Payment Result
Last updated
Was this helpful?
Was this helpful?
const result = client.components.paymentResult({
containerId: 'result',
status: 'success',
payment: {
id: 'pay_xxx',
amount: 150.00,
currency: 'USD',
// ...
},
onDone: () => {
window.location.href = '/dashboard';
},
});const result = client.components.paymentResult({
containerId: 'result',
status: 'error',
error: new Error('Card declined'),
onRetry: () => {
// Go back to payment method selection
showPaymentMethods();
},
onDone: () => {
window.location.href = '/dashboard';
},
});const result = client.components.paymentResult({
containerId: 'result',
status: 'processing',
onDone: () => {
window.location.href = '/dashboard';
},
});<div id="result"></div>
<script type="module">
import { AlternativeClient } from '@getalternative/partner-sdk';
const client = new AlternativeClient({
clientId: 'your-client-id',
clientSecret: 'your-client-secret',
});
// Get payment result from previous step
const paymentResult = getPaymentResult();
const result = client.components.paymentResult({
containerId: 'result',
status: paymentResult.success ? 'success' : 'error',
payment: paymentResult.payment,
error: paymentResult.error,
onDone: () => {
// Return to main application
window.location.href = '/';
},
onRetry: () => {
// Try again
window.location.href = '/pay';
},
});
</script>