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);
?>
# Python 3.6+
import base64
import hmac
import hashlib
import requests
import json
import random
merchant_id = 'XXXXXX'
merchant_key = b'XXXXXXXXXXXXXXXXXX'
merchant_salt = 'XXXXXXXXXXXXXXXXXX'
merchant_oid = ''
hash_str = merchant_id + merchant_oid + merchant_salt
paytr_token = base64.b64encode(hmac.new(merchant_key, hash_str.encode(), hashlib.sha256).digest())
params = {
'merchant_id': merchant_id,
'merchant_oid': merchant_oid,
'paytr_token': paytr_token
}
result = requests.post('https://www.paytr.com/odeme/durum-sorgu', params)
res = json.loads(result.text)
if res['status'] == 'success':
print(res['payment_amount'] + res['currency'])
print(res['payment_total'] + res['currency'])
for return_success in res['returns']:
print(return_success)
else:
print(res['err_no'] + ' ' + res['err_msg'])
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using PayTrTest.Model;
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Net;
using System.Security.Cryptography;
using System.Text;
namespace PayTrTest
{
class Program
{
private readonly string TRANSFER_URL = "https://www.paytr.com/odeme/durum-sorgu";
private readonly string MERCHANT_ID = "MERCHANT_ID";
private readonly string MERCHANT_KEY = "MERCHANT_KEY";
private readonly string MERCHANT_SALT = "MERCHANT_SALT";
static void Main(string[] args)
{
var p = new Program();
p.Start();
}
public void Start()
{
Dictionary<string, string> testCases = new Dictionary<string, string>
{
{ "Geçersiz Merchant OID", "invalid_merchant_oid" } ,
{ "Başarılı Ödeme", "ffd0c5992212400cb87b88ff40bbcda2" } ,
{ "Başarısız Ödeme", "fed4b0f2aa33450bab58971ce5da75f0" } ,
{ "Kısmi Transfer (işlemde) ve Kısmi İade", "dbb5a788734f498e8490333936ec6e11" } ,
{ "Tamamı Transfer Edilmiş", "5cfbb224a9c44246853818c3082946d8" } ,
};
foreach(KeyValuePair<string, string> item in testCases)
{
Console.WriteLine($"TESTING '{item.Key}' using Merchant OID: `{item.Value}` {Environment.NewLine}");
_DoQuery(item.Value);
Console.WriteLine(new string('-',50) + Environment.NewLine);
}
Console.WriteLine($"{Environment.NewLine}{Environment.NewLine}Cikmak icin bir tusa basin...");
Console.ReadKey();
}
private void _DoQuery(string merchantOid)
{
PaytrDurumSorguResponse res = _QueryPayment(
MERCHANT_ID,
MERCHANT_KEY,
MERCHANT_SALT,
merchantOid
);
if (res.Status != "success")
{
Console.WriteLine($" {res.ErrorMessage} - {res.ErrorNo}");
return;
}
Console.WriteLine($" Sipariş Tutarı : {res.PaymentAmount} {res.Currency}");
Console.WriteLine($" Müşteri Ödeme Tutarı : {res.PaymentTotal} {res.Currency}");
if(res.Returns.Count > 0)
Console.WriteLine(" ## IADELER ##");
foreach (PaytrDurumSorguReturnItem returnItem in res.Returns)
{
Console.WriteLine($" {returnItem.Amount} - {returnItem.Date} - {returnItem.Type} - {returnItem.DateCompleted} - {returnItem.AuthCode} - {returnItem.RefNum}");
}
}
private PaytrDurumSorguResponse _QueryPayment(string merchantId, string merchantKey, string merchantSalt, string merchantOid)
{
NameValueCollection data = _GeneratePayTrSorguData(merchantId, merchantKey, merchantSalt, merchantOid);
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
using (WebClient client = new WebClient())
{
client.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
byte[] result = client.UploadValues(TRANSFER_URL, "POST", data);
string ResultAuthTicket = Encoding.UTF8.GetString(result);
dynamic json = JValue.Parse(ResultAuthTicket);
return JsonConvert.DeserializeObject<PaytrDurumSorguResponse>(ResultAuthTicket);
}
}
private NameValueCollection _GeneratePayTrSorguData(string merchantId, string merchantKey, string merchantSalt, string merchantOid)
{
NameValueCollection data = new NameValueCollection();
data["merchant_id"] = merchantId;
data["merchant_oid"] = merchantOid;
string Birlestir = string.Concat(merchantId, merchantOid, merchantSalt);
HMACSHA256 hmac = new HMACSHA256(Encoding.UTF8.GetBytes(merchantKey));
byte[] b = hmac.ComputeHash(Encoding.UTF8.GetBytes(Birlestir));
data["paytr_token"] = Convert.ToBase64String(b);
return data;
}
}
}
var request = require('request');
var crypto = require('crypto');
var express = require('express');
var app = express();
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
var merchant_id = 'XXXXXXXXX';
var merchant_key = 'XXXXXXXXXXXXXXXXXX';
var merchant_salt = 'XXXXXXXXXXXXXXXXXX';
var merchant_oid = '';
app.get("/", function (req, res) {
var paytr_token = crypto.createHmac('sha256', merchant_key).update(merchant_id + merchant_oid + merchant_salt).digest('base64');
var options = {
'method': 'POST',
'url': 'https://www.paytr.com/odeme/durum-sorgu',
'headers': {
'Content-Type': 'application/x-www-form-urlencoded'
},
form: {
'merchant_id': merchant_id,
'merchant_oid': merchant_oid,
'paytr_token': paytr_token,
}
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
var res_data = JSON.parse(body);
if (res_data.status == 'success') {
res.send(res_data);
} else {
console.log(response.body);
res.end(response.body);
}
});
});
var port = 3200;
app.listen(port, function () {
console.log("Server is running. Port:" + port);
});
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);
?>
# Python 3.6+
import base64
import hmac
import hashlib
import requests
import json
import random
merchant_id = 'XXXXXXXXX'
merchant_key = b'XXXXXXXXXXXXXXXXXX'
merchant_salt = 'XXXXXXXXXXXXXXXXXX'
merchant_oid = ''
hash_str = merchant_id + merchant_oid + merchant_salt
paytr_token = base64.b64encode(hmac.new(merchant_key, hash_str.encode(), hashlib.sha256).digest())
params = {
'merchant_id': merchant_id,
'merchant_oid': merchant_oid,
'paytr_token': paytr_token
}
result = requests.post('https://www.paytr.com/odeme/durum-sorgu', params)
res = json.loads(result.text)
if res['status'] == 'success':
print(res['payment_amount'] + res['currency'])
print(res['payment_total'] + res['currency'])
for return_success in res['returns']:
print(return_success)
for sub_payments in res['submerchant_payments']:
print(sub_payments)
else:
print(res['err_no'] + ' ' + res['err_msg'])
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Collections.Specialized;
using System.Net;
using System.Security.Cryptography;
using System.Text;
using System.Web.Script.Serialization;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Routing;
using System.IO;
namespace WebApplication1.Controllers
{
public class durum_sorgu_platform_ornekController : Controller
{
public ActionResult durum_sorgu_platform_ornek()
{
string merchant_id = "YYYYYY";
string merchant_key = "YYYYYYYYYYYYYY";
string merchant_salt = "YYYYYYYYYYYYYY";
string merchant_oid = "";
string Birlestir = string.Concat(merchant_id, merchant_oid, merchant_salt);
HMACSHA256 hmac = new HMACSHA256(Encoding.UTF8.GetBytes(merchant_key));
byte[] b = hmac.ComputeHash(Encoding.UTF8.GetBytes(Birlestir));
string paytr_token = Convert.ToBase64String(b);
NameValueCollection data = new NameValueCollection();
data["merchant_id"] = merchant_id;
data["merchant_oid"] = merchant_oid;
data["paytr_token"] = paytr_token;
using (WebClient client = new WebClient())
{
client.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
byte[] result = client.UploadValues("https://www.paytr.com/odeme/durum-sorgu", "POST", data);
string ResultAuthTicket = Encoding.UTF8.GetString(result);
dynamic json = JValue.Parse(ResultAuthTicket);
if (json.status == "success")
{
Response.Write(json.payment_amount + "-" + json.currency);
Response.Write(json.payment_total + "-" + json.currency);
foreach (var return_success in json.returns)
{
Response.Write(return_success);
}
foreach (var sub_payments in json.submerchant_payments)
{
Response.Write(sub_payments);
}
}
else
{
Response.Write(json.err_no + "-" + json.err_msg);
}
}
return View();
}
}
}
var request = require('request');
var crypto = require('crypto');
var express = require('express');
var app = express();
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
var merchant_id = 'XXXXXXXXX';
var merchant_key = 'XXXXXXXXXXXXXXXXXX';
var merchant_salt = 'XXXXXXXXXXXXXXXXXX';
var merchant_oid = '';
app.get("/", function (req, res) {
var paytr_token = crypto.createHmac('sha256', merchant_key).update(merchant_id + merchant_oid + merchant_salt).digest('base64');
var options = {
'method': 'POST',
'url': 'https://www.paytr.com/odeme/durum-sorgu',
'headers': {
'Content-Type': 'application/x-www-form-urlencoded'
},
form: {
'merchant_id': merchant_id,
'merchant_oid': merchant_oid,
'paytr_token': paytr_token,
}
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
var res_data = JSON.parse(body);
if (res_data.status == 'success') {
res.send(res_data);
} else {
//hata durumu
console.log(response.body);
res.end(response.body);
}
});
});
var port = 3200;
app.listen(port, function () {
console.log("Server is running. Port:" + port);
});