Setting up a callback URL

Edited

A callback URL is a website page where a user is redirected to after a successful transaction.
For example, on an e-commerce website that sells phone cases and jewellery, the customer can make a purchase through the provided checkout option. Once the payment process is completed, the customer is redirected back to the website, typically to a page that confirms their order has been received. This page is the callback URL.

From the customer's point of view, a properly set up callback URL would redirect them back to the page you specified after they complete their transaction, typically an order confirmation page. This would put the mind of a customer at ease knowing that they were able to complete their payment and purchase the product/service successfully.

 Callback URL applications

  • If a customer purchases an item from your store using the redirect method to pay for the item, a callback URL is used to return the customer to your website so they can continue browsing items.

  • If you own an appointment web app that integrates Paystack, you can redirect a user to your Calendly account for them to book a slot in your calendar.

  • If you own a bookstore, you can set up a callback URL that redirects a customer to your Google Drive containing books after the customer completes their payment.

Callback URL applications for non-developers

Callback URLs can be used in different use cases without having to write code. You can set a callback URL for any of our Paystack-hosted tools:

You can set a callback URL on any of these tools, such that when a customer completes payment, they can be redirected to a different URL either to grant access to the service they’ve paid for. For example, a Google Drive link containing an e-book, or to upsell the customer on another service. It could also be a simple thank-you page. The way the callback URL is used depends on your particular business needs.

Pitfalls to avoid when using a callback URL

Some of the pitfalls to avoid when using a callback URL are as follows:

  • Ensure that it only redirects to an HTTPS site.

  • Ensure that the URL is a website that can be loaded by a browser. For example: www.yourwebstore.com

  • Ensure you don’t use localhost as your callback URL. For example, localhost://mystore.com would not work.

  • You shouldn’t use a Callback URL as the only way of returning value. For instance, your customer might not get redirected after completing a transaction due to a network error. This would make it difficult for you to know if the transaction was successful.

Why Webhooks are preferred to callback URLs for delivering value

A webhook is a link to your server where Paystack can send notifications about the status of a transaction. If you specify a webhook URL, we will send a response to this URL whenever a webhook event is carried out on your website/app.
If users face network issues when making a transaction, they will still receive value for their purchase since we'll still send a notification to your Webhook URL.

In summary, Webhooks are preferred to Callback URLs because they are faster, more efficient, and more reliable in delivering real-time updates, and can be used to send data directly to a client, without the need for the client to poll for updates.

If you have any more questions about this, please feel free to reach out to us at support@paystack.com or via our contact form.

Was this article helpful?

Sorry about that! Care to tell us more?

Thanks for the feedback!

There was an issue submitting your feedback
Please check your connection and try again.