Quickstart Guide

Welcome to the WHITELABEL SDKs quickstart guide. This guide shows you how to easily implement WHITELABEL’s full payment flow, its most straightforward solution with pre-built UI and automatic payment method display.

Choose your platform and follow the steps to start processing your first payments with WHITELABEL.

1. Install

npm install @yuno-payments/sdk-web

To start the SDK download while the page loads, add a preload and preconnects to your HTML <head>. See Preload the SDK script.

Or include via CDN:

<script src="https://sdk-web.whitelabel.com/v1.10/main.js"></script>

2. Initialize and process payment

import { Whitelabel } from '@yuno-payments/sdk-web';

// Initialize SDK
const whitelabel = await Yuno.initialize('your-public-api-key');

// Create checkout session on your backend
// Your backend calls: POST https://api-sandbox.whitelabel.com/v1/checkout/sessions
// Backend adds: account_id, merchant_order_id, payment_description (server-side)
const session = await fetch('/api/create-session', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
    customer_id: 'customer-123',
    amount: { currency: 'USD', value: 1000 },
    country: 'US'
})
}).then(r => r.json());

// Configure checkout
await whitelabel.startCheckout({
checkoutSession: session.checkout_session,
elementSelector: '#payment-form',
countryCode: 'US',
async yunoCreatePayment(oneTimeToken) {
    // Your backend calls: POST https://api-sandbox.whitelabel.com/v1/payments
    // with header: X-Idempotency-Key
    // and body: { account_id, description, country, merchant_order_id, amount,
    //             checkout: { session }, payment_method: { token: oneTimeToken }, ... }
    const payment = await fetch('/api/process-payment', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({
        one_time_token: oneTimeToken,
        checkout_session: session.checkout_session
    })
    }).then(r => r.json());
    
    // Required for async payment methods (3DS, PIX, etc.)
    await whitelabel.continuePayment();
}
});

// Mount payment form
await whitelabel.mountCheckout();

3. Add HTML container and trigger payment

<div id="payment-form"></div>
<button id="pay-button">Pay Now</button>

<script>
document.getElementById('pay-button').addEventListener('click', async () => {
    await whitelabel.startPayment();
});
</script>

See Test cards below.

For a comprehensive overview of all Web SDK parameters, see Web SDK Common Reference.

Complete Web guide →

1. Install

CocoaPods:

pod 'YunoSDK', '~> 2.11.1'

Swift Package Manager:

dependencies: [
    .package(url: "https://github.com/yuno-payments/yuno-sdk-ios", from: "2.11.1")
]

2. Initialize and implement delegate

import YunoSDK

// Initialize in AppDelegate or App struct
Yuno.initialize(
    apiKey: "your-public-api-key",
    config: YunoConfig()
)

// In your view controller - implement YunoPaymentDelegate
class PaymentViewController: UIViewController, YunoPaymentDelegate {
    
    // Required delegate properties
    var checkoutSession: String { "session-from-backend" }
    var countryCode: String { "US" }
    var language: String? { "en" }
    var viewController: UIViewController? { self }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        displayPaymentMethods()
    }
    
    func displayPaymentMethods() async {
        // Get payment methods view
        let paymentView = await Yuno.getPaymentMethodViewAsync(delegate: self)
        view.addSubview(paymentView)
        // Add constraints...
    }
    
    // Required: Create payment with one-time token
    func yunoCreatePayment(with token: String) {
        // Call your backend: POST /v1/payments
        createPaymentOnBackend(token: token) { result in
            // After payment creation, continue for async methods
            Yuno.continuePayment()
        }
    }
    
    // Required: Handle payment result
    func yunoPaymentResult(_ result: Yuno.Result) {
        switch result {
        case .succeeded:
            print("Payment succeeded!")
        case .fail:
            print("Payment failed")
        case .processing:
            print("Payment processing")
        default:
            break
        }
    }
}

// Start payment when user taps pay button
@IBAction func payButtonTapped(_ sender: UIButton) {
    Yuno.startPayment(showPaymentStatus: true)
}

See Test cards below.

