Manage the Return and Callback URLs
PayTabs provides you with the backend packages that make the integrating with PayTabs payment gateway very easy by providing ready-made classes that handle the payment process.
This article is dedicated to walking you through how to manage and pass the return and the callback URLs. The following parameters should be sent within the sendURLs
function as shown below:
Method Specification
Description | Allow you to pass both the return and callback URLs. |
---|---|
Since | 1.0.0 |
Required | ✘ |
Signature |
|
Sample |
|
Method Parameters:
Return
Name | $return |
---|---|
Type | STRING |
Description | The return URL is the URL that PayTabs will redirect the customer to after he finishes the payment process (whether it's authenticated or not). It will redirect the customer with a POST response that is sent with the client/cardholder redirection through his browser containing the basic transaction information once the payment process ends (whether the customer cancels, paid, or failed to pay). It depends on the customer's actions, which means if the customer closes the browser right after the payment without waiting to be redirected back to your system, you will not receive this response. |
Default |
|
Min | - |
Max | 255 |
Validation Rule | Valid URL |
Required | ✔ |
Callback
Name | $callback |
---|---|
Type | STRING |
Description | The callback response is a server-to-server POST response that is sent (to a pre-defined HTTPS URL) with the full detailed transaction information once the payment process has ended (whether the customer cancels, paid, or failed to pay). It does not depend on the customer's actions; the response will be sent anyway. |
Default |
|
Min | - |
Max | 255 |
Validation Rule | Valid URL |
Required | ✔ |
Expected payment flow behaviour:
- As a merchant you would initiate a payment request per the above Specifications, which include a sample code.
- Then, you will call the method create_pay_page() and return the result to redirect the customer to the payment page.
try {
$paymentPage = paypage::sendTransaction('sale','ecom')
->sendCart("Order_101", 1000.00, 'Order Description')
->sendURLs("https://example.com/order-page", "https://api.example.com/callback")
->create_pay_page();
return $paymentPage;
} catch (\Exception $e) {
// Handle errors appropriately
return back()->with('error', 'Payment initiation failed: ' . $e->getMessage());
} - After this, your customer would proceed normally with payment by choosing the preferred payment method (if available), and providing his card information.
- Then, he will be redirected to his issuer bank 3DS/OTP page to authenticate the used card
- Finally, he would be redirect to a success/error page accordingly. By this time, you will be able to see his transaction on your merchant dashboard, whether it's accepted/authorized or not.