Search Overlay

Apple Pay - React Native SDK

The React Native Apple Pay SDK enables Apple Pay integration in React Native applications via PassKit and PaysafePaymentsSDK.

  • Prerequisite: Complete the common setup before making Apple Pay calls.
  • Package: @paysafe/react-native-paysafe-apple-pay v2.0.2+
  • Platform: iOS only
  • Requirements:
    • React Native 0.76+ with the New Architecture enabled
    • @paysafe/paysafe-payments-sdk-common v2.0.0+
  • Turbo module support: Available from v2.0.0. To use the legacy bridge architecture, remain on version 1.x.
  • Additional resources:

Installation

npm install @paysafe/react-native-paysafe-apple-pay @paysafe/paysafe-payments-sdk-common
cd ios && pod install && cd ..

The react-native-paysafe-apple-pay pod installs PaysafePaymentsSDK and Apple PassKit dependencies.

Xcode

  • Enable the Apple Pay capability.
  • Add your Merchant ID. This must match the merchantIdentifier value used in your code.
  • Use a Paysafe card account with Apple Pay enabled (native SDK validates on init).

Android

Apple Pay is not supported on Android.

  • initializeApplePayContext() and tokenize() throw an exception on non-iOS platforms.
  • resetApplePayContext() performs no action.
  • isApplePayAvailable() returns all availability flags as false.

JavaScript API

Turbo module: RNPaysafeApplePay (RNPaysafeApplePaySpec, RCTNativeRNPaysafeApplePay on iOS)

Function Description
initializeApplePayContext(options) Initializes the Paysafe Apple Pay context. iOS only; throws on other platforms.
tokenize(options) Presents the Apple Pay sheet and returns a PaysafeApplePayPaymentResult.
resetApplePayContext() Clears the native context, for example when a component is unmounted.
isApplePayAvailable(request?) Checks Apple Pay availability through PassKit. Optionally accepts supportedNetworks.
validateInitializeContextOptions
validateTokenizeOptions
JavaScript validation helpers.
import { setup, getMerchantReferenceNumber } from '@paysafe/paysafe-payments-sdk-common';
import {
initializeApplePayContext,
isApplePayAvailable,
tokenize,
resetApplePayContext,
} from '@paysafe/react-native-paysafe-apple-pay';

Types include ApplePayInitializeContextOptions, PaysafeApplePayTokenizeOptions, PaysafeApplePayPaymentResult, and others defined in packages/paysafe-apple-pay/src/types.ts.

Integration flow

Step Action
1 Complete the common setup
2 Call isApplePayAvailable({ supportedNetworks: ['visa', 'masterCard'] })
3 Call initializeApplePayContext({ currencyCode, accountId, merchantIdentifier, countryCode })
4 Call tokenize({ amount, currencyCode, transactionType, merchantRefNum, accountId, profile, psApplePay, ... })
5 If result.isSuccess, send result.token to the backend.
6 Call resetApplePayContext() when leaving the Apple Pay flow.

Apple Pay and Venmo v2.x use Promises for initialization and tokenization. Card payments and Google Pay use device events for completion. Card payments also stream CardPaymentEnabled and CardPaymentDisabled events for form validity.

Context initialization

await setup(apiKey, 'TEST');
const availability = await isApplePayAvailable({
supportedNetworks: ['visa', 'masterCard', 'amex', 'discover'],
});
await initializeApplePayContext({
currencyCode: 'USD',
accountId: 'YOUR_ACCOUNT_ID',
merchantIdentifier: 'merchant.com.your.app',
countryCode: 'US',
});

Tokenization

const result = await tokenize({
amount: 1099,
currencyCode: 'USD',
transactionType: 'PAYMENT',
merchantRefNum: await getMerchantReferenceNumber(),
accountId: 'YOUR_ACCOUNT_ID',
profile: {
firstName: 'Jane',
lastName: 'Doe',
email: 'jane@example.com',
},
psApplePay: {
label: 'Order total',
requestBillingAddress: false,
},
requestBillingAddress: false,
});

if (result.isSuccess) {
console.log(result.token);
} else {
console.error(result.error);
}

Optional parameters include billingDetails, shippingDetails, merchantDescriptor, and simulator (EXTERNAL or INTERNAL).

Invalid options throw a JavaScript error before the native Apple Pay sheet is displayed.

PaysafeApplePayPaymentResult

Field Description
isSuccess true if tokenization succeeded.
token Payment handle token returned when successful.
error Error details returned when unsuccessful.

Credentials and configuration

Value Source
API key and environment Common setup
Account ID Paysafe Portal (Apple Pay-enabled card account)
Merchant ID Apple Developer account and Xcode (merchant.com...)

In the demo application, use EXPO_PUBLIC_PAYSAFE_APPLE_PAY_ACCOUNT_ID and EXPO_PUBLIC_APPLE_PAY_MERCHANT_ID as defined in .env.example.

Expo vs bare React Native

Topic Guidance
Expo Go Not supported.
Development build Run npx expo run:ios after pod install.
Config plugin No Apple Pay config plugin is required. Configure the capability and Merchant ID in Xcode.

Test on a real device or on a simulator with Apple Pay configured. Some flows require hardware or wallet setup.

Linking and errors

  • Rebuild the iOS application after installation and run pod install.
  • Do not import generated headers from unrelated pods into AppDelegate (for example, PaysafeVenmo-Swift.h). Although not specific to Apple Pay, this is a common iOS integration issue in this repository.

Troubleshooting

Symptom Check
initializeApplePayContext() throws an error Verify that the application is running on iOS and that a valid Account ID and Merchant ID are configured.
Apple Pay sheet does not appear Verify that isApplePayAvailable() returns true, Apple Pay is configured on the device, and at least one supported payment card is available in the wallet.
Account validation fails Verify that Apple Pay is enabled for the Paysafe account and environment being used.

Integration verification

To verify the integration, confirm the following:

  1. setup succeeds.
  2. isApplePayAvailable confirms that the device can pay.
  3. tokenize returns isSuccess: true and a token in the TEST environment.

You can also test the integration in DemoAppExpo by selecting Test Apple Pay. This option is available on iOS only.

Test files:

  • packages/paysafe-apple-pay/__tests__/
  • DemoAppExpo/__tests__/applePayScreen.test.tsx