Skip to main content

Accept a Payment

Your server creates a payment, and your customer pays on BillPay's hosted checkout page. You never handle wallet, bank, or card details.

  1. Create the payment from your server.
  2. Redirect the customer to the checkoutUrl in the response.
  3. Handle the return when the customer comes back to your site.
  4. Confirm the result with a webhook, not the redirect.

1. Create the payment​

POST/api/v1/checkout/payments

Headers​

x-api-keystringRequired
Your API key. See API Keys.
Idempotency-KeystringRequired
Up to 255 characters. Use your order ID, so a retried request can't create a second payment. See Idempotency.
Content-TypestringRequired
application/json

Body​

merchantReferencestringRequired
Your order ID, up to 100 characters. A reference belongs to one payment forever. Reusing it returns 409.
amountnumberRequired
At least 0.01, with up to 4 decimal places.
currencystring
Three-letter currency code. Defaults to your account currency. ETB is the only currency today.
descriptionstring
What the customer is paying for. Up to 255 characters.
customerobject
The customer's details. BillPay stores them encrypted and only returns them masked.
customer.namestring
Up to 150 characters.
customer.phonestring
7 to 32 digits, optionally starting with +. For example, +251911234567.
customer.emailstring
The customer's email address.
returnUrlstring
Where the customer goes after paying. Must use https, up to 2,048 characters.
cancelUrlstring
Where the customer goes if they give up. Must use https.

Example​

curl https://sandbox.api.billpay.et/api/v1/checkout/payments \
-H "x-api-key: $BILLPAY_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: order-10231" \
-d '{
"merchantReference": "order-10231",
"amount": 1000.00,
"currency": "ETB",
"description": "Invoice 10231",
"customer": {
"name": "Abebe Kebede",
"phone": "+251911234567"
"email": "abebe@example.com"
},
"returnUrl": "https://shop.example.com/orders/10231",
"cancelUrl": "https://shop.example.com/cart"
}'

Response​

201 Created, with the new payment in body.

If you send the same Idempotency-Key with the same body again, BillPay doesn't create a second payment. It returns the original one, with the message Payment already created. Treat a repeat like a new response: the payment is in body, and its id is the same.

{
"statusCode": 201,
"message": "Payment created successfully",
"body": {
"id": "cae54780-b884-4253-829c-1069e1d41e3c",
"merchantId": "7d3e9b14-2c5a-4f8e-b6d1-0a9c4e2f7b35",
"merchantReference": "order-10231",
"status": "CREATED",
"amount": {"amount": 1000.0000, "currency": "ETB"},
"charged": {"amount": 1000.0000, "currency": "ETB"},
"fee": {"amount": 0.0000, "currency": "ETB"},
"vat": {"amount": 0.0000, "currency": "ETB"},
"net": {"amount": 1000.0000, "currency": "ETB"},
"refunded": {"amount": 0.0000, "currency": "ETB"},
"feePayer": null,
"description": "Invoice 10231",
"customer": {
"name": "Abebe Kebede",
"phone": "****4567",
"email": "a***e@example.com"
},
"checkoutUrl": "https://sandbox.checkout.billpay.et/...",
"returnUrl": "https://shop.example.com/orders/10231",
"cancelUrl": "https://shop.example.com/cart",
"createdAt": "2026-10-31T17:04:11.988768131Z",
"expiresAt": "2026-10-31T17:34:11.988768131Z",
"completedAt": null,
"attempts": []
},
"timestamp": "2026-10-31T17:04:12.010+00:00"
}
The payment object
idstring
BillPay's ID for the payment. Save it with your order.
merchantIdstring
Your merchant account ID.
merchantReferencestring
Your order ID, as you sent it.
statusstring
Starts as CREATED. See Payment Statuses.
amountmoney
The amount you asked for.
chargedmoney
What the customer pays: the amount plus the customer's share of the fee.
feemoney
BillPay's fee. Set in your agreement with BillPay. It can be 0, for example for some charities, and in the sandbox.
vatmoney
VAT on the fee.
netmoney
What is credited to your balance.
refundedmoney
How much has been refunded so far.
feePayerstring
Who pays the fee: MERCHANT, CUSTOMER, or SPLIT. Set in your agreement with BillPay. Can be null in the sandbox.
descriptionstring
As you sent it.
customerobject
The customer's details. BillPay stores them encrypted. In responses, the phone and email are masked.
checkoutUrlstring
The page to send your customer to. Only in this response. Later responses return null.
returnUrlstring
As you sent it.
cancelUrlstring
As you sent it.
createdAtstring
When the payment was created.
expiresAtstring
When the checkout link stops working.
completedAtstring
When the payment reached a final status. null until then.
attemptsarray
Each try the customer made to pay. Empty until the first try.
attempts[].attemptNointeger
The try number, starting at 1.
attempts[].providerstring
The provider used, for example SANDBOX_WALLET.
attempts[].instrumentstring
The instrument used, for example TEST_WALLET.
attempts[].payerReferencestring
The customer's account or phone number, masked.
attempts[].statusstring
The result of this try, for example SUCCEEDED or TIMEOUT.
attempts[].failureCodestring
Why the try failed, for example PROVIDER_TIMEOUT. null if it succeeded.
attempts[].failureReasonstring
A readable explanation of the failure.
attempts[].createdAtstring
When the try started.
attempts[].completedAtstring
When the try finished.

