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 refund a transaction means to return/transfer back a transaction amount from your bank account to the customer's bank account. It will be logged as a new separated transaction with this type, and it will be related to the previous "Sale" or "Capture" transaction. In this article, we walk you through how to use and manage the below function:


Paypage::refund('tran_ref','order_id','amount','refund_reason');

Refund request is available ONLY for those authenticated "Sale" transactions or authenticated "Capture" 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 refund.
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 refund, either the full amount for a full refund or partial one for a partial refund.
Validation RulesAccept only decimal amounts, which must be less than or equal to the actual amount of the main transaction.




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 refund” and the transaction reference of the original "Auth" transaction that you want to refund, as shown in the below sample:


 $refund = Paypage::refund('tran_ref','order_id','amount','refund_reason');
  return $refund;
Generic


Refund request is available ONLY for those Authenticated Sale transactions or Authenticated Capture transactions



Sample Response Payload 


The response PayTabs will send to you will be a JSON object that contains the full details regarding this refund transaction, as shown below:

 
{
  "tran_ref": "TST2111100150559",
  "tran_type": "refund",
  "cart_id": "cart_66666",
  "cart_description": "refund reason",
  "cart_currency": "USD",
  "cart_amount": "10.00",
  "customer_details": {
    "name": "first last",
    "email": "[email protected]",
    "phone": "0522222222",
    "street1": "address street",
    "city": "dubai",
    "state": "DU",
    "country": "AE",
    "ip": "196.219.200.200"
  },
  "payment_result": {
    "response_status": "A",
    "response_code": "G97111",
    "response_message": "Authorised",
    "transaction_time": "2021-04-21T09:25:11Z"
  },
  "payment_info": {
    "card_type": "Credit",
    "card_scheme": "Visa",
    "payment_description": "4111 11## #### 1111"
  }
}
Generi









⌂ 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.