Returning Payments Send From Account

With this service, a transfer request has been made but you can send a payment request for the returning payments due to the buyer account error. Returned payments are processed as a balance to a subaccount for your store. You can access the list of these reimbursed payments with the “Returning Payments - List API” service.

1-To send payment transfer from the account, send the information specified in the table to the URL related to POST: https://www.paytr.com/odeme/hesaptan-gonder

Required parameters for token creation

Field name / type Description Mandatory Limitations
merchant_id(integer) Merchant No: Merchant number given to you by PayTR Yes -
trans_id(string) Transfer ID: The unique transaction number you set for the transfer transaction. Yes Up to 64 characters, alpha numeric)
merchant_salt A value specific to your store, which you can access through the PayTR Merchant Panel > Information page. Yes -
merchant_key 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

Field name / type Description Mandatory Limitations
merchant_id(integer) Merchant No: Merchant number given to you by PayTR Yes -
trans_id(string) Transfer ID: The unique transaction number you set for the transfer transaction Yes Up to 64 characters, alpha numeric)
trans_info(JSON) Transfer Information: Content in JSON format containing transfer amount, recipient name and IBAN values.(See sample code for how to define it) Yes -
paytr_token (string) PayTR Token: The value you create to make sure that the request comes from you and that the content has not changed(See sample code for calculation) Yes -



2- Your request will be returned in JSON format. a. If the request is valid, the status number returns the transaction number you sent in the success and trans_id field. b. 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.

3- After receiving the success response, your request to send from the account will be successfully received by the PayTR system. The PayTR system will process your request in an average of 5 minutes, check the trans_info content you send, and make the transfers. If incorrect information is detected during the check, the relevant transaction is marked as unsuccessful. The resulting result is notified by POST to the address you defined as PayTR Mağaza Paneli > Ayarlar > Platform Transfer Sonucu Bildirim URL in JSON format.

<?php

    $merchant_id    = 'XXXXXX';
    $merchant_key   = 'XXXXXXXXYYYYYYYY';
    $merchant_salt  = 'XXXXXXXXYYYYYYYY';

    $trans_id="PHG".time();
    $trans_info=array();

    $trans_info[]=array("amount"=>"1283",
        "receiver"=>"XYZ LTD ŞTİ",
        "iban"=>"TRXXXXXXXXXXXXXXXXXXXXX");

    $paytr_token=base64_encode(hash_hmac('sha256',$merchant_id.$trans_id.$merchant_salt, $merchant_key, true));

    $post_vals=array('trans_info'=>json_encode($trans_info),
        'trans_id'=>$trans_id,
        'paytr_token'=>$paytr_token,
        'merchant_id'=>$merchant_id
    );

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, "https://www.paytr.com/odeme/hesaptan-gonder");
    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_raw=$result;
    $result=json_decode($result,1);

    if($result['status']=='success')
    {

        print_r($result_raw);
    }
    else
    {

        print_r($result_raw);
    }

Returning payments send from account sample codes click to download