Building your business from scratch and can't find any of the above solutions compatible with your business? Don't worry we got your back. Paytabs provides you with a collection of API endpoints which used to process all payments, regardless of if they are through either your own payment pages, the managed payment pages, or if you are using the hosted payment pages.



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 mentioned endpoint.

   

Refund request is available ONLY for those Authenticated Sale transactions or Authenticated Capture transactions. In which the tran_type MUST be refund”, and the requested transaction id to be refunded MUST be passed to the tran_ref parameter in the request


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


In this article, you will be going to know about:


The Endpoint and Related Postman Collection


In this tutorial, we will rely on the PayTabs Query Transaction API Endpoint, mentioned on the PayTabs API endpoints postman collection, which you can access from here. The endpoint will need to be accessed with a POST request on the below-mentioned URL


Post
{{domain}}/payment/request 


Please note that not using the proper endpoint URI {{domain}} will lead to authentication issues within your responses. To find the your proper domain you can read our What Is My (Region)/(endpoint URL)? solution article.



The Minimum Required Parameters


To initiate a refund payment request, there are minimum required parameters that need to be passed with valid information. The specification of these required parameters is clarified below:


Parameter 

Sample Response

Nullable

Purpose 

TST2234701408580

Indicates the Transaction Reference on the Paytabs side

check details on [Response Parameters | tran_ref]



Sample Request Payload


The below sample request payload will show you how you can pass the above-mentioned parameters, which are needed to be passed with valid values to perform a request.  

Refund request is ONLY available for successfully Authorized (A) transactions. 


{
    "profile_id": 70303,
    "tran_type": "refund",
    "tran_class": "ecom",
    "cart_id": "cart_66666",
    "cart_currency": "{{currency}}",
    "cart_amount": 1.3,
    "cart_description": "refund reason",
    "tran_ref": "TST2016700000692"
}
Generic


Note that the "tran_type" must be "refund".



Sample Response Payload


{
  "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"
  }
}










⌂ To get familiar with the whole process and the other steps, kindly navigate to our "The PT2 API Endpoints 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.