npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-apple-pay-token

v0.2.2

Published

React Native module to handle Apple Pay tokens

Downloads

8

Readme

react-native-apple-pay-token

React Native module to handle Apple Pay tokens

Installation

Before using these functions, make sure you have installed and properly configured the react-native-apple-pay package in your React Native project.

yarn add react-native-apple-pay

Configuration

Before using these functions, you must configure your Info.plist file by setting the ApplePayMerchantIdentifier variable to your Apple Pay merchant identifier.

Follow these steps:

  1. Open your Xcode project.
  2. Locate your Info.plist file in the project navigator.
  3. Add the following key-value pair to your Info.plist file, replacing YOUR_MERCHANT_IDENTIFIER with your actual Apple Pay merchant identifier:
<key>ApplePayMerchantIdentifier</key>
<string>YOUR_MERCHANT_IDENTIFIER</string>

Usage

Import the necessary functions from react-native-apple-pay to use them in your code. Here are the available functions:

getApplePayToken

This function is used to obtain an Apple Pay token for a specific transaction.

Parameters

  • tiket (number): The ticket or item price.
  • tax (number): The tax amount for the transaction.
  • total (number): The total amount for the transaction. Returns
  • A Promise that resolves to an Object containing the Apple Pay token.

Example

import { getApplePayToken } from 'react-native-apple-pay';

const tiket = 100.0;
const tax = 10.0;
const total = tiket + tax;

getApplePayToken(tiket, tax, total)
  .then((token) => {
    // Handle the Apple Pay token
    console.log('Apple Pay Token:', token);
  })
  .catch((error) => {
    // Handle errors
    console.error('Error:', error);
  });

canMakePayments

This function checks if the device is capable of making payments using Apple Pay.

Returns A Promise that resolves to a boolean value, indicating whether Apple Pay payments can be made on the device.

Example

import { canMakePayments } from 'react-native-apple-pay';

canMakePayments()
  .then((canMake) => {
    if (canMake) {
      // Apple Pay is available
      console.log('Apple Pay is available on this device.');
    } else {
      // Apple Pay is not available
      console.log('Apple Pay is not available on this device.');
    }
  })
  .catch((error) => {
    // Handle errors
    console.error('Error:', error);
  });

canSetupCards

This function checks if the device is capable of setting up cards for Apple Pay.

Returns A Promise that resolves to a boolean value, indicating whether Apple Pay card setup is supported on the device.

Example

import { canSetupCards } from 'react-native-apple-pay';

canSetupCards()
  .then((canSetup) => {
    if (canSetup) {
      // Card setup is available
      console.log('Apple Pay card setup is available on this device.');
    } else {
      // Card setup is not available
      console.log('Apple Pay card setup is not available on this device.');
    }
  })
  .catch((error) => {
    // Handle errors
    console.error('Error:', error);
  });

navigateToSetup

This function navigates the user to the Apple Pay card setup screen.

Returns A Promise that resolves once the user has been navigated to the card setup screen.

Example

import { navigateToSetup } from 'react-native-apple-pay';

navigateToSetup()
  .then(() => {
    // User has been navigated to the card setup screen
    console.log('Navigated to Apple Pay card setup.');
  })
  .catch((error) => {
    // Handle errors
    console.error('Error:', error);
  });

License

MIT