Recharge API Callback URL Explained (with PHP Example)
Key takeaways
- A callback updates pending recharges automatically
- Update an order only if it is still pending
- Fall back to the status API if a callback is missed
Most recharges succeed or fail within seconds. A few stay pending while the operator confirms. Without a callback URL, someone on your team checks those by hand. With one, your system updates itself.
How the callback works
- You send a recharge with a unique order id.
- The response says Pending.
- When the operator confirms, A1Topup calls your callback URL with the order id, status and operator id.
- Your code updates the order and refunds the customer if it failed.
A simple PHP handler
<?php
$orderId = isset($_GET['txid']) ? $_GET['txid'] : '';
$status = isset($_GET['status']) ? $_GET['status'] : '';
$opid = isset($_GET['opid']) ? $_GET['opid'] : '';
// 1. find the order 2. update only if still pending
// 3. on Failure refund the wallet 4. reply 200
http_response_code(200); echo 'OK';
Write the callback so that running it twice gives the same result. Providers may retry, and your code should never refund the same order twice.
Rules that prevent double refunds
- Update an order only if its current status is pending
- Log every callback with the time and raw values
- Reply with HTTP 200 quickly; do heavy work after
- If no callback arrives, check the status API with the same order id
Conclusion
A callback URL is a few lines of code that saves hours of manual checking every week. Full details and samples are in the API documentation.
Integrating the recharge API?
Docs, code samples and a Postman collection.
Frequently asked questions
What is a callback URL in a recharge API?
What data does the callback send?
What if my server misses a callback?
Have a question? Talk to our team
Related articles
Recharge API Responses Explained: Success, Pending and Failed
Three statuses, three different jobs for your code. Here is how to handle each one safely.
Read more →Recharge API Integration Security Checklist for Developers
Recharge APIs move real money. Ten checks to run before your integration goes live.
Read more →DTH Recharge API: Operators, Customer Info and Common Errors
DTH customers come back every month. Here is how the API side works and what usually goes wrong.
Read more →