Skip to Content
Docs

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:

Illustration of the iOS drop-in for a new customer: Close, Example shop and €24.90, an Apple Pay button, "or", a Pay with list with Card selected, PayPal, and iDEAL, each with its logo, the card fields, and a Pay €24.90 button with the accepted card brands under it.Illustration of the Android drop-in for a new customer: Example shop and €24.90 with Close, a Google Pay button, "or", a Pay with list with Card selected by radio, PayPal, and iDEAL, each with its logo, outlined card fields, and a Pay €24.90 button with the accepted card brands under it.

Requirements

@pay-com/react-native runs on the New Architecture, with these minimum versions.

RequirementVersion
React Native0.88 or later
ArchitectureNew Architecture only (TurboModules and Fabric)
iOS15.1 or later, React Native 0.88's minimum
AndroidminSdk 24 (Android 7.0)

Install

Add the package, then install the iOS pods:

npm install @pay-com/react-native
cd ios && pod install

React 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.

  1. Your server creates a session with Create a payment session, with return_url set to the app's return URL, and sends only its client_secret to the app. The app never holds your API key.
  2. The app starts a checkout with PayCheckout.create().
  3. The app shows the drop-in with checkout.presentDropIn(). Or it shows the card fields on its own screen and calls checkout.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.
  4. 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 the payment_session.completed webhook before it fulfills the order.
  5. The app frees the checkout with checkout.release().
Was this page helpful?