| Time | Status | User Agent | |
|---|---|---|---|
Retrieving recent requests… | |||
Accept Tamara payments through DigetPay's Server-to-Server (S2S) Sale API.
Your backend initiates the payment, and DigetPay returns a redirect URL where the customer completes the Tamara checkout process.
Important: Tamara S2S uses the same Direct Sale endpoint as card payments, but requires a different request hash formula and redirect handling.
1. Prerequisites
Before integrating Tamara, ensure that:
- Tamara is enabled for your DigetPay merchant account.
- You have a valid Test or Live API Key.
- Your backend can securely generate the request hash.
- You have HTTPS success and failure URLs.
- You can receive payment webhooks and verify transaction status.
The customer's full name should include both first and last name to avoid Tamara customer validation errors.
2. API Endpoint
| Property | Value |
|---|---|
| Method | POST |
| Endpoint | /payment/s2s/sale |
| Base URL | https://api.digetpay.com/v1 |
| Authentication | x-api-key |
| Content-Type | application/json |
| Payment Method | tamara |
Both Test and Live use the same API base URL. The API key determines the environment.
3. Tamara Request Hash
Tamara requires a different MD5 request hash from standard S2S card payments.
Tamara Hash Formula
MD5(
UPPERCASE(
REVERSE(customerEmail)
+ API_KEY
+ REVERSE(orderId)
)
)Trim the email and order ID before reversing them. Concatenate the three values without separators, uppercase the resulting string, and calculate its MD5 hexadecimal digest.
Tamara vs. Standard Card S2S
| Standard Card S2S | Tamara S2S |
|---|---|
| Reverse customer email | Reverse customer email |
| Add merchant API key | Add merchant API key |
| Reverse first 6 + last 4 card digits | Reverse merchant orderId |
| Uppercase and MD5 | Uppercase and MD5 |
Important: Do not use the card payment hash formula for Tamara transactions.
Postman Pre-request Script
Configure a Postman environment variable named digetpay_api_key and use it in the x-api-key header.
function s2sTamaraHash(email, apiKey, orderId) {
const rev = (s) => s.split("").reverse().join("");
const combined = (
rev(email.trim()) +
apiKey +
rev(String(orderId).trim())
).toUpperCase();
return CryptoJS.MD5(combined)
.toString(CryptoJS.enc.Hex);
}
const API_KEY = pm.environment.get("digetpay_api_key");
if (!API_KEY) {
throw new Error("Missing digetpay_api_key");
}
const body = JSON.parse(pm.request.body.raw);
const hash = s2sTamaraHash(
body.customer.email,
API_KEY,
body.orderId
);
pm.variables.set("tamara_hash", hash);Use "hash": "{{tamara_hash}}" in the Postman request body.
Security: Generate the hash on your secure backend for production transactions. Never expose API keys in frontend JavaScript or hardcode them in publicly shared Postman collections.
4. Create Tamara Payment
Request Example
curl --location 'https://api.digetpay.com/v1/payment/s2s/sale' \
--header 'x-api-key: YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
"orderId": "TAMARA-ORDER-1001",
"amount": 125.52,
"currency": "SAR",
"paymentMethod": "tamara",
"auth": "N",
"customer": {
"name": "Ahmed Mohamed",
"email": "[email protected]",
"phone": "+966501234567"
},
"successUrl": "https://merchant.example/success",
"failureUrl": "https://merchant.example/failure",
"hash": "GENERATED_TAMARA_MD5_HASH"
}'Generate the hash from the same customer email, merchant API key, and order ID used in this request.
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
orderId | string | Yes | Unique merchant order reference, also used in the hash. |
amount | number | Yes | Payment amount. |
currency | string | Yes | SAR for this Tamara flow. |
paymentMethod | string | Yes | Must be tamara. |
auth | string | Yes | N for the sale operation shown here. |
customer.name | string | Yes | Customer's full name. |
customer.email | string | Yes | Customer email used in the hash. |
customer.phone | string | Yes | Customer mobile number. |
successUrl | string | Yes | Merchant success return URL. |
failureUrl | string | Yes | Merchant failure return URL. |
hash | string | Yes | Tamara-specific MD5 request hash. |
5. API Response
Redirect Response
{
"code": 200,
"message": "Success",
"errorCode": null,
"data": {
"result": "REDIRECT",
"action": "SALE",
"status": "PENDING",
"amount": "125.52",
"currency": "SAR",
"order_id": "TAMARA-ORDER-1001",
"trans_date": "2026-10-21 10:18:02",
"transactionId": "713d8ecf-61a4-4661-b877-de90e3aba778",
"paymentId": "7295722",
"card_brand": "TAMARA",
"merchant_name": null,
"decline_reason": null,
"Card": null,
"result_url": "https://merchant.example/success?paymentId=7295722&Id=7295722",
"html": null,
"redirect_url": "https://pay.digetpay.com/En/KWT/PayInvoice/Checkout?invoiceKey=EXAMPLE_INVOICE_KEY&paymentGatewayId=2417"
}
}Response Fields
| Field | Description |
|---|---|
data.result | REDIRECT indicates customer redirection is required. |
data.action | Transaction action, such as SALE. |
data.status | Current payment status, initially PENDING. |
data.amount | Transaction amount. |
data.currency | Transaction currency. |
data.order_id | Merchant order reference. |
data.transactionId | DigetPay transaction UUID. |
data.paymentId | Payment provider identifier. |
data.card_brand | TAMARA for Tamara payments. |
data.redirect_url | URL where the customer completes payment. |
data.result_url | Merchant return URL supplied in the response. |
data.html | Null for this redirect example. |
data.decline_reason | Decline reason, when available. |
Important:
code: 200means the API request was processed.result: REDIRECTandstatus: PENDINGdo not confirm successful payment.
6. Customer Payment Flow
The Tamara payment process follows these steps:
- The customer selects Tamara as the payment method.
- The merchant backend generates the Tamara request hash.
- The backend submits
POST /payment/s2s/sale. - DigetPay returns
result: REDIRECT,status: PENDING, andredirect_url. - The merchant redirects the customer to
data.redirect_url. - The customer completes the Tamara payment process.
- DigetPay updates the transaction outcome.
- The merchant verifies the final transaction status and updates the order accordingly.
Important: Always redirect the customer to data.redirect_url, not data.result_url.
The returned checkout URL should be used as provided by DigetPay without manually reconstructing it.
7. Payment Verification
A successful API initiation does not confirm that the customer has completed payment.
The merchant should:
- Receive the payment webhook notification when configured.
- Retrieve the latest transaction status through the appropriate authenticated S2S status API.
- Verify the merchant order reference, amount, and currency.
- Update the order as paid only after confirming a successful payment state.
Store the returned transactionId, paymentId, and order_id for tracking and reconciliation.
See Embedded Transaction Status for status lookup details. Confirm the supported identifiers and final status values for Tamara before implementing automatic fulfillment.
8. Troubleshooting
| Issue | Possible Cause / Solution |
|---|---|
| Invalid Request Hash | Check the email reversal, API key, reversed orderId, uppercase conversion, and MD5 calculation. |
| Invalid Customer Data | Provide full customer name, valid email, and valid phone number. |
| Invalid API Key | Verify the Test or Live API Key is active and matches the environment. |
Status remains PENDING | Customer may not have completed the payment. Query the transaction status. |
| Customer not redirected | Verify that data.redirect_url is being used. |
| Order not updated | Check webhook delivery and server-side payment verification. |
| Duplicate Order Reference | Use a unique orderId for each new payment attempt and retain the transaction identifiers. |
9. Important Notes
- Tamara uses the S2S Sale endpoint with
paymentMethod: "tamara". - Tamara requires its own request hash formula.
- The hash uses the customer email, API key, and order ID.
- Do not include a
cardobject in the Tamara request shown here. - Customer payment completion takes place through the returned redirect URL.
PENDINGis not a completed payment.- Payment status must be verified before fulfilling the merchant order.
- Test and Live API Keys use the same DigetPay base URL.
10. Related Documentation
200
