Skip to main content

Refund 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 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:



Method Specification​


Description

To refund return/transfer back a previous transaction amount from your bank account to the customer's bank account. It will be logged as a new separated transaction with this type.

Since1.0.0
Required

✘

Signature

refund(string $tran_ref, string $order_id, float $amount, string $refund_description)

Sample

$tran_ref = "TST2016700000692";
$order_id = "cart_11111";
$refund_description="Void reason of the items/services."
$amount = 500.00;

$refund = Paypage::void($tran_ref, $order_id, $amount, $refund_description);
return $refund;

Be Aware Of

Refund request is available ONLY for those authenticated Sale transactions or authenticated Capture transactions.

Note

Through out the article we will use the transaction types clarified in ourWhat is the "tran_type" (transaction type)?solution article.




Method Parameters:​

Tran Ref​

Name$tran_ref
Type

STRING

DescriptionIndicates the reference to a Sale or Capture transaction you want to refund
Default

-

Validation Rule

Accept only valid Sale or Capture transaction references.

Required

βœ”



Order Id​

Name$order_id
Type

STRING

DescriptionIndicates the cart id to the transaction you want to refund
Default

-

Required

βœ”



Amount​

Name$amount
Type

float

DescriptionIndicates the amount you want to refund, either the full amount for a full refund or partial one for a partial refund.
Default

-

Validation Rule

Accept only float amounts, which must be less than or equal to the actual amount of the main transaction you want refund.

Required

βœ”



Refund Description​

Name$refund_description
Type

STRING

DescriptionIndicates the cart/order description at your end to easily relate this transaction to. It might contain the reason for the refund.
Default

-

Required

βœ”




Sample Request:​

To process a refund request, you have to pass a tran_type that MUST be refund which handed via the method and the transaction reference of the original authenticated Sale or Capture transaction that you want to refund, as shown in the below sample:

$tran_ref = "TST2016700000692";
$order_id = "cart_11111";
$refund_description="Void reason of the items/services."
$amount = 500.00;

$refund = Paypage::void($tran_ref, $order_id, $amount, $refund_description);
return $refund;


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": "TST2509502044803",
"previous_tran_ref": "TST2016700000692",
"tran_type": "Refund",
"cart_id": "cart_11111",
"cart_description": "Refund 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.00108000"
}

We are glad to be always in help. We aim to serve you better each time. As such, please spare a minute to share feedback about your recent experience with PayTabs Developers , on Trustpilot, or Google Reviews.