Developers Payment Gateway APIs v1.0
العربية Request API Access

Introduction #

Al-Saqi Payment Gateway

Integrate Pay by Link: authenticate from your server, create a hosted payment link, and verify the payment status before fulfilling the customer’s order.

The Al-Saqi Payment Gateway RESTful API uses JSON requests and responses. This guide covers Pay by Link: your application directs the customer to the Al-Saqi hosted page to enter card details, while your server creates the link and verifies the result. Keep credentials and access tokens on your server, and do not use the browser redirect alone as proof of payment.

Sandbox Base URL Use https://pg-t2.alsaqi.net for development and testing, and send all requests over HTTPS. Review API Environments before moving to production.

How Integration Works #

A Pay by Link integration follows four steps.

Step Action Endpoint
1 Authenticate and receive a JWT access token + clientId. /api/Auth/CreateAccessToken
2 Create a payment link for an amount and invoice. /api/Payment/generate-payment-link/{client_id}
3 Redirect the customer to paymentLink to pay on the hosted page. Hosted Page
4 Verify the final result server-side before fulfilling the order. /api/Payment/CheckPaymentStatus

The flow at a glance #

Flow
Create Token  ──▶  Generate Payment Link  ──▶  Cardholder pays (hosted page)  ──▶  Check Payment Status
   (auth)              (returns paymentLink)            (success / fail URL)              (final result)
Always confirm server-side Never rely on the browser redirect alone. Treat an order as paid only after Check Payment Status returns linkStatus = 2 (Approved).

API Environments #

Development and testing run on the sandbox. When moving to production, only the base URL and credentials change; endpoint paths and request formats are the same in both environments.

Environment Base URL Use for
Sandbox https://pg-t2.alsaqi.net Development & testing with test cards.
Production Provided after onboarding Live transactions with real cards.

Test card

Card number 4032080000002567
Expiry 12/25
CVV 200
Currency IQD
Test credentials and the test card work only in the sandbox. To get API credentials, contact Al-Saqi support: support@alsaqi.net or +964 781 054 7229.

Authentication & Security #

Token-protected endpoints require a Bearer access token obtained from the Create Access Token endpoint. Send it in the Authorization header on every protected request:

HTTP Header
Authorization: Bearer ACCESS_TOKEN_STRING

Security best practices #

  • Send all requests over HTTPS.
  • Keep the username, password and access token on the merchant's server only.
  • The access token is valid for 24 hours by default; request a new one before it expires.
  • Use a new RequestId for every payment.

API Overview #

The Pay By Link model generates a secure hosted payment link. The cardholder enters their card data on the Al-Saqi hosted page, keeping you out of PCI scope.

Resource Method Path
Create token POST /api/Auth/CreateAccessToken
Generate link POST /api/Payment/generate-payment-link/{client_id}
Check status POST /api/Payment/CheckPaymentStatus
Check by RequestId POST /api/Payment/CheckPaymentStatusByRequestId

Create Access Token #

POST https://pg-t2.alsaqi.net/api/Auth/CreateAccessToken

Creates a JWT access token for the client and returns its clientId. The token must be sent as a Bearer header on protected endpoints.

Request Body

Field Required Type Description
UserName Required string Client username.
Password Required string Client password.
ExpireDuration Optional number Token validity in minutes. Default is 1440 (24h).
Request
curl -X POST https://pg-t2.alsaqi.net/api/Auth/CreateAccessToken \
  -H "Content-Type: application/json" \
  -d '{
    "UserName": "client_username",
    "Password": "client_password",
    "ExpireDuration": 1440
  }'
const res = await fetch("https://pg-t2.alsaqi.net/api/Auth/CreateAccessToken", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    UserName: "client_username",
    Password: "client_password",
    ExpireDuration: 1440
  })
});
const data = await res.json();
// store data.access_token and data.clientId
console.log(data.access_token, data.clientId);
import requests

res = requests.post(
    "https://pg-t2.alsaqi.net/api/Auth/CreateAccessToken",
    json={
        "UserName": "client_username",
        "Password": "client_password",
        "ExpireDuration": 1440,
    },
)
data = res.json()
print(data["access_token"], data["clientId"])
200 — Success
JSON
{
  "access_token": "ACCESS_TOKEN_STRING",
  "clientId": 29
}
Errors
Case Response
Client inactive { "status": false, "message": "Client is not active. Please contact support." }
Invalid credentials { "status": false, "message": "Please provide valid credentials" }

Check Payment Status #

POST https://pg-t2.alsaqi.net/api/Payment/CheckPaymentStatus
POST https://pg-t2.alsaqi.net/api/Payment/CheckPaymentStatusByRequestId

Returns the current status of a payment. Requires a Bearer token. You may query by paymentId, RequestId, or InvoiceId.

