Example app
The repository includes a full example app in the example/ folder: an Expo app that demonstrates the checkout flow with usePaymentCheckout, cart management, and platform-specific buttons.
Key checkout snippet
From example/app/(tabs)/index.tsx:
import { Platform } from 'react-native'
import {
ApplePayButton,
GooglePayButton,
usePaymentCheckout,
} from '@gmisoftware/react-native-pay'
import { callback } from 'react-native-nitro-modules'
const {
canMakePayments,
isCheckingStatus,
items,
total,
addItems,
clearItems,
startPayment,
isProcessing,
reset,
} = usePaymentCheckout({
countryCode: 'US',
currencyCode: 'USD',
})
const handleAddCoffee = () => {
clearItems()
addItems([
{ label: 'Coffee', amount: 4.99 },
{ label: 'Tax', amount: 0.5 },
])
}
const handlePayment = async () => {
const paymentResult = await startPayment()
if (paymentResult?.success) {
reset()
clearItems()
}
}
{Platform.OS === 'ios' ? (
<ApplePayButton
buttonType="buy"
buttonStyle="black"
onPress={callback(handlePayment)}
style={{ width: '100%', height: 56 }}
/>
) : (
<GooglePayButton
buttonType="buy"
theme="dark"
radius={8}
onPress={callback(handlePayment)}
style={{ width: '100%', height: 56 }}
/>
)}
What’s in the full example
- Checkout flow — Add items (e.g. “Coffee”, “Subscription”), see cart and total, then pay with Apple Pay or Google Pay.
- Status — Check whether the device can make payments or only set up cards.
- Cart UI — Add/clear items and display total.
- Result handling — Success and error messages; reset and clear cart after success.
- Nitro
callback— Buttons usecallback(handlePayment)(see Troubleshooting: Nitro callback for onPress).
Run the example
From the repo root:
cd example
bun install
npx expo prebuild
npx expo run:ios
# or
npx expo run:android
Or from the root (if scripts are set up):
bun run ios
# or
bun run android
What to copy from the example
Use the checkout screen in the example app as a reference for:
- Calls
usePaymentCheckoutwithcountryCode,currencyCode, and optional platform-specific overrides. - Shows a loading state while
isCheckingStatusis true. - Renders “Quick Add” buttons that call
addItemsoraddItem. - Displays the cart (items + total) and a “Clear” action.
- Renders ApplePayButton on iOS and GooglePayButton on Android with
callback(handlePayment). - On successful payment, shows an alert and calls
reset()andclearItems().
Copy these patterns into your app: config setup, cart handling, button usage, and native-safe onPress handlers.
Plugin config in the example
The example’s app.json includes the React Native Pay plugin (e.g. with a demo Merchant ID and Google Pay enabled). Change the plugin merchantIdentifier and any Google Pay runtime settings to your own for real payments.
Next
- Quick Start — Minimal integration in your app
- API: usePaymentCheckout — Hook options and return value
- Troubleshooting — Common integration issues and fixes