Skip to main content

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:
  1. Create Session: Your backend creates a checkout session
  2. Load SDK: Your frontend loads the Orsunpay Checkout SDK
  3. 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

ParameterTypeRequiredDescription
amountintegerYesAmount in smallest currency unit
currencystringYesThree-letter currency code
countrystringYesCustomer’s country (ISO 3166-1 alpha-2)
customerobjectYesCustomer information
returnUrlstringYesURL to redirect after payment
cancelUrlstringNoURL to redirect if canceled
methodsFilterarrayNoRestrict to specific payment methods
localestringNoLanguage preference (default: en-US)
metadataobjectNoCustom 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)

Client Component (Checkout Form)

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

  1. Server-side session creation: Always create sessions from your secure backend
  2. Webhook verification: Use webhooks as the authoritative source of payment status
  3. Client secret protection: The client secret is safe for frontend use but should be unique per session

User Experience

  1. Loading states: Show loading indicators while the checkout initializes
  2. Error handling: Provide clear error messages and recovery options
  3. Mobile optimization: Ensure the checkout works well on mobile devices
  4. Accessibility: The checkout SDK is built with accessibility in mind

Integration

  1. Webhook backup: Always implement webhook handling as primary status source
  2. Idempotency: Handle duplicate success callbacks gracefully
  3. Testing: Thoroughly test all payment flows in sandbox environment

Troubleshooting

Common Issues

IssueSolution
SDK not loadingCheck script URL and network connectivity
Client secret invalidVerify session creation on backend
Payment methods not showingCheck country/currency configuration
Success callback not firingVerify 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.