The second endpoint, CheckPaymentStatusByRequestId, is meant for lookups by RequestId and returns the same response.

Request — any one identifier
{ "PaymentId": "4e8185b2-8134-4bc7-aca4-59ee87a45910" }
{ "RequestId": "REQ-987654321" }
{ "InvoiceId": "INV-00021" }

Response Fields

Field Type Description
status boolean Transaction succeeded (true) or failed (false).
linkStatus integer Current status code — see the Link Status Reference.
message string Human-readable status description.
paymentId string Unique payment link identifier generated by the gateway.
requestId string Unique request ID sent by the client.
invoiceId string Invoice identifier. Reusable across attempts unless the transaction is Approved/Unknown.
rrn string Retrieval Reference Number from the processor.
cardMasked string Masked card number used in the transaction.
cardHolderName string Cardholder name returned from the transaction.
expiry datetime Expiration date/time of the payment link.
paidDate datetime When the payment completed. Null if not paid.
createDate datetime When the payment link was created.
totalAmount decimal Total payment amount.
respCode string Processor response code (00 = approved; Z1/Z4 = timeout).
errorMessage string Decline / error message from the processor, if any.
isReversal boolean Present once a payment attempt exists: true if the transaction was reversed automatically, in which case the status becomes Unknown (8).

Example Responses #

linkStatus 2 · Approved
JSON
{
  "status": true,
  "linkStatus": 2,
  "message": "Approved",
  "paymentId": "170acac1-3eb9-498c-8623-845139eb204a",
  "requestId": "ZO-1780503160412-1020",
  "rrn": "000030614276",
  "cardMasked": "403208******2567",
  "cardHolderName": "GDGBDHFHFN",
  "expiry": "2026-06-17T16:32:40.49",
  "paidDate": "2026-06-03T19:12:52.863",
  "createDate": "2026-06-03T19:12:40.49",
  "totalAmount": 1,
  "respCode": null,
  "errorMessage": null
}
linkStatus 4 · Declined
JSON
{
  "status": false,
  "linkStatus": 4,
  "message": "Declined",
  "paymentId": "fee05441-0c8c-414a-a756-b532629cb9d3",
  "requestId": "ZO-1779611550221-821",
  "invoiceId": "test-0000350",
  "rrn": "000030617015",
  "cardMasked": "403208******2567",
  "cardHolderName": "AHMED ALI",
  "expiry": "2026-06-07T08:52:30.257",
  "paidDate": "2026-05-24T11:35:11.933",
  "createDate": "2026-05-24T11:32:30.257",
  "totalAmount": 1,
  "respCode": "AB",
  "errorMessage": "رمز CVV2 غير صالح",
  "isReversal": false
}

Refunds & Reversals #

Manual refunds #

Refunds are not available through the API. To refund a completed payment, the merchant contacts Al-Saqi support and sends the paymentId and rrn.

Scenario Behaviour
Completed payment Via Al-Saqi support

Error Codes & Statuses #

The linkStatus field on every status response maps to one of the following values.

Value Status Description
0 Invalid No payment found for the identifier, or the link is invalid.
1 Pending Payment still in progress; the customer has not completed it.
2 Approved Payment completed and approved successfully.
3 Expired The link expired before the customer paid.
4 Declined The payment was rejected.
5 Error A gateway or processing error occurred.
6 NotPaid The payment was not completed.
7 Timeout The connection timed out before the final result.
8 Unknown Status is unknown or still under verification.

Common processor response codes #

respCode Meaning
00 Approved.
31 Issuer unavailable — الجهة المصدرة غير متاحة.
AB Invalid CVV2 — رمز CVV2 غير صالح.
68 Operation timed out — انتهت مهلة العملية.
Z1 / Z4 Host / connection timeout.
Treat Timeout (7) and Unknown (8) as non-final. Re-query the status before deciding to retry, to avoid double-charging the customer.

Postman Collection #

Download the collection with the button at the end of this section and import it into Postman. Enter userName and password in the Variables tab; copy the other values from the responses as shown in the table below.

Collection variables

Variable Value
baseUrl https://pg-t2.alsaqi.net
userName Enter manually: your username
password Enter manually: your password
accessToken Copy access_token from the Generate Access Token response
clientId Copy clientId from the Generate Access Token response
paymentId Copy paymentId from the Generate Link response
requestId Copy requestId from the Generate Link response (for Check Payment Status By RequestId)
Authentication is already set up in the collection; just put the access token in the accessToken variable. A new RequestId is created automatically with every Generate Link request.

Download Postman collection

Changelog & Updates #

Version Date Changes
v1.0 2025 Initial release: Pay By Link hosted checkout, JWT authentication, and payment status verification.
© 2026 Al-Saqi for Electronic Payments dev@alsaqi.net · +964 781 054 7229