Manage the Cart Details - sendCart()
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 pass the cart information within the initiation of the payment page.The following parameters are required to be sent within the sendCart
function as shown below:
Method Specification
That the sendCart
method is Mandatory, not passing it would throw an exception.
Description | Responsible of sending the card/order details. |
---|---|
Since | 1.0.0 |
Required | ✔ |
Signature |
|
Sample |
|
Method Parameters:
Cart Id
Name | $cart_id |
---|---|
Type | STRING |
Description | Indicates the cart/order id at the merchant end to easily relate the transaction to. |
Default | - |
Min | 1 |
Max | 64 |
Required | ✔ |
Amount
Name | $amount |
---|---|
Type | FLOAT |
Description | Indicates the amount the customer is about to be charged with. Both min and max values are subjected to the merchant transaction limits. |
Default | - |
Min | 0.01 |
Max | 9999999999.99 |
Required | ✔ |
Cart Description
Name | $cart_description |
---|---|
Type | STRING |
Description | Indicates the cart/order description at the merchant end to easily relate the transaction to. |
Default | - |
Min | 1 |
Max | 128 |
Required | ✔ |
Expected payment flow behaviour:
- As a merchant you would initiate a payment request per the above Specifications, which include a sample code.
- Then, after generating the payment page use the result to redirect the customer to the payment page.
try {
$paymentPage = paypage::sendTransaction('sale','ecom')
->sendCart("Order_101", 1000.00, 'Order Description')
->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.