PayTabs Laravel Package makes integration with the PayTabs payment gateway very easy by providing a ready-made payment class that handles the card entry and, billing & shipping information and completes the missing details.


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:


    

Paypage::capture('tran_ref','order_id','amount','capture description'); 


Capture request is ONLY available for successfully Authorized (Auth) transactions. 


Through out the article we will use the transaction types clarified in our What is "tran_type"? solution article.   . 


Transaction Reference 


The Parameter Tag/Nametran_ref
Example
$tran_ref = "TST2016700000692";
Data TypeSTRING
Required

PurposeIndicates the reference to the "Auth" transaction you want to capture
Validation RulesAccept only valid "Auth" transaction references.



Order Id


The Parameter Tag/Nameorder_id
Example
$order_id = "CART#1001";
Data TypeSTRING
Required

PurposeIndicates the cart id to the transaction you want to create




Amount


The Parameter Tag/Nameamount
Example
$amount = 100.50
Data TypeDECIMAL
Required

PurposeIndicates the amount you want to capture, either the full amount for a full capture or partial one for partial capture.
Validation RulesAccept only decimal amounts, which must be less than or equal to the authorized amount that has not been captured yet.




Description 


The Parameter Tag/Namedescription
Example
$description = "order description";
Data TypeSTRING
Required

PurposeIndicates the cart/order description at your end to easily relate this transaction to. It might contain the reason for the capture.



Sample Request


To process a capture request, you have to pass a tran_type that MUST be capture” and the transaction reference of the original authenticated "Auth" transaction that you want to capture, as shown in the below sample:


   $capture = Paypage::capture('tran_ref','order_id','amount','capture description'); 
return $capture;


Capture request is ONLY available for successfully Authorized (Auth) transactions. 



Sample Response Payload

Generic


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": "TST2111100150569",
"tran_type": "Capture",
"cart_id": "cart_11111",
"cart_description": "Description of the items/services",
"cart_currency": "USD",
"cart_amount": "200.00",
"callback": "https://webhook.site/4b3af623-085f-4b82-ab22-cb6cedeba218",
"customer_details": {
"name": "first last",
"email": "[email protected]",
"phone": "0522222222",
"street1": "address street",
"city": "dubai",
"state": "DU",
"country": "AE",
"ip": "1.1.1.1"
},
"payment_result": {
"response_status": "A",
"response_code": "G97564",
"response_message": "Authorised",
"transaction_time": "2021-04-21T09:32:44Z"
},
"payment_info": {
"card_type": "Credit",
"card_scheme": "Visa",
"payment_description": "4111 11## #### 1111"
}
}








⌂ To get familiar with the whole process and the other steps, kindly navigate to our "The Laravel Packge Integration Manual" solution article. 

 And to get familiar with the rest of the steps regarding the current step "Step 7 - Manage Transactions" kindly click here.

 And to navigate to the previous step in the integration process "Step 6 - Handle the post payment responses" kindly click here.