Fees​

Who pays BillPay's fee is agreed with BillPay when you sign up. You don't choose it per payment. The payment's feePayer tells you which applies:

feePayerWho pays the feeEffect
MERCHANTYou. This is the most common.The customer pays amount. You receive amount minus the fee and VAT.
CUSTOMERThe customerThe customer pays more than amount. You receive the full amount.
SPLITBothThe fee is shared between you and the customer.

Some merchants have no fee at all, so fee is 0.

Always read charged for what the customer paid, and net for what reaches your balance. Don't calculate them yourself.

Errors​

StatusReason
400A field failed validation, or Idempotency-Key is missing. body names each invalid field.
401The key is missing or wrong, or it's from the other environment.
409merchantReference is already used, or the same Idempotency-Key was sent with a different body.
422Your account can't take live payments yet (production only).

See Errors for the full list.

2. Redirect the customer​

Redirect the customer's browser to checkoutUrl. For example, in Express:

res.redirect(303, payment.checkoutUrl);

The link works until expiresAt, which is 30 minutes after the payment is created. Read expiresAt instead of hard-coding 30 minutes. The customer gets 3 tries. If a try fails, for example because of a wrong PIN, the payment stays open and the customer can try again on the same page.

The checkout page is available in English, French, Arabic, Amharic, Afaan Oromoo, Tigrinya, and Chinese., and the customer gets 3 tries. If a try fails, for example because of a wrong PIN, the payment stays open and the customer can try again on the same page.

Save the checkout URL

BillPay returns checkoutUrl only when the payment is created. If you want to send the link again later, for example by SMS, save it with the order.

3. Handle the return​

After paying, the customer's browser goes to your returnUrl. If they give up on the checkout page, it goes to your cancelUrl.

  • Put your order ID in the URL, like https://shop.example.com/orders/10231. BillPay sends the customer to your returnUrl exactly as you set it, without adding a payment ID or status. The URL is the only way your page knows which order to show.
  • Show the status from your database, not from the URL. The webhook updates your database.
  • The webhook can arrive a few seconds after the customer. If the order isn't updated yet, show "Confirming your payment…" and refresh the status after a few seconds.

4. Confirm the result​

BillPay sends one of these webhooks to your server:

EventMeaningWhat to do
PaymentCapturedThe customer paid.Mark the order paid and deliver it.
PaymentFailedThe payment failed for good.Mark the order failed and offer another try.

Cancelled and expired payments don't send a webhook yet. For orders still unpaid after 30 minutes, check the payment. It will be CANCELLED or EXPIRED.

Letting the customer try again​

A merchantReference belongs to one payment forever. If a payment ends FAILED, CANCELLED, or EXPIRED, create a new payment with a new reference, such as order-10231-2, and a new Idempotency-Key.