For a comprehensive overview of all iOS SDK parameters, see iOS SDK Common Reference.

Complete iOS guide →

1. Install

build.gradle:

repositories {
    maven { url "https://yunopayments.jfrog.io/artifactory/snapshots-libs-release" }
}

dependencies {
    implementation 'com.yuno.payments:android-sdk:2.9.0'
}

2. Initialize and process payment

Initialize in Application:

class MyApplication : Application() {
    override fun onCreate() {
        super.onCreate()
        Yuno.initialize(
            this,
            publicApiKey = "your-public-api-key",
            config = YunoConfig(
                keepLoader = true,
            )
        )
    }
}

For a detailed explanation of the keepLoader parameter and mandatory error handling, see the Android Reference Guide.

In Activity/Fragment:

import com.yuno.payments.Yuno

class PaymentActivity : ComponentActivity() {
    private var checkoutSession: String? = null
    
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        
        // Create checkout session on your backend first
        // Your backend calls: POST https://api-sandbox.whitelabel.com/v1/checkout/sessions
        lifecycleScope.launch {
            val session = createCheckoutSession() // Your backend call
            checkoutSession = session.id
            
            // Start checkout with session
            startCheckout(
                checkoutSession = session.id,
                countryCode = "US",
                callbackPaymentState = { state, subState, message ->
                    when (state) {
                        "SUCCEEDED" -> println("Payment succeeded!")
                        "FAIL" -> println("Payment failed: ${message?.code}")
                        "PROCESSING" -> println("Payment processing")
                        "REJECT" -> println("Payment rejected: ${message?.reason}")
                        else -> println("Payment state: $state")
                    }
                }
            )
        }
        
        setContent {
            var paymentMethodSelected by remember { mutableStateOf(false) }
            
            Column(
                modifier = Modifier
                    .fillMaxSize()
                    .verticalScroll(rememberScrollState())
            ) {
                // Display payment methods
                PaymentMethodListViewComponent(
                    activity = this@PaymentActivity,
                    onPaymentSelected = { isSelected ->
                        paymentMethodSelected = isSelected
                    }
                )
                
                // Pay button
                Button(
                    onClick = {
                        startPayment(
                            showStatusYuno = true,
                            callbackOTT = { token ->
                                token?.let { ott ->
                                    // Call your backend: POST /v1/payments
                                    // with { payment_method: { token: ott }, checkout_session: ... }
                                    createPayment(ott, checkoutSession!!)
                                    
                                    // Required for async payment methods
                                    continuePayment()
                                }
                            }
                        )
                    },
                    enabled = paymentMethodSelected
                ) {
                    Text("Pay Now")
                }
            }
        }
    }
}

See Test cards below.

For a comprehensive overview of all Android SDK parameters, see Android SDK Common Reference.

Complete Android guide →

Handling a failed payment

The Web SDK can recover from a failed payment without reloading the page. Two mechanisms work together:

  • Payment retry — inline card retry when the payment returns DECLINED or ERROR. In Seamless the SDK handles retry automatically. In Full Checkout, Lite, and Secure Fields you call continuePayment after your backend confirms the decline. Works for non-enrolled credit and debit cards. See Payment retry for the full reference.

  • Switching payment methods — call updateCheckoutSession(newSession) to inject a fresh checkout session without unmounting the SDK. Picking from the already-rendered payment-method list after a session swap works; a different set of payment methods requires unmounting and re-mounting the SDK — not a page reload. See updateCheckoutSession.

// Inside your yunoCreatePayment callback:
const payment = await createPaymentOnYourBackend(oneTimeToken);

const isCard = payment.payment_method?.type === 'CARD';
const failed = payment.status === 'DECLINED' || payment.status === 'ERROR';

if (isCard && failed) {
  // Card retry: keeps the card form open with the decline shown.
  await whitelabel.continuePayment();
} else if (payment.checkout?.sdk_action_required) {
  // Additional action: 3DS, bank redirect, etc.
  await whitelabel.continuePayment({ showPaymentStatus: true });
} else {
  // No further SDK action — unmount.
  await whitelabel.unmountSdk();
}

