Using this service, you can make a refund for part or all of the amount of the order.
IMPORTANT WARNING: Incorrect integration may cause incorrect returns and therefore you may experience financial loss. Please be very careful during integration! You can contact us for your questions.
1- For the order you want to return, send the order number and the refund amount to the other information specified in the table below https://www.paytr.com/odeme/iade via POST.
Required parameters for token creation
Variable / Type | Explanation | Mandatory |
---|---|---|
merchant_id (string) | Store Number: Store number given to you by PAYTR | Yes |
merchant_oid (string) | Order Number: The order number of the transaction you want to return | Yes |
return_amount(integer) | Refund Amount: The amount you wish to return for the relevant order. (Only a period (.) should be sent as delimiter. E.g.: 10.25 | Yes |
merchant_salt (string) | A value specific to your store, which you can access through the PayTR Merchant Panel > Information page. | Yes |
merchant_key(integer) | A value specific to your store, which you can access through the PayTR Merchant Panel > Information page. | Yes |
Values to be sent in POST REQUEST:
Variable / Type | Explanation | Mandatory |
---|---|---|
merchant_id (integer) | Store Number: Store number given to you by PAYTR | Yes |
merchant_oid (string) | Order Number: The order number of the transaction you want to return | Yes |
return_amount(integer) | Refund Amount: The amount you wish to return for the relevant order. (Only a period (.) should be sent as delimiter. E.g.: 10.25 | Yes |
paytr_token (string) | PayTR Token: It is the value that you will create to make sure that the request comes from you and that the content has not changed (You should look at the sample codes regarding the calculation) | Yes |
reference_no | Reference No: Returns from Status Query service if transmitted.(up to 64 character, Alphanumeric)) | No |
Your request will be returned in JSON format. a. If there is no transaction for the order number you have requested, the status value returns failed. b. If there is a transaction for the order number you have requested, the status value returns success and the information in the table below returns. c. If you have an error in the query, the status value returns an error. In this case, you should check the err_msg content for the error detail.
Values returned in the Result variable
Values | Explanation |
---|---|
status | If the return request is successful, success returns |
is_test | Returns 1 if the return request is for testing |
merchant_oid | Order number for which a return request was made |
return_amount | Amount made for a refund |
reference_no | Reference number, if submitted |
<?php
$merchant_id = "XXXXXX";
$merchant_key = "YYYYYYYYYYYYYY";
$merchant_salt = "ZZZZZZZZZZZZZZ";
$merchant_oid = "XXXXXX";
$return_amount = "11.97";
$reference_no = "XXXXXX11111";
$paytr_token=base64_encode(hash_hmac('sha256',$merchant_id.$merchant_oid.$return_amount.$merchant_salt,$merchant_key,true));
$post_vals=array('merchant_id'=>$merchant_id,
'merchant_oid'=>$merchant_oid,
'return_amount'=>$return_amount,
'paytr_token'=>$paytr_token);
$ch=curl_init();
curl_setopt($ch, CURLOPT_URL, "https://www.paytr.com/odeme/iade");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1) ;
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_vals);
curl_setopt($ch, CURLOPT_FRESH_CONNECT, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 90);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 90);
$result = @curl_exec($ch);
if(curl_errno($ch))
{
echo curl_error($ch);
curl_close($ch);
exit;
}
curl_close($ch);
$result=json_decode($result,1);
if($result['status']=='success')
{
}
else
{
//Örn. $result -> array('status'=>'error', "err_no"=>"006", "err_msg"=>"Toplam iade tutarı odeme tutarindan fazla olamaz")
echo $result['err_no']." - ".$result['err_msg'];
}
For Refund API service sample codes Click to download.