Quick Start

First hosted checkout payment on Fin staging in under 5 minutes.

This guide walks you through a complete Hosted Checkout payment in Test Mode using your Test API Key — from creating a payment link to confirming the final transaction status and issuing an optional refund.

📘

Prerequisites: Access to the Merchant Dashboard at pay.digetpay.com, your Test API Key (x-api-key), and a tool that can send JSON requests such as Postman, ReadMe Try It, or your backend HTTP client.


Before you begin

RequirementDetail
API keyYour Test API Key, sent in the x-api-key header
API base URLhttps://api.digetpay.com/v1 (the same for Test and Live)
ModeTest Mode (determined by the Test API Key)
IntegrationHosted Checkout
AmountUse a small test amount, such as 0.20 SAR
Customer phoneRequired when creating the checkout session

Security: Keep API keys on your server. Never expose them in browser JavaScript, mobile applications, or public repositories.

For API modes and credentials, see API Modes & Credentials.


Payment flow

The Hosted Checkout flow has four main steps:

sequenceDiagram
    autonumber
    participant Merchant as Your server
    participant API as DigetPay API
    participant Customer as Customer
    participant Checkout as DigetPay Checkout

    Merchant->>API: Create checkout session
    API-->>Merchant: id and redirectUrl
    Merchant->>Customer: Redirect to redirectUrl
    Customer->>Checkout: Complete payment
    Checkout-->>Customer: Redirect to successUrl or failureUrl
    Merchant->>API: Query transaction status
    API-->>Merchant: Final transaction status
    Merchant->>Merchant: Confirm before fulfillment

Redirect is not proof of payment

A redirect to successUrl does not confirm that the payment was successful. Confirm the final transaction status on your server before fulfilling the order.


Step 1 — Create a payment link

Create a Hosted Checkout session using the DigetPay API and your Test API Key.

Endpoint:

POST https://api.digetpay.com/v1/payment/checkout/intiate

Header:

x-api-key: YOUR_TEST_API_KEY

The current endpoint path is intiate. Use the exact path documented in the API Reference for your integration.

Request

{
  "merchantOrderId": "PAY-20260901-001",
  "amount": 0.20,
  "currency": "SAR",
  "customerName": "Ahmed Ali",
  "customerEmail": "[email protected]",
  "customerPhone": "501223324",
  "successUrl": "https://your-domain.com/payment/success",
  "failureUrl": "https://your-domain.com/payment/failure"
}

Successful response

{
  "success": {
    "status": 201,
    "body": {
      "id": "70471003-64ee-4ae7-a639-e607b45e890b",
      "redirectUrl": "<checkout URL returned by the API>"
    }
  }
}

The response contains:

FieldDescription
idCheckout session ID
redirectUrlURL where you send the customer to complete payment

Store the returned session ID for your payment flow and reconciliation.

Always use the redirectUrl exactly as returned by the API. Do not hard-code or build the checkout URL yourself.

Example error response

{
  "statusCode": 400,
  "message": [
    "customerPhone should not be empty"
  ],
  "error": "Bad Request"
}

After receiving redirectUrl, redirect the customer to the DigetPay checkout page.

For all request parameters and error responses, see Create Payment Link.


Step 2 — Complete the payment

  1. Redirect the customer to redirectUrl.
  2. In Test Mode, the customer pays with a Test Card. See the Testing Guide for card values and scenarios.
  3. DigetPay redirects the customer to successUrl or failureUrl.
  4. Your server confirms the final transaction status.

customerPhone must be included when creating the checkout session when required by the selected payment method or checkout flow.

Do not fulfill the order based only on successUrl. A webhook is a notification that something changed, not proof of payment. Always confirm the final payment status with the Status API on your server.

For the complete checkout experience, see Hosted Checkout Overview.


Step 3 — Confirm transaction status

Use the checkout session ID returned in Step 1 to query the transaction status.

Endpoint:

GET https://api.digetpay.com/v1/payment/checkout/status?sessionId={sessionId}

Example request

GET /v1/payment/checkout/status?sessionId=70471003-64ee-4ae7-a639-e607b45e890b

Header:

x-api-key: YOUR_TEST_API_KEY

Successful response

{
  "code": 200,
  "message": "Success",
  "errorCode": null,
  "data": {
    "content": [
      {
        "transactionId": "2232e99b-0257-47d5-bbfd-022c8951767f",
        "amount": "0.20",
        "transactionStatus": "SUCCESS",
        "paymentStatus": "APPROVED",
        "refundStatus": "NONE"
      }
    ],
    "totalElements": 1
  }
}

The Status API response contains the gateway transaction ID and final payment information.

FieldDescription
transactionIdGateway transaction ID
transactionStatusFinal transaction processing status
paymentStatusPayment approval status
refundStatusCurrent refund status

Confirm that the transaction has reached the expected successful status before fulfilling the order.

The checkout session ID and gateway transaction ID are different identifiers. See Transaction Identifiers for the complete identifier reference.

For all supported status values, see Query Transaction Status.


Step 4 — Refund a payment

After a successful payment, use the gateway transactionId returned by the Status API to create a refund.

Endpoint:

POST https://api.digetpay.com/v1/payment/refund

Header:

x-api-key: YOUR_TEST_API_KEY

Request

{
  "transactionId": "2232e99b-0257-47d5-bbfd-022c8951767f",
  "amount": 0.20
}

Successful response

{
  "code": 200,
  "message": "Success",
  "errorCode": null,
  "data": {
    "result": "accepted",
    "referenceId": "2026001124",
    "paymentId": "0808779145497567115585",
    "message": "Refund Created Successfully!",
    "amount": "0.20",
    "refundId": "1046772"
  }
}

A successful refund request returns:

result: accepted

A refund request may be asynchronous. Use the refund status and transaction information to confirm the final refund result.

For partial refunds and complete refund workflows, see Process Refund.


Quick reference

ItemTest ModeLive Mode
API base URLhttps://api.digetpay.com/v1https://api.digetpay.com/v1
API keyTest API KeyLive API Key
Authenticationx-api-keyx-api-key
Checkout URLUse the redirectUrl returned by the APIUse the redirectUrl returned by the API
Create checkoutPOST /payment/checkout/intiatePOST /payment/checkout/intiate
Check statusGET /payment/checkout/status?sessionId={sessionId}GET /payment/checkout/status?sessionId={sessionId}
Create refundPOST /payment/refundPOST /payment/refund
WebhooksTest Webhook ConfigurationLive Webhook Configuration

To go live, replace the Test API Key with your Live API Key and configure your Live webhook. The API base URL and request formats stay the same.


What to do next


Need help?

If you encounter an integration issue, include the following information when contacting support:

  • Mode: Test or Live (never send the API key itself)
  • Merchant ID, if available
  • Request endpoint and HTTP method
  • HTTP status code
  • API error response
  • Checkout session ID or transaction ID
  • Approximate transaction time

Contact the DigetPay integration team at [email protected].


Did this page help you?