Status Inquiry API

You can access the status of merchant transactions made. You can view the returns if there are any.

Status inquiry service is divided into two categories as Merchant Status Inquiry and Marketplace Status Inquiry.

1- A request is made to status inquiry service https://www.paytr.com/odeme/durum-sorgu along with the fields that must be sent.

Field name / Type Explanation
merchant_id Store Number
merchant_key Store Password
merchant_salt Store secret key
merchant_oid Order Number


Merchant Status Inquiry
The order number is queried with the values from the table. The customer's payment amount and the total payment amount are printed on the screen together with the currency. If there is an error in the above information, the error message will be displayed on the screen. At the same time, if there are returns for the order, these returns are indicated on the screen.

2- Your request will be returned in JSON format.
a. If there is no error in the query, the status value is "success" and the information in the table below returns.
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.

Other information returned in the status "success" are detailed in the table below.

Field name / Type Explanation Values
Status(string) Status: Result of query success or error
payment_amount(string) Payment Amount: Amount information for the order. 10,8
payment_total(string) Payment Total: The amount paid by the customer for the order. 10,8
payment_date(integer) Payment Date: Transaction date. 2021-01-01 (YYYY-MM-DD)
currency(string) Currency TL(or TRY), EUR, USD, GBP, RUB
net_tutar (string) Net Amount : The amount remaining after the deduction 0.76
kesinti_tutari (string) Amount deducted for trading 0.24
payment_amount(string) Payment Amount: Amount information for the order. 10,8
payment_total(string) Payment Total: The amount paid by the customer for the order. 10,8
payment_date(integer) Payment Date: Transaction date. 2021-01-0123:59:59(YYYY-MM-DDhh:mm:ss)
currency(string) currency unit TL(orTRY),EUR,USD,GBP,RUB
taksit(string) Installments: If the transaction is made in installments, the number of installments 0,2,3,4,5,6,7,8,9,10,11,12
kart_marka(string) The brand of the card being transacted Etc.WORD,BONUS,ETC.
masked_pan(string) Date of execution of the transaction Etc.455359AAA6747
odeme_tipi(string) What type of payment is made CART or EFT
test_mode(string) The procedure is performed in a test or live environment 0 or 1
returns(Array) Returns: If there is a refund in the order, the value is returned.
err_no err_no: error number. 004
err_msg err_msg: error message. Failed to find successful payment with merchant_oid


Merchant inquiry service sample codes: The sample code describes in detail how to do this.

<?php

$merchant_id = "XXX";
$merchant_key = "XXX";
$merchant_salt = "XXX";
$merchant_oid = "XXX";

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

$post_vals = array('merchant_id' => $merchant_id,
        'merchant_oid' => $merchant_oid,
        'paytr_token' => $paytr_token);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://www.paytr.com/odeme/durum-sorgu");
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') {
       echo $result['err_no'] . " - " . $result['err_msg'];
       exit;
}

echo $result['payment_amount'] . " " . $result['currency'] . "<br>";

echo $result['payment_total'] . " " . $result['currency'] . "<br>";

foreach ($result['returns'] AS $return_success)
       print_r($return_success);
?>

For merchant inquiry service sample codes Click to download.

1- A request is made to status inquiry service https://www.paytr.com/odeme/durum-sorgu along with the fields that must be sent.

Field name / Type Explanation
merchant_id Store Number
merchant_key Store Password
merchant_salt Store secret key
merchant_oid Order Number


Marketplace Status Inquiry API
The order number is queried with the values from the table. The customer's payment amount and the total payment amount are printed on the screen together with the currency. If there is an error in the above information, the error message will be displayed on the screen. At the same time, if there are returns for the order, these returns are indicated on the screen.

2- Your request will be returned in JSON format.
a. If there is no error in the query, the status value is "success" and the information in the table below returns.
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.

Other information returned in the status "success" are detailed in the table below.

Field name / Type Explanation Values
Status(string) Status: Result of query success or error
net_tutar (string) Net Amount : The amount remaining after the deduction 0.76
kesinti_tutari (string) Amount deducted for trading 0.24
payment_amount(string) Payment Amount: Amount information for the order. 10,8
payment_total(string) Payment Total: The amount paid by the customer for the order. 10,8
payment_date(integer) Payment Date: Transaction date. 2021-01-0123:59:59(YYYY-MM-DDhh:mm:ss)
currency(string) currency unit TL(orTRY),EUR,USD,GBP,RUB
taksit(string) Installments: If the transaction is made in installments, the number of installments 0,2,3,4,5,6,7,8,9,10,11,12
kart_marka(string) The brand of the card being transacted Etc.WORD,BONUS,ETC.
masked_pan(string) Date of execution of the transaction Etc.455359AAA6747
odeme_tipi(string) What type of payment is made CART or EFT
test_mode(string) The procedure is performed in a test or live environment 0 or 1
payment_amount(string) Payment Amount: Amount information for the order. 10,8
payment_total(string) Payment Total: The amount paid by the customer for the order. 10,8
payment_date(integer) Payment Date: Transaction date. 2021-01-01 23:59:59 (YYYY-MM-DD hh:mm:ss)
currency(string) Currency TL(or TRY), EUR, USD, GBP, RUB
returns(string) Returns: If there is a refund in the order, the value is returned.
err_no err_no: error number. 004
err_msg err_msg: error message. Failed to find successful payment with merchant_oid
submerchant_payments


Marketplace inquiry service sample codes: The sample code describes in detail how to do this.

<?php
    $merchant_id = "XXX";
    $merchant_key = "XXX";
    $merchant_salt = "XXX";
    $merchant_oid = "XXX";

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

    $post_vals = array('merchant_id' => $merchant_id,
        'merchant_oid' => $merchant_oid,
        'paytr_token' => $paytr_token);

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, "https://www.paytr.com/odeme/durum-sorgu");
    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') {
        echo $result['err_no'] . " - " . $result['err_msg'];
        exit;
    }

    echo $result['payment_amount'] . " " . $result['currency'] . "<br>";

    echo $result['payment_total'] . " " . $result['currency'] . "<br>";

    foreach ($result['returns'] AS $return_success)
        print_r($return_success);

    foreach ($result['submerchant_payments'] AS $sub_payments)
        print_r($sub_payments);
?>

For marketplace inquiry service sample codes Click to download.