On a retried attempt the SDK does not fire yunoPaymentResult. It delivers the cloned checkout session to your onLoading callback as { type: 'PAYMENT_RETRY', data: { newCheckoutSession } }. Register onLoading in your startCheckout configuration to receive it:

await whitelabel.startCheckout({
  checkoutSession: session.checkout_session,
  // ...
  onLoading: ({ type, data }) => {
    if (type === 'PAYMENT_RETRY') {
      // A fresh session has been cloned for the retry.
      const newCheckoutSession = data.newCheckoutSession;
    }
  }
});

Backend integration

Your backend must implement two API endpoints to work with WHITELABEL:

1. Create checkout session

Before displaying the payment UI, your backend creates a checkout session:

  • Endpoint: POST https://api-sandbox.whitelabel.com/v1/checkout/sessions
  • Required (OpenAPI): account_id, merchant_order_id, payment_description, country
  • Also send: customer_id (from Create Customer) and amount { currency, value }
  • Optional for SDK: workflow (SDK_CHECKOUT | SDK_SEAMLESS | CHECKOUT), callback_url, checkout_id
  • Returns: checkout_session ID (used in SDK)
  • Reference: Create checkout session API

Example request:

{
  "account_id": "YOUR_ACCOUNT_ID",
  "merchant_order_id": "order-001",
  "payment_description": "Sandbox quickstart payment",
  "country": "US",
  "customer_id": "YOUR_CUSTOMER_UUID",
  "amount": {
    "currency": "USD",
    "value": 100
  },
  "workflow": "SDK_CHECKOUT"
}

2. Create payment

In the One-Time Token (OTT) callback, your backend creates the payment:

  • Endpoint: POST https://api-sandbox.whitelabel.com/v1/payments
  • Required header: X-Idempotency-Key (unique UUID per attempt) — see Authentication
  • Required body (OpenAPI): account_id, description, country, merchant_order_id, amount, payment_method, checkout
  • payment_method.token = one-time token from the SDK callback
  • checkout.session = checkout session id from step 1
  • Returns: Payment status and sdk_action_required field
  • Reference: Create payment API

Example headers:

public-api-key: YOUR_PUBLIC_API_KEY
private-secret-key: YOUR_PRIVATE_SECRET_KEY
X-Idempotency-Key: YOUR_UUID
content-type: application/json
accept: application/json

Example request:

{
  "account_id": "YOUR_ACCOUNT_ID",
  "description": "Sandbox quickstart payment",
  "country": "US",
  "merchant_order_id": "order-001",
  "amount": {
    "currency": "USD",
    "value": 100
  },
  "customer_payer": {
    "id": "YOUR_CUSTOMER_UUID"
  },
  "checkout": {
    "session": "YOUR_CHECKOUT_SESSION_UUID"
  },
  "payment_method": {
    "token": "ONE_TIME_TOKEN_FROM_SDK"
  }
}

Important: If the API response has sdk_action_required: true or checkout.sdk_action_required: true, you must call the SDK’s continuePayment() method to complete async payment methods (3DS authentication, PIX, bank redirects, etc.).

Parameters

Primary parameters used in this quickstart:

ParameterDescription
publicKey / apiKeyYour WHITELABEL public API key (frontend). From WHITELABEL Dashboard → Developers > Credentials.
checkoutSessionCheckout session ID returned by your backend (create session endpoint). Required to start payment.
countryCodeISO country code for the payment (for example, US, CO). See Country coverage.
elementSelector (Web)CSS selector for the element where the payment form is mounted (e.g. #payment-form).

Full parameter reference: Payment flows (Web), Payment flows (iOS), Payment flows (Android).

Alternative integration methods

If you need more control over the user interface or specific payment flows, WHITELABEL provides alternative integration methods:

Lite SDK

A lightweight integration that gives you full control over the payment method display while WHITELABEL handles the secure payment processing.

Secure Fields

Build your own payment forms from scratch using WHITELABEL’s UI components for maximum customization (Web Only).

Test cards

Card NumberScenario
4111 1111 1111 1111Success
4000 0000 0000 0002Declined
4000 0000 0000 32203DS Challenge