Unified Checkout Integration
Orsunpay’s Unified Checkout provides a seamless payment experience that automatically displays the best payment methods for each customer based on their location, currency, and preferences.
Overview
The Unified Checkout process involves three main steps:
- Create Session: Your backend creates a checkout session
- Load SDK: Your frontend loads the Orsunpay Checkout SDK
- Handle Events: Process payment success/failure events
Step 1: Create Checkout Session
First, create a checkout session from your backend:
Session Response
Never expose your secret API key in frontend code. The clientSecret from the session response is safe to use in client-side code.
Session Parameters
| Parameter | Type | Required | Description |
|---|
amount | integer | Yes | Amount in smallest currency unit |
currency | string | Yes | Three-letter currency code |
country | string | Yes | Customer’s country (ISO 3166-1 alpha-2) |
customer | object | Yes | Customer information |
returnUrl | string | Yes | URL to redirect after payment |
cancelUrl | string | No | URL to redirect if canceled |
methodsFilter | array | No | Restrict to specific payment methods |
locale | string | No | Language preference (default: en-US) |
metadata | object | No | Custom key-value data |
Step 2: Load Checkout SDK
Add the Orsunpay Checkout SDK to your page:
For sandbox testing:
Step 3: Initialize Checkout
Basic Integration
Advanced Configuration
Next.js Integration (App Router)
Server Component (Create Session)
Page Component
Event Handling
Success Event
The onSuccess callback receives a result object:
Error Event
The onFail callback receives an error object:
Cancel Event
The onCancel callback is triggered when users explicitly cancel the payment flow.
Styling and Theming
Theme Options
CSS Customization
Best Practices
Security
- Server-side session creation: Always create sessions from your secure backend
- Webhook verification: Use webhooks as the authoritative source of payment status
- Client secret protection: The client secret is safe for frontend use but should be unique per session
User Experience
- Loading states: Show loading indicators while the checkout initializes
- Error handling: Provide clear error messages and recovery options
- Mobile optimization: Ensure the checkout works well on mobile devices
- Accessibility: The checkout SDK is built with accessibility in mind
Integration
- Webhook backup: Always implement webhook handling as primary status source
- Idempotency: Handle duplicate success callbacks gracefully
- Testing: Thoroughly test all payment flows in sandbox environment
Troubleshooting
Common Issues
| Issue | Solution |
|---|
| SDK not loading | Check script URL and network connectivity |
| Client secret invalid | Verify session creation on backend |
| Payment methods not showing | Check country/currency configuration |
| Success callback not firing | Verify webhook endpoint configuration |
Debug Mode
Enable debug mode for additional logging:
Always test your integration thoroughly in sandbox mode before going live. Use webhook notifications as the primary source of truth for payment status updates.