Skip to content

Hosted Checkout Flow

In this guide

How hosted checkout works end-to-end, when to choose it, and how to build and handle the request.

Recommended for most apps

Hosted checkout keeps card data off your app entirely, which minimizes your PCI DSS scope. Start here unless you have a specific reason not to.

Hosted checkout is the safest default flow for most Android apps because the payment page is hosted by DigetPay.

sequenceDiagram
    participant App as Merchant App
    participant SDK as DigetPay SDK
    participant API as DigetPay API
    participant Page as Hosted Checkout

    App->>SDK: DigetPay.checkout(activity, request, callback)
    SDK->>API: Create checkout session
    API-->>SDK: redirectUrl + session id
    SDK->>Page: Open checkout screen
    Page-->>SDK: Redirect to success/failure URL
    SDK->>API: Verify payment status
    SDK-->>App: PaymentCallback result

When to Use It

Use hosted checkout when:

  • You want the fastest production integration.
  • You do not want to collect card data inside the app.
  • You want the SDK to handle the checkout screen and result routing.

Request

val request = CheckoutRequest(
    merchantOrderId = "ORDER-${System.currentTimeMillis()}",
    amount = 125.0,
    currency = "SAR",
    customerName = "Ahmed Ali",
    customerEmail = "ahmed@example.com",
    customerPhone = "+966501234567"
)
CheckoutRequest request = new CheckoutRequest(
    "ORDER-" + System.currentTimeMillis(),
    125.0,
    "SAR",
    "Ahmed Ali",
    "ahmed@example.com",
    "+966501234567",
    CheckoutRequest.DEFAULT_SUCCESS_URL,
    CheckoutRequest.DEFAULT_FAILURE_URL
);

Result Handling

PaymentCallback invokes exactly one method:

  • onSuccess when the payment completes successfully.
  • onFailure when payment fails, is declined, or the SDK cannot complete the request.
  • onCancelled when the user closes the checkout screen before finishing.

Tip

Do not rely only on the visual success page for critical order state. Store the IDs and verify status from your backend or through getTransactionStatus().