Interactive code examples for integrating Aurion payments
Simple payment button with minimal configuration
import React, { useEffect } from 'react';
import { Aurion } from '@aurion/client-sdk';
function App() {
useEffect(() => {
Aurion.initialize({
publicKey: 'pk_your-public-key'
});
}, []);
const handlePayment = () => {
Aurion.instantCheckout({
transactionId: 'txn_abc123',
onSuccess: () => {
alert('Payment successful!');
}
});
};
return (
<button onClick={handlePayment}>
Pay Now
</button>
);
}Use dark theme for better integration with dark mode apps
Aurion.instantCheckout({
transactionId: 'txn_abc123',
theme: 'dark', // 'light' or 'dark'
onSuccess: () => console.log('Payment complete')
});Handle all payment lifecycle events
Aurion.instantCheckout({
transactionId: 'txn_abc123',
isModal: true,
enablePayViaLink: true,
onSuccess: () => {
console.log('Payment completed successfully');
// Redirect or show success message
},
onError: (code, details) => {
// code: screen code, e.g. 'TransactionNotFound'
// details: the AurionError (details.code, details.message)
console.error('Payment error:', code, details?.message);
},
onClose: () => {
console.log('Checkout closed by user');
// Cleanup or reset state
},
onConnected: (wallet) => {
console.log('Wallet connected:', wallet);
// Update UI to show connected wallet
}
});Display checkout inline instead of as a modal
Aurion.instantCheckout({
transactionId: 'txn_abc123',
isModal: false // Embeds in page
});Handle different error scenarios gracefully
Aurion.initialize({
publicKey: 'pk_your-public-key',
// Receives every SDK error as an AurionError, including wallet errors
// the user can retry inside the widget.
onError: (error) => {
switch (error.code) {
case 'INSUFFICIENT_FUNDS':
alert('Insufficient balance. Please add more funds.');
break;
case 'WALLET_REJECTED':
alert('Transaction was rejected.');
break;
case 'NETWORK_ERROR':
case 'TIMEOUT':
alert('Network error. Please try again.');
break;
default:
console.warn(error.code, error.message); // message is user-safe
}
}
});
Aurion.instantCheckout({
transactionId: 'txn_abc123',
// Called when the checkout ends on an error screen.
onError: (code, details) => console.error(code, details?.code)
});