React Native SDK
Take payments in a React Native app on iOS and Android, with Pay.com's ready-made payment sheet or SDK-owned card fields on your own screen.
The Pay.com React Native SDK, @pay-com/react-native, takes payments in a React Native app on iOS and Android, in TypeScript. It's a thin bridge over Pay.com's native iOS and Android SDKs. Payments, card validation, 3DS, and client-side encryption run in native code. Your server creates a session, the app starts a checkout with the session's client_secret, and the SDK takes the payment:
- A ready-made payment sheet. The drop-in shows a card form, the session's redirect methods, Apple Pay on iOS and Google Pay on Android when you turn them on, the save-card choice, and a Pay button labeled with the amount. A decline shows in the sheet, and the customer can try again.
- Or your own screen. Place the SDK's card fields in your layout, list the session's methods, and pay with
checkout.pay(). - Card data never reaches JavaScript. The card inputs are the native SDKs' own views. JavaScript sees only validation state, the card brand, and the first 8 digits.
- 3DS and redirects handled for you. They open over the app's current screen, and redirects come back through React Native's
Linking. - Saved and payout methods. At checkout, the customer can pay with one of their saved cards, PayPal accounts, or bank accounts. In a setup session, the customer keeps one of their saved methods or adds one. In a payout setup session, a recipient chooses where their payouts go.
The drop-in for a new customer, on iOS and on Android:
Requirements
@pay-com/react-native runs on the New Architecture, with these minimum versions.
| Requirement | Version |
|---|---|
| React Native | 0.88 or later |
| Architecture | New Architecture only (TurboModules and Fabric) |
| iOS | 15.1 or later, React Native 0.88's minimum |
| Android | minSdk 24 (Android 7.0) |
Install
Add the package, then install the iOS pods:
npm install @pay-com/react-native
cd ios && pod installReact Native's autolinking adds the native code. The pod brings in the Pay.com iOS SDK, and the Android module brings in the Pay.com Android SDK, so you don't add either yourself.
Redirect payment methods come back to the app at its return URL, such as myshop://pay. Register that URL with the app. See Set up deep links.
How a payment works
A payment moves from your server to the app and back in five steps.
- Your server creates a session with Create a payment session, with
return_urlset to the app's return URL, and sends only itsclient_secretto the app. The app never holds your API key. - The app starts a checkout with
PayCheckout.create(). - The app shows the drop-in with
checkout.presentDropIn(). Or it shows the card fields on its own screen and callscheckout.pay(). The SDK sends the card to Pay.com from native code, runs 3DS when the session asks for it, and shows any challenge or redirect. - The call resolves with a
PayResult. Treat it as a hint for your UI. Your server confirms the payment with Retrieve a payment session or thepayment_session.completedwebhook before it fulfills the order. - The app frees the checkout with
checkout.release().
Accept payments in your React Native app
Take a first payment, with the drop-in or your own screen.
Start a checkout
Load a session from its client_secret.
Present the drop-in
Pay.com's ready-made payment sheet, with Apple Pay and Google Pay.
Card fields
SDK-owned card inputs for your own screen.
Pay
Pay with a card, a redirect method, or a saved method.
Pay with a saved payment method
Saved cards, PayPal accounts, and bank accounts at checkout.
Let customers choose a payout method
Saved methods in setup and payout sessions.
Types
Results, errors, and their codes.