Testing
In the sandbox, the number the customer types on the checkout page decides what happens. You can test every outcome without real money. None of this works in production.
The sandbox checkout shows three test payment methods. They run on BillPay's simulator, so no real bank, wallet, or card is involved.
| On the checkout page | provider / instrument in the API |
|---|---|
| BillPay Test Wallet | SANDBOX_WALLET / TEST_WALLET |
| BillPay Test Bank | |
| BillPay Test Card |
These are sandbox-only. Production will show the real providers as they go live.
Payments
| Type on checkout | Result | failureCode |
|---|---|---|
0911234567, or any number not listed below | Paid after a few seconds | |
0911000000 (ends in 0000) | Refused | INSUFFICIENT_FUNDS |
0911001111 (ends in 1111) | Declined by the customer | CUSTOMER_DECLINED |
0911002222 (ends in 2222) | Refused, account blocked | ACCOUNT_BLOCKED |
0911003333 (ends in 3333) | Refused, over the customer's limit | LIMIT_EXCEEDED |
0911008888 (ends in 8888) | Paid after a few minutes, like a slow customer | |
0911009999 (ends in 9999) | Never answers. The try ends as TIMEOUT, and the payment becomes EXPIRED when the link runs out | PROVIDER_TIMEOUT |
Test cards
On the test card page, use one of these tokens instead of a card number. Real card numbers never reach BillPay, in the sandbox or in production.
| Token | Result |
|---|---|
tok_success | Paid |
tok_insufficient_funds | Refused, INSUFFICIENT_FUNDS |
tok_declined | Refused, CUSTOMER_DECLINED |
tok_expired_card | Refused, CARD_EXPIRED |
tok_timeout | Never answers |
A refused try sends the payment back to CREATED, so the customer can try again. They get 3 tries within 30 minutes.
Refunds
| Refund amount | Result |
|---|---|
Ends in .13, for example 10.13 | Refused by the provider (REFUND_REFUSED). The money goes back to your balance. |
| Any other amount | COMPLETED, and PaymentRefunded is sent. |
Payouts
These apply to settlements and withdrawals.
| Destination account number | Result |
|---|---|
Ends in 0000 | Refused by the receiving bank. |
Ends in 9999 | Paid, then sent back by the bank (ACCOUNT_CLOSED). |
| Anything else | Paid. |
Webhooks
Send a signed TestEvent from Developers → Webhooks → Send test in the
portal, or with the API:
curl -X POST https://sandbox.api.billpay.et/api/v1/checkout/webhooks/{webhookId}/test \
-H "x-api-key: $BILLPAY_API_KEY"
To receive webhooks on your own computer, use a tunnel such as
ngrok. Its inspector at http://localhost:4040 also lets
you replay a delivery, which is an easy way to test duplicate events.
Before you go live
Run each of these at least once:
| # | Test | How | You should see |
|---|---|---|---|
| 1 | Successful payment | Pay with 0911234567 | CAPTURED, PaymentCaptured, order marked paid |
| 2 | Refused, then paid | 0911000000, then 0911234567 | Still one payment, ending CAPTURED |
| 3 | Refused 3 times | 0911001111 three times | FAILED and PaymentFailed with failureCode CUSTOMER_DECLINED |
| 4 | Customer gives up | Cancel on the checkout page | Lands on your cancelUrl. CANCELLED, no webhook |
| 5 | Nobody pays | Create a payment, don't open the checkout, wait 30 minutes | EXPIRED, picked up by your status check |
| 6 | Slow customer | 0911008888 | Your return page waits, then shows paid |
| 7 | Duplicate webhook | Replay a delivery from ngrok within 5 minutes | Handled once, answered 200 both times |
| 8 | Fake webhook | Send a request with a wrong signature | 400, order unchanged |
| 9 | Partial refund | Refund 10.00 | COMPLETED and PaymentRefunded |
| 10 | Refused refund | Refund 10.13 | FAILED, balance restored |