Introduction
One API for every Libyan payment method, in two calls:
POST /payments/initiatestarts the payment.POST /payments/{id}/confirmconfirms it with the OTP, when the method requires one.
A third, read-only call, GET /payments/{id}, returns the transaction's status at any time.
Every example runs against the test environment with a dafa_test_… key; nothing there moves money.
Authentication
Send your key (top of this page) in a header on every request:
X-API-Key: <your-key>The key prefix sets its environment: dafa_test_ creates simulated transactions, dafa_live_ real ones. A key never reads or confirms the other environment's transactions.
You need an API key to run requests. Yours is created in a minute with your phone number.
Get an API keyStep 1: Initiate the payment
https://dev.dafa.ly/api/v1/payments/initiateFormat: application/json, application/x-www-form-urlencoded or multipart/form-data, with the same fields in all three.
providerrequiredamountrequireduser_identifierPer methodbirthyearSadad onlycallback_urlOptionalreturn_urlOptional, bank cards onlyhttps:// address or an app link (myapp://…). Without it the page shows no buttonExample: bank cards
The simplest to try: no user_identifier and no confirm step.
POST /api/v1/payments/initiate HTTP/1.1
X-API-Key: <your-key>
provider=moamalat
amount=50Successful response:
{
"id": "b7e1c9a0-1234-4a5b-9c8d-abcdef123456",
"amount": 50.000,
"amount_str": "50.000",
"is_paid": false,
"payment_page_url": "https://localbankcards.dafa.ly/b7e1c9a0-…",
"callback_url": null,
"created_at": "2026-07-18T10:00:00Z",
"payment_method_details": { "id": "7b992f96-…", "name": { "ar": "البطاقات المصرفية", "en": "Local Cards" } },
"gateway": { "id": "895d5537-…", "name": "البطاقات المصرفية" },
"workspace": { "id": "3f0c6a2e-…", "name": "My store", "is_test": true }
}Redirect the customer to payment_page_url to enter their card details on a secure page. Once they pay there, the transaction confirms automatically.
If you sent return_url, the success screen shows a "Continue" button that takes the customer to it, unchanged. Reaching that address does not prove payment: check the transaction's status before you deliver.
Response fields
idstring (UUID)amountnumberamount_strstringis_paidbooleantrue once the money has actually been receivedpayment_page_urlstring or nullcallback_urlstring or nullreturn_urlstringcreated_atstring (date)payment_method_detailsobjectid and name in Arabic and Englishgatewayobjectid and nameworkspaceobjectid, name and is_testMethods that send an OTP
Sadad, Edfali, MobiCash and the other methods text the customer an OTP and need user_identifier (Sadad also needs birthyear):
POST /api/v1/payments/initiate HTTP/1.1
X-API-Key: <your-key>
provider=edfali
amount=25.5
user_identifier=912345678Same response shape with "payment_page_url": null. Keep the id for the next step.
Step 2: Confirm the payment
Only for methods that send an OTP. Ask the customer for the code and send it:
https://dev.dafa.ly/api/v1/payments/{id}/confirmotprequiredPOST /api/v1/payments/b7e1c9a0-1234-4a5b-9c8d-abcdef123456/confirm HTTP/1.1
X-API-Key: <your-key>
otp=111111Successful response, same fields; is_paid: true means the money reached your wallet:
{
"id": "b7e1c9a0-1234-4a5b-9c8d-abcdef123456",
"amount": 25.500,
"amount_str": "25.500",
"is_paid": true,
"payment_page_url": null,
"callback_url": null,
"created_at": "2026-07-18T10:00:00Z",
"payment_method_details": { "id": "a1d2f3e4-…", "name": { "ar": "إدفعلي", "en": "Edfali" } },
"gateway": { "id": "c4b5a6d7-…", "name": "إدفعلي" },
"workspace": { "id": "3f0c6a2e-…", "name": "My store", "is_test": true }
}Checking payment status
This call is the source of truth for any transaction: whether it was paid, and for how much.
https://dev.dafa.ly/api/v1/payments/{id}{id} is the transaction id from the initiate response. The call takes no fields:
GET /api/v1/payments/b7e1c9a0-1234-4a5b-9c8d-abcdef123456 HTTP/1.1
X-API-Key: <your-key>The response has the same fields as the initiate response:
{
"id": "b7e1c9a0-1234-4a5b-9c8d-abcdef123456",
"amount": 50.000,
"amount_str": "50.000",
"is_paid": true,
"payment_page_url": "https://localbankcards.dafa.ly/b7e1c9a0-…",
"callback_url": "https://example.com/dafa/webhook",
"created_at": "2026-07-18T10:00:00Z",
"payment_method_details": { "id": "7b992f96-…", "name": { "ar": "البطاقات المصرفية", "en": "Local Cards" } },
"gateway": { "id": "895d5537-…", "name": "البطاقات المصرفية" },
"workspace": { "id": "3f0c6a2e-…", "name": "My store", "is_test": true }
}Before you fulfil an order, check that is_paid is true and that amount is your order's. is_paid: false means the money has not been received yet.
Use a key from the environment the transaction was initiated in; a transaction from the other environment answers 404.
Test environment
Every method is available with no setup, and you control the outcome:
111111222222- Any correctly formatted phone number is accepted.
- Bank cards (
moamalat) open a test checkout page: card6394984349023404, expiry11/28, OTP111111. Closing the page leaves the transaction unconfirmed. - Every response carries
"workspace": { "is_test": true }. - A declined payment answers
400withdata.code(for examplePAYER_INSUFFICIENT_FUNDS), exactly like live.
Try it in two minutes
POST /payments/initiatewithprovider=sadad,amount=10,user_identifier=912345678,birthyear=1995.POST /payments/{id}/confirmwithotp=111111→is_paid: true.- Repeat step 1, then confirm with
otp=222222→400withdata.code. - Pass a
callback_url, watch for the webhook, then callGET /payments/{id}→is_paid: true.
Automatic notifications (Webhook)
If you pass callback_url when initiating, we POST to your URL as soon as the transaction completes, as JSON:
{ "transaction_id": "b7e1c9a0-1234-4a5b-9c8d-abcdef123456", "is_confirmed": true }Answer 200 within 15 seconds. Without a 200 we send it again after about 30 seconds, then after about two minutes, then stop.
The webhook is a notice that the transaction has an update, not its status. When it arrives, take transaction_id and fetch the transaction to learn its status:
https://dev.dafa.ly/api/v1/payments/{id}Fulfil the order only after this call returns is_paid: true for your order's amount (see Checking payment status). The webhook is not signed, so its body alone proves nothing.
A webhook can arrive more than once for the same transaction, so make fulfilment idempotent.
Every webhook carries the header X-Dafa-Environment: test or live; a test webhook never reports a real payment.
Providers table
sadadSadadbirthyearedfaliEdfalimobicashMobiCashmoamalatBank cardsyussor-payYussor Paymasrafi-payMasrafi Paysahara-paySahara Pay