Architecture for Mobile
Never call the Paychainly API directly from the mobile app — your API key would be exposed in the app bundle. Instead, create a lightweight backend endpoint that your app calls, and that backend calls Paychainly.
Mobile App → Your Backend API → Paychainly APIYour Backend Endpoint
// POST /payments/create-session
app.post('/payments/create-session', authenticateUser, async (req, res) => {
const { orderId, amount } = req.body;
const session = await paychainly.createSession({
userId: String(orderId), amount,
});
res.json({ address: session.address, expiresAt: session.expiresAt });
});React Native Payment Screen
import { Linking } from 'react-native';
import QRCode from 'react-native-qrcode-svg';
function PaymentScreen({ address, amount, expiresAt }) {
const openWallet = () => {
// Trust Wallet deep link
Linking.openURL(`trust://send?asset=c20000714_t0x55d398326f99059ff775485246999027b3197955&address=${address}&amount=${amount}`);
};
return (
<View>
<QRCode value={address} size={200} />
<Text selectable>{address}</Text>
<Button title="Open in Trust Wallet" onPress={openWallet} />
<CountdownTimer expiresAt={expiresAt} />
</View>
);
}Polling for Confirmation
Use React Native's AppState API to pause polling when the app is backgrounded (the user is in their wallet app sending funds):
AppState.addEventListener('change', nextState => {
if (nextState === 'active') startPolling();
else stopPolling();
});