Capture Transaction
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.
To capture a transaction means that the previously authorized amount from a previous auth transaction will be captured/transferred from the cardholder's bank account to your bank account. In this article, we walk you through how to use and manage the below function:
Method Specification
Description | Used to make a direct request. |
---|---|
Since | 1.0.0 |
Required | ✔ |
Signature |
|
Sample |
|
Capture request is ONLY available for successfully Authorized Auth transactions.
Through out the article we will use the transaction types clarified in ourWhat is the "tran_type" (transaction type)?solution article.
Method Parameters:
TransactionDetails
Name | transactionDetails | |||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Type | ARRAY | |||||||||||||||||||||||||||||||
Array Element values: |
| |||||||||||||||||||||||||||||||
Description | Array of transaction details elements (Reference, type and class) | |||||||||||||||||||||||||||||||
Default | - | |||||||||||||||||||||||||||||||
Required | ✔ | |||||||||||||||||||||||||||||||
Example |
|
CartDetails
Name | cartDetails | ||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Type | ARRAY | ||||||||||||||||||||||||||||||||||||||||||||
Array Element values: |
| ||||||||||||||||||||||||||||||||||||||||||||
Description | This is the second parameter of the queryTransaction() function, which handles the payment cart details (e.g ID, Currency, etc). | ||||||||||||||||||||||||||||||||||||||||||||
Default | - | ||||||||||||||||||||||||||||||||||||||||||||
Required | ✔ | ||||||||||||||||||||||||||||||||||||||||||||
Example |
|
Callback
Name | callback |
---|---|
Type | Method |
Description | A callback function invoked upon the successful of the request. |
Default | - |
Required | ✔ |
Example |
|
Sample Request:
To process a capture request, you have to pass a tran_type
that MUST be capture which will be handled via the method and the transaction reference of the original authenticated Auth transaction that you want to capture, as shown in the below sample:
PayTabs.queryTransaction(
transactionDetails,
cartDetails,
callback
);
Sample Response Payload:
The response PayTabs will send to you will be a JSON object that contains the full details regarding this capture transaction as shown below:
{
"tran_ref": "TST2509502044803",
"previous_tran_ref": "TST2016700000692",
"tran_type": "Capture",
"cart_id": "cart_11111",
"cart_description": "Capture reason of the items/services.",
"cart_currency": "SAR",
"cart_amount": "500.00",
"tran_currency": "SAR",
"tran_total": "500.00",
"customer_ref":"CUST0101",
"customer_details": {
"name": "Technical Support Team",
"email": "[email protected]",
"phone": "+966 55 xxxxxx6",
"street1": "address street",
"city": "Jeddah",
"state": "Makkah",
"country": "SA",
"zip": "12345"
"ip": "156.221.244.35"
},
"payment_result": {
"response_status": "A",
"response_code": "G40178",
"response_message": "Authorised",
"transaction_time": "2022-12-14T15:53:58Z"
},
"payment_info": {
"payment_method": "Visa",
"card_type": "Credit",
"card_scheme": "Visa",
"payment_description": "4000 00## #### 0002",
"expiryMonth": 12,
"expiryYear": 2026
},
"serviceId": 1,
"paymentChannel": "Transaction API",
"merchant_id": 31000,
"profile_id": 81000,
"trace": "PMNT0402.67F0E000.00100000"
}