First Checkout¶
In this guide
Run your first end-to-end payment with hosted checkout, learn which IDs to store, and add status verification.
Hosted checkout is the recommended first integration. The SDK creates a checkout session, opens DigetPay's payment page, watches the redirect, verifies status, and reports the result through PaymentCallback.
Start in SANDBOX
Make sure the SDK is initialized with Environment.SANDBOX and use test
cards for this first run.
import com.digetpay.sdk.DigetPay
import com.digetpay.sdk.callback.PaymentCallback
import com.digetpay.sdk.model.CheckoutRequest
import com.digetpay.sdk.model.PaymentError
import com.digetpay.sdk.model.PaymentResult
DigetPay.checkout(
activity = this,
request = CheckoutRequest(
merchantOrderId = "ORDER-123",
amount = 125.0,
currency = "SAR",
customerName = "Ahmed Ali",
customerEmail = "ahmed@example.com",
customerPhone = "+966501234567"
),
callback = object : PaymentCallback {
override fun onSuccess(result: PaymentResult) {
// Store result.sessionId, result.transactionId, and result.orderId.
}
override fun onFailure(error: PaymentError) {
// Show error.message and log error.code for diagnostics.
}
override fun onCancelled() {
// The user closed the checkout screen before completion.
}
}
)
import com.digetpay.sdk.DigetPay;
import com.digetpay.sdk.callback.PaymentCallback;
import com.digetpay.sdk.model.CheckoutRequest;
import com.digetpay.sdk.model.PaymentError;
import com.digetpay.sdk.model.PaymentResult;
CheckoutRequest request = new CheckoutRequest(
"ORDER-123",
125.0,
"SAR",
"Ahmed Ali",
"ahmed@example.com",
"+966501234567",
CheckoutRequest.DEFAULT_SUCCESS_URL,
CheckoutRequest.DEFAULT_FAILURE_URL
);
DigetPay.checkout(this, request, new PaymentCallback() {
@Override
public void onSuccess(PaymentResult result) {
// Store result.getSessionId(), result.getTransactionId(), and result.getOrderId().
}
@Override
public void onFailure(PaymentError error) {
// Show error.getMessage() and log error.getCode() for diagnostics.
}
@Override
public void onCancelled() {
// The user closed the checkout screen before completion.
}
});
What to Store¶
After success, persist these values on your backend:
sessionId- Used as
paymentIdfor status, capture, void, refund, and recurring operations. transactionId- Gateway transaction id for reconciliation and records.
orderId- Used to match DigetPay payments to your order system.
status- Useful for user-facing order state.
Confirm on your backend
The visual success page is not proof of a completed payment. Always confirm
the final state with getTransactionStatus() or a server-side webhook
before fulfilling the order.
Next Steps¶
After your first checkout works, add status verification and production error handling:
Next step
Explore the other Payment Flows or the full list of Operations — status, capture, void, refund, and recurring.