SDKs
React Native SDK
Take crypto payments in a React Native app (Android and iOS, bare or Expo dev build). The checkout opens as a full-screen modal in your app and returns a typed result.
- Package:
@razcrypto/react-nativeon npm - Version: 1.0.0
- Requires: React 18+, React Native 0.72+,
react-native-webview13+ - Key in the app: none (opens the
checkout_urlfrom your server), or the publishable keypk_… - Download: razcrypto-react-native-sdk.zip · Source on GitHub · MIT
How it works
- The app asks your server to start a payment.
- Your server creates it with the secret key and returns the
checkout_url(PHP / Laravel, Node.js, Python). - The app opens the checkout. The customer pays.
- The app gets
success,pending,cancelledorfailedand tells your server. - Your server verifies the signature and the real status. Only the server marks the order paid.
1. Install
From npm (recommended)
npm install @razcrypto/react-native react-native-webview
cd ios && pod install # iOS onlyExpo: npx expo install react-native-webview, then npm install @razcrypto/react-native. It works in a development
build and in EAS builds.
From the download (local / offline)
curl -L -o razcrypto-react-native-sdk.zip https://razcryptogateway.com/downloads/razcrypto-react-native-sdk.zip
mkdir razcrypto-react-native-sdk && unzip razcrypto-react-native-sdk.zip -d razcrypto-react-native-sdk
cd razcrypto-react-native-sdk
npm install && npm run build && npm pack # creates razcrypto-react-native-1.0.0.tgz
cd ../your-app
npm install ../razcrypto-react-native-sdk/razcrypto-react-native-1.0.0.tgz react-native-webviewA packed .tgz works better with Metro than a symlinked folder.
Android
The internet permission is already in every React Native app. To let Android 11+ open wallet apps directly, add
this to android/app/src/main/AndroidManifest.xml inside <manifest>:
<queries>
<intent><action android:name="android.intent.action.VIEW" /><data android:scheme="metamask" /></intent>
<intent><action android:name="android.intent.action.VIEW" /><data android:scheme="trust" /></intent>
</queries>2. Open the checkout
Hook (promise style)
import { Alert, Button } from 'react-native';
import { useRazCryptoCheckout } from '@razcrypto/react-native';
export function PayWithCrypto({ amount }: { amount: number }) {
const { open, element } = useRazCryptoCheckout();
const pay = async () => {
const order = await api.post('/payments/razcrypto/create', { amount }); // { payment_id, checkout_url }
const r = await open({ checkoutUrl: order.checkout_url, locale: 'en' }); // or 'hi'
switch (r.status) {
case 'success': {
const res = await api.post('/payments/razcrypto/verify', {
payment_id: r.paymentId,
reference_id: r.referenceId,
status: r.paymentStatus,
signature: r.signature,
});
res.status === 'completed' ? showPaid() : waitForPaid(r.paymentId);
break;
}
case 'pending': // on-chain, confirming
waitForPaid(r.paymentId);
break;
case 'cancelled': // closed; order stays pending
break;
case 'failed':
Alert.alert('Payment failed', r.message);
}
};
return (
<>
<Button title="Pay with crypto" onPress={pay} />
{element}
</>
);
}Render {element} once in the screen; it is the checkout modal.
Component
import { RazCryptoCheckout } from '@razcrypto/react-native';
<RazCryptoCheckout
visible={open}
options={{ checkoutUrl }} // or { key: 'pk_live_…', paymentId: 'pay_…' }
onResult={(r) => {
setOpen(false);
handle(r);
}}
/>waitForPaid polls your server (GET /payments/razcrypto/status/{id}) for about 30 seconds, then tells the
customer the order will update shortly.
3. Server side
A complete Laravel backend (migration, admin settings, create / verify / status / webhook) is on the PHP SDK page. Node.js: Node.js SDK.
signature= hex HMAC-SHA256(webhook signing secret,payment_id|reference_id|status). Verify it on the server.- Fulfil only when
payments.retrieve(id)returnspaidor on the verifiedpayment.paidwebhook.
Reference
| Options | Use |
|---|---|
{ checkoutUrl, locale? } | Recommended. The checkout_url from your server. |
{ key, paymentId, payHost?, locale? } | Publishable key + payment id. payHost only for staging / self-hosted. |
Result status | Other fields |
|---|---|
'success' | paymentId, referenceId, paymentStatus, signature |
'pending' | paymentId |
'cancelled' | — |
'failed' | code, message |
What the customer sees: network → coin → QR or "Open in MetaMask / Trust" → green success screen that closes by itself. Android Back asks "Leave this payment?".
Test and go live
- Server on
sk_test_…, open a payment, thensimulate(paymentId, 'paid')on the server. - Check Dashboard → API apps → Webhooks for the delivery.
- Live:
sk_live_…+ live signing secret + live webhook URL, then one small real payment.
Develop the SDK
npm install
npm run typecheck && npm test && npm run build