Checkout React Native Components

For detailed integration steps, refer to our
official documentation ↗️ .
🚀 Quick Start
Installation
Install the package using your preferred package manager:
npm install @checkout.com/checkout-react-native-components
yarn add @checkout.com/checkout-react-native-components
Platform Setup
This package supports both React Native architectures (New Architecture/Fabric and Old Architecture/Paper) out of the box.
📱 iOS Setup
cd ios
pod install
🤖 Android Setup
Add the following repositories to your app's settings.gradle:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)
repositories {
google()
mavenCentral()
maven { url = uri("https://jitpack.io") }
maven { url = uri("https://maven.fpregistry.io/releases") }
}
}
Or add the allProjects block to the project build.gradle:
allprojects {
repositories {
google()
mavenCentral()
maven { url 'https://maven.fpregistry.io/releases' }
maven { url 'https://www.jitpack.io' }
}
}
To enable Google Pay payments the following metadata tag must be added to your AndroidManifest.xml:
<meta-data
android:name="com.google.android.gms.wallet.api.enabled"
android:value="true" />
While not mandatory, we recommend setting android:allowBackup to false in your AndroidManifest.xml. Failing to set it to false or to override our default value with your own will result in a manifest merge error.
Requirements:
- New Arch: Android Studio Ladybug 2024.2.2
- Old Arch: Android Studio Koala 2024.1.1
💡 Tip: Use JetBrains Toolbox for easy Android Studio version management.
Expo Setup
Our package cannot run in Expo Go. Instead, you need to run:
npx expo prebuild
This command compiles your app with our package included.
For Android, the repositories step above is a hard requirement to resolve dependencies. Our package provides a general-purpose plugin that appends the repositories defined in the Android Setup block above. The plugin can also append the Google Pay tag to the AndroidManifest.xml if required.
If your app already uses custom plugins that modify build.gradle or AndroidManifest.xml, we recommend extending your existing plugin or creating an additional plugin to customize adding the repositories block to fit your use case. You can find documentation on writing Expo plugins here.
The android:allowBackup tag and plugins can be set in app.json like so:
"android": {
"allowBackup": false
},
"plugins": [
[
"@checkout.com/checkout-react-native-components",
{
"enableGooglePay": true
}
]
]
🧩 Components Overview
| Flow | Complete payment flow with multiple payment methods | iOS/Android | 3DS support, dynamic payment methods, built-in validation |
| Card | Secure card input form | iOS/Android | Card validation, tokenization, custom styling |
| Apple Pay | Native Apple Pay integration | iOS only | Seamless iOS payment experience |
| Google Pay | Native Google Pay integration | Android only | Seamless Android payment experience |
⚙️ Core Configuration
CheckoutProvider Setup
Wrap your payment screen with CheckoutProvider to enable payment functionality.
Create a Payment Session and pass it to CheckoutProvider.
import {
CheckoutProvider,
CheckoutConfiguration,
Environment,
Locale
} from '@checkout.com/checkout-react-native-components';
const config: CheckoutConfiguration = {
publicKey: 'pk_test_your_public_key',
environment: 'sandbox',
locale: Locale.en_GB,
merchantIdentifier: 'merchant.com.your-app.name',
translations: {
[Locale.en_GB]: {
cardNumber: 'Card Number',
payButtonPay: 'Pay Now'
}
},
style: {
colorTokensMain: {
primary: '#186AFF',
background: '#FFFFFF',
border: '#E3E8F2',
error: '#E01E5A'
},
borderButtonRadius: 12,
borderFormRadius: 8
}
};
export default function PaymentScreen() {
const [paymentSession, setPaymentSession] = useState({
id: '',
payment_session_secret: ''
});
useEffect(() => {
fetchPaymentSession().then((data) => {
setPaymentSession(data);
});
}, []);
return (
<CheckoutProvider
config={config}
onSuccess={(paymentMethod, paymentID) => {
console.log('Payment successful:', { paymentMethod, paymentID });
}}
onError={(error) => {
console.error('Payment error:', error);
}}
paymentSession={paymentSession}
>
{/* Your app components */}
</CheckoutProvider>
);
}
📝 Configuration Options
publicKey | string | ✅ | Your Checkout.com public API key |
environment | 'sandbox' | 'production' | ✅ | Environment for API calls |
locale | string | ❌ | Locale for UI text (defaults to English) |
merchantIdentifier | string | ❌ | Apple Pay merchant identifier |
translations | Record<string, Translations> | ❌ | Custom text translations |
style | Style | ❌ | UI customization options |
📖 Component Reference
Flow Component
The Flow component provides a complete payment experience with support for multiple payment methods, 3D Secure, and dynamic payment method display.
🔧 Flow Configuration & Usage
Basic Usage
import { Flow } from '@checkout.com/checkout-react-native-components';
const PaymentScreen = () => {
return (
<CheckoutProvider config={config} paymentSession={paymentSession}>
<Flow style={{ marginVertical: 20 }} />
</CheckoutProvider>
);
};
Imperative API Usage
const PaymentScreen = () => {
const flowRef = useRef<FlowRef>(null);
const handleSubmit = () => {
flowRef.current?.submit();
};
const handleTokenize = () => {
flowRef.current?.tokenize();
};
return (
<CheckoutProvider config={config} paymentSession={paymentSession}>
<Flow
ref={flowRef}
config={{ showPayButton: false }} // Hide built-in pay button
/>
<Button title="Pay" onPress={handleSubmit} />
<Button title="Tokenize Card" onPress={handleTokenize} />
</CheckoutProvider>
);
};
Flow Props
config | FlowConfig | ❌ | Flow-specific configuration |
style | ViewStyle | ViewStyle[] | ❌ | React Native styling |
ref | FlowRef | ❌ | Imperative API reference |
FlowConfig Options
showPayButton | boolean | true | Show/hide the built-in pay button |
paymentButtonAction | 'payment' | 'tokenize' | 'payment' | Action when pay button is pressed |
Card Component
The Card component provides a secure card input form ideal for custom checkout implementations.
💳 Card Configuration & Usage
Basic Usage
import { Card, CardRef } from '@checkout.com/checkout-react-native-components';
const CardPaymentScreen = () => {
const cardRef = useRef<CardRef>(null);
const handleSubmit = () => {
cardRef.current?.submit();
};
return (
<CheckoutProvider config={config} paymentSession={paymentSession}>
<Card
ref={cardRef}
config={{ showPayButton: false }}
/>
</CheckoutProvider>
);
};
Card Props
config | CardConfig | ❌ | Card-specific configuration |
style | ViewStyle | ViewStyle[] | ❌ | React Native styling |
ref | CardRef | ❌ | Imperative API reference |
CardConfig Options
showPayButton | boolean | true | Show/hide the built-in pay button |
paymentButtonAction | 'payment' | 'tokenize' | 'payment' | Action when pay button is pressed |
Apple Pay Component
The Apple Pay component provides native Apple Pay integration for iOS devices.
🍎 Apple Pay Configuration & Usage
Basic Usage
import { ApplePay, CheckoutProvider } from '@checkout.com/checkout-react-native-components';
const PaymentScreen = () => {
return (
<CheckoutProvider
config={{
...config,
merchantIdentifier: 'merchant.com.your-app.name' // Required!
}}
paymentSession={paymentSession}
>
<ApplePay style={{ height: 60, marginVertical: 10 }} />
</CheckoutProvider>
);
};
Apple Pay Props
style | ViewStyle | ViewStyle[] | ❌ | React Native styling |
📝 Note: Apple Pay requires a valid merchantIdentifier in your CheckoutConfiguration and is only available on iOS devices.
Google Pay Component
The Google Pay component provides native Google Pay integration for Android devices.
🤖 Google Pay Configuration & Usage
Basic Usage
import { CheckoutProvider, GooglePay } from '@checkout.com/checkout-react-native-components';
const PaymentScreen = () => {
return (
<CheckoutProvider config={config} paymentSession={paymentSession}>
<GooglePay />
</CheckoutProvider>
);
};
Google Pay Props
config | GooglePayConfig | ❌ | Google Pay configuration (reserved for future use) |
style | ViewStyle | ViewStyle[] | ❌ | React Native styling |
📝 Note: Google Pay is only available on Android devices.
🔧 Advanced Features
Imperative API
Both Flow and Card components support imperative APIs for programmatic control:
import { CheckoutProvider, Card, Flow, FlowRef, CardRef } from '@checkout.com/checkout-react-native-components';
const PaymentScreen = () => {
const flowRef = useRef<FlowRef>(null);
const cardRef = useRef<CardRef>(null);
const processPayment = async () => {
flowRef.current?.submit();
};
const tokenizeCard = async () => {
cardRef.current?.tokenize();
};
return (
<CheckoutProvider config={config} paymentSession={paymentSession}>
<Flow ref={flowRef} config={{ showPayButton: false }} />
<Card ref={cardRef} config={{ showPayButton: false }} />
<Button title="Process Payment" onPress={processPayment} />
<Button title="Save Card" onPress={tokenizeCard} />
</CheckoutProvider>
);
};
🎨 Customization
🎨 Complete Color Token Reference
const customStyle = {
colorTokensMain: {
primary: '#186AFF',
background: '#FFFFFF',
formBackground: '#F7F9FC',
border: '#E3E8F2',
formBorder: '#C8D1E0',
outline: '#91B2EE',
error: '#E01E5A',
success: '#1AA27B',
disabled: '#B0B0B0',
secondary: '#545F7A',
inverse: '#FFFFFF',
action: '#186AFF',
scrolledContainer: '#F0F0F0'
}
};
📏 Border Radius
const customBorders = {
borderButtonRadius: 12,
borderFormRadius: 8
};
🌍 Supported Locales & Custom Translations
Supported Locales
enum Locale {
ar = 'ar',
da_DK = 'da-DK',
de_DE = 'de-DE',
el = 'el',
en_GB = 'en-GB',
es_ES = 'es-ES',
fi_FI = 'fi-FI',
fil_PH = 'fil-PH',
fr_FR = 'fr-FR',
hi_IN = 'hi-IN',
id_ID = 'id-ID',
it_IT = 'it-IT',
ja_JP = 'ja-JP',
ms_MY = 'ms-MY',
nb_NO = 'nb-NO',
nl_NL = 'nl-NL',
pt_PT = 'pt-PT',
sv_SE = 'sv-SE',
th_TH = 'th-TH',
vi_VN = 'vi-VN',
zh_CN = 'zh-CN',
zh_HK = 'zh-HK',
zh_TW = 'zh-TW'
}
Translations Interface
All available translation keys with their descriptions:
export type Translations = {
addBillingAddress?: string;
addAddress?: string;
address?: string;
addressLine1?: string;
addressLine2?: string;
billingAddress?: string;
card?: string;
cardExpiryDate?: string;
cardExpiryDateIncomplete?: string;
cardExpiryDateInvalid?: string;
cardExpiryDatePlaceholderMonth?: string;
cardExpiryDatePlaceholderYear?: string;
cardHolderName?: string;
cardNumber?: string;
cardNumberInvalid?: string;
cardNumberNotSupported?: string;
cardSecurityCode?: string;
cardSecurityCodeInvalid?: string;
cardSecurityCodePlaceholder?: string;
city?: string;
confirm?: string;
country?: string;
selectCountry?: string;
editAddress?: string;
email?: string;
emailFormatInvalid?: string;
firstName?: string;
formRequired?: string;
lastName?: string;
insufficientCharacters?: string;
noMatchesFound?: string;
optional?: string;
payButtonPay?: string;
payButtonPaymentComplete?: string;
payButtonPaymentProcessing?: string;
paymentDeclinedInvalidCustomerData?: string;
paymentDeclinedInvalidPaymentSessionData?: string;
paymentDeclinedMerchantMisconfiguration?: string;
paymentDeclinedNotEnoughFunds?: string;
paymentDeclinedTryAgain?: string;
phoneNumber?: string;
search?: string;
state?: string;
trySearchingWithAnotherTerm?: string;
useShippingAsBilling?: string;
zip?: string;
preferredSchemeCta?: string;
preferredSchemeDescription?: string;
selectState?: string;
};
Custom Translations Example
const customTranslations = {
[Locale.en_GB]: {
addBillingAddress: 'Add Billing Address',
addAddress: 'Add Address',
address: 'Address',
addressLine1: 'Address Line 1',
addressLine2: 'Address Line 2',
billingAddress: 'Billing Address',
card: 'Card',
cardNumber: 'Card Number',
cardExpiryDate: 'MM/YY',
cardExpiryDatePlaceholderMonth: 'MM',
cardExpiryDatePlaceholderYear: 'YY',
cardSecurityCode: 'CVV',
cardSecurityCodePlaceholder: 'CVV',
cardHolderName: 'Cardholder Name',
firstName: 'First Name',
lastName: 'Last Name',
email: 'Email Address',
phoneNumber: 'Phone Number',
city: 'City',
state: 'State/Province',
zip: 'ZIP/Postal Code',
country: 'Country',
selectCountry: 'Select Country',
selectState: 'Select State',
payButtonPay: 'Pay Now',
payButtonPaymentProcessing: 'Processing...',
payButtonPaymentComplete: 'Payment Complete',
confirm: 'Confirm',
editAddress: 'Edit Address',
search: 'Search',
formRequired: 'This field is required',
cardNumberInvalid: 'Invalid card number',
cardNumberNotSupported: 'Card type not supported',
cardExpiryDateIncomplete: 'Expiry date incomplete',
cardExpiryDateInvalid: 'Invalid expiry date',
cardSecurityCodeInvalid: 'Invalid security code',
emailFormatInvalid: 'Invalid email format',
insufficientCharacters: 'Insufficient characters',
paymentDeclinedTryAgain: 'Payment declined. Please try again.',
paymentDeclinedNotEnoughFunds: 'Insufficient funds',
paymentDeclinedInvalidCustomerData: 'Invalid payment details',
paymentDeclinedInvalidPaymentSessionData: 'Invalid payment session data',
paymentDeclinedMerchantMisconfiguration: 'Merchant configuration error',
noMatchesFound: 'No matches found',
trySearchingWithAnotherTerm: 'Try searching with another term',
optional: 'Optional',
useShippingAsBilling: 'Use shipping address as billing address',
preferredSchemeCta: 'Select Preferred Scheme',
preferredSchemeDescription: 'Please select your preferred card scheme'
}
};
📡 Event Handling
📋 Complete Event Reference
const eventHandlers = {
onReady: (paymentMethod: string) => {
console.log('Component ready for:', paymentMethod);
},
onChange: (paymentMethod: string, isValid: boolean) => {
console.log('Form state changed:', { paymentMethod, isValid });
},
onSubmit: (paymentMethod: string) => {
console.log('Payment submitted for:', paymentMethod);
},
onTokenized: (tokenizationResult: TokenizationResult) => {
console.log('Card tokenized:', tokenizationResult);
},
onSuccess: (paymentMethod: string, paymentID: string) => {
console.log('Payment successful:', { paymentMethod, paymentID });
},
onError: (error: Error) => {
console.error('Payment error:', error);
},
};
<CheckoutProvider {...eventHandlers}>
{/* Components */}
</CheckoutProvider>
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.