Skip to main content
  1. Home
  2. Blog
  3. Recharge API
  4. Recharge API Callback URL Explained (with PHP Example)

Recharge API Callback URL Explained (with PHP Example)

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

  1. You send a recharge with a unique order id.
  2. The response says Pending.
  3. When the operator confirms, A1Topup calls your callback URL with the order id, status and operator id.
  4. 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';
Pro tip

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?
A URL on your server that the provider calls with the final status of a recharge, so your system updates without manual checks.
What data does the callback send?
Your order id, the final status (Success or Failure) and the operator reference.
What if my server misses a callback?
Use the status API with the same order id to check the result.

Have a question? Talk to our team

We respect your privacy. Your details are only used to contact you about A1Topup.

Related articles

WhatsApp