The React Native Mobile SDK wrapper provides a bridge between a React Native based application and the native Number mobile SDK libraries.
Number's Android and iOS SDK libraries are required for use of the wrapper. It is highly recommended that you review the core SDK products before proceeding.
Installation
Requirements
Mac OS based workstation v15 or newer
Xcode v16.2 or newer
Android Studio Ladybug Feature Drop | 2024.2.2 or newer
React Native CLI
React Native v0.77 without new architecture enabled
Node v18.19.0 or newer
npm v10.8.2 or newer
Prerequisites
Before beginning your implementation you will need a Number account. It should include the following:
Session Key: this authenticates you to a particular account.
HMAC secret: used to create a hash which proves your request is authentic.
RSA Certificate: to encrypt the credit card number prior to transmission.
A sentry.io key: used for logging events and errors.
Merchant record or merchant ID: Each Number account can support multiple merchant records.
Each merchant record can be a separate location center which generates a separate daily settlement report. Many of our API calls require that you specify which merchant ID to use.
Installation instructions
1
Setup your environment
Make sure you have completed the React Native - Environment Setup instructions until the "Creating a new application" step before proceeding.
2
Install components
For iOS
From the project's root folder, run npm install. This will load the node_modules packages that are listed in the package.json file. Change directories to the iOS folder and run pod install.
# in a terminal window
npm install
cd ios
pod install
3
Configure keys
In the app.tsx file, pass your configuration toEasyPayModule.configureSecrets:
First, you will need to start the Metro Server, the JavaScript bundler that ships with React Native. To start Metro, run the following command from the root of your React Native project:
# using npm
npm start
# OR using Yarn
yarn start
Let the Metro Bundler run in its own terminal. To run the app, open a new terminal from the root of your React Native project and run one of the following commands:
# using npm
npm run android
# OR using Yarn
yarn android
# using npm
npm run ios
# OR using Yarn
yarn ios
If everything is set up correctly, you should see your new app running in your Android Emulator or iOS Simulator.
This is one way to run your app — you can also run it directly from within Android Studio and Xcode respectively. To launch the wrapper in XCode, click on the EasyPayRN.xcworkspace file.
Certificates
When API traffic originates from unknown networks or mobile devices, we mandate that any credit card numbers be encrypted prior to transmission to Number. We will provide an RSA 2048 certificate which is used by Number's Android and iOS SDKs to automatically encrypt the card data.
During the initialization, the process of downloading the certificate is starting. Proceeding with any call before downloading has finished will result in an error RsaCertificateError.failedToLoadCertificateData.
To test the certificate download, call:
EasyPayModule.loadCertificate()
Using the widgets
Number's prebuilt payment UI components allow you to collect and process credit card information in a secure way.
Managing cards
For managing saved cards without making a payment, the following initializer should be used:
The config and payment objects are used for passing additional payment details not visible for the end user. Either customerReferenceId or rpguid must be provided to get the list of consents of a specific customer.
In case of of incorrect data, CardSelectionViewControllerInitError will be thrown.
Collecting payments
For managing saved cards and collecting a payment, following initializer should be used:
Communication between the Number SDK widgets and the React Native wrapper is handled via event emitters. These event emitters allow you to respond to user events such as a payment being processed.
The EasyPayModule.swift file contains functions that map to the iOS SDK's CardPaymentDelegate and CardSelectionDelegate protocols. These functions send events that are received in the wrapper's JavaScript code.