Menu

React Native SDK

SDK v2
Last updated January 2024

Create your own uniquely styled and branded checkout form by integrating our SDK into your native app.

Read more about the Checkout SDK and the supported payment journeyshere.

Note: Make yourself familiar with ourAPI Principlesto ensure a resilient integration.

How does it work?

We are securing your customer's payment details by generating sessions. You can thencreate a tokenwith the card details and optionally use the CVC totake a payment.

What is a session?

A session is a unique identifier for your customer's payment details, generated by the SDK.

Prerequisites

The React Native SDK is compatible with the following:

  • react-native version >= 0.70.0
  • react version >= 18.1
  • For iOS dependencies, Cocoapods support only.

Get our SDK

  1. Run the following command to install our SDK.

    Copied!
    npm install @worldpay/access-worldpay-checkout-react-native-sdk
    yarn add @worldpay/access-worldpay-checkout-react-native-sdk
  2. Add a dependency to the Android Bridge in the Android part of your application.

    1. Define in your android/build.gradle file a local maven Repo for the Android Bridge which is shipped with the SDK.

      Copied!
      maven { url("$rootDir/../node_modules/@worldpay/access-worldpay-checkout-react-native-sdk/android/") }
    2. Add the Android Bridge dependency in your gradle configuration.

      Copied!
      dependencies { 
         ...
         implementation "com.worldpay.access:access-checkout-react-native-sdk-android-bridge:+"
         ...
      }
    3. Add the AccessCheckoutReactPackage which contains the Android Bridge to the list of ReactPackage exposed by your ReactApplication.

      Copied!
      ...
      import com.worldpay.access.checkout.reactnative.AccessCheckoutReactPackage;
      
      public class MainActivity extends ReactActivity {
        ...
      
        public static class MainApplication extends Application implements ReactApplication {
      
          private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
            @Override
            public boolean getUseDeveloperSupport() {
              ...
            }
      
            @Override
            protected List<ReactPackage> getPackages() {
              List<ReactPackage> packages = new PackageList(this).getPackages();
              ...
              packages.add(new AccessCheckoutReactPackage());
      
              return packages;
            }
      
            @Override
            protected String getJSMainModuleName() {
              ...
            }
          };
      
          @Override
          public ReactNativeHost getReactNativeHost() {
            return mReactNativeHost;
          }
      
          @Override
          public void onCreate() {
            ...
          }
        }
      }
      ...
      import com.worldpay.access.checkout.reactnative.AccessCheckoutReactPackage
      
      class MainActivity : ReactActivity() {
        ...
      
        class MainApplication : Application(), ReactApplication {
      
          private val mReactNativeHost: ReactNativeHost = object : ReactNativeHost(this) {
            @get:Override
            val useDeveloperSupport: Boolean
              get() = ...
      
            @get:Override
            protected val packages: List<Any>
              protected get() {
                val packages: List<ReactPackage> = PackageList(this).getPackages()
                ...
                packages.add(AccessCheckoutReactPackage())
      
                return packages
              }
      
            @get:Override
            protected val jSMainModuleName: String
              protected get() = ...
          }
      
          @get:Override
          val reactNativeHost: ReactNativeHost
            get() = mReactNativeHost
      
          @Override
          fun onCreate() {
            super.onCreate()
            ...
          }
        }
      }
  3. Add a dependency to the iOS Bridge in the iOS part of your application.

    To add the iOS dependency into your application, define the dependencies in the Podfile.

    Copied!
    target 'my-app' do
       ...
       pod 'AccessCheckoutReactNativeSDKiOSBridge', :path => '../node_modules/@worldpay/access-worldpay-checkout-react-native-sdk/ios/'
    end

What to do next

See our guides on how to create sessions you can use to take a payment:

Note: For one-time payments, you mustdelete the tokenafter you take the payment.

Create a session to pay with a card

  1. Submit card details to create a session
  2. Create averified token
  3. Take a paymentwith this token

Create sessions to pay with a card and CVC

  1. Submit card details and CVC to create two separate sessions
  2. Create averified tokenwith your CARD session
  3. Use your CVC session and verified token in our card/checkout payment instrument totake a payment

Create a session for CVC only and pay with a stored token

  1. Submit the CVC to create a session
  2. Use your cvc session and stored verified token in our card/checkout payment instrument totake a payment