Payment Statement
You can access the payment statement of the amounts transferred or to be transferred to the merchant account within the transmitted date range.
It is divided into two categories as Merchant Payment Statement and Marketplace Payment Statement.
Merchant Payment Statement
1- Send the date range you want to see the payment details to https://www.paytr.com/rapor/odeme-dokumu/ via POST method.
| Field name |
Explanation |
| merchant_id |
Merchant No |
| start_date |
Start Date:Date Format: 2022-01-01 (YYYY-MM-DD) |
| end_date |
End Date:Date Format: 2022-01-01 (YYYY-MM-DD ) |
| paytr_token |
You should look at the example codes. |
2- Your response to this request is returned in JSON format.
a. If there is no transaction within the given date duration, the status value returns failed.
b. If there is a transaction within the given date duration the status value returns as "success" with the information in the table below returns.
c. If there is any mistake in the request, the status value returns "error". In this case, you should check the "err_msg" for error details.
When the status value is “successful", the returned values are in the table below.
| Field name |
Explanation |
Values |
| date_paid |
Payment Date |
e.g. 2022-02-07 |
| currency |
Currency |
e.g. TL |
| sales |
Total sales amount |
e.g. 950.95 |
| return |
Total refund amount |
e.g. 12.64 |
| net |
Net amount transferred |
e.g. 938.31 |
| merchant_iban |
Merchant IBAN number |
e.g. TR00000000000000000000000000 |
| currency |
Currency |
e.g. TL, USD |
Could you please translate this? You can handle the data block containing your future payments under the name 'future_payments.' Inside future_payments, in addition to the fields specified below, you can access the date and currency type values.
| Field name |
Explanation |
Values |
| net_amounts |
Net amount |
500 |
| sale_amounts |
Sales amount |
500 |
| return_amounts |
Refund amount |
150 |
Payment statement sample codes: It is explained in detail in the sample codes.
<?php
$merchant_id = 'XXXXXX';
$merchant_key = 'XXXXXX';
$merchant_salt = 'XXXXXX';
#
$start_date = "2022-09-01";
$end_date = "2022-09-31";
#
############################################################################################
$paytr_token = base64_encode(hash_hmac('sha256', $merchant_id . $start_date . $end_date . $merchant_salt, $merchant_key, true));
$post_vals = array('merchant_id' => $merchant_id,
'start_date' => $start_date,
'end_date' => $end_date,
'paytr_token' => $paytr_token
);
#
############################################################################################
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://www.paytr.com/rapor/odeme-dokumu/");
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);
echo "<pre>";
$result = json_decode($result, 1);
if ($result['status'] == 'success')
{
print_r($result);
}
elseif ($result['status'] == 'failed')
{
echo "No payment statement was found in the relevant date range";
}
else
{
echo $result['err_no'] . " - " . $result['err_msg'];
}
# Python 3.6+
import base64
import hmac
import hashlib
import requests
import json
merchant_id = 'XXXXXX'
merchant_key = 'XXXXXX'
merchant_salt = 'XXXXXX'
start_date = '2022-09-01'
end_date = '2022-09-31'
hash_str = merchant_id + start_date + end_date + merchant_salt
paytr_token = base64.b64encode(hmac.new(merchant_key, hash_str.encode(), hashlib.sha256).digest())
params = {
'merchant_id': merchant_id,
'start_date': start_date,
'end_date': end_date,
'paytr_token': paytr_token
}
result = requests.post('https://www.paytr.com/rapor/odeme-dokumu', params)
res = json.loads(result.text)
if res['status'] == 'success':
print(result.text)
elif res['status'] == 'failed':
print('ilgili tariht aralıgında odeme ozeti bulunamadi')
else:
print('Error: ' + 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;
namespace WebApplication1.Controllers
{
public class TransactionDetailController : Controller
{
public ActionResult TransactionDetail()
{
string merchant_id = "AAAAAA";
string merchant_key = "XXXXXXXXXXXXXXXX";
string merchant_salt = "XXXXXXXXXXXXXXXX";
//
string start_date = "2022-09-01";
string end_date = "2022-09-31";
string Birlestir = string.Concat(merchant_id, start_date, end_date, 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["start_date"] = start_date;
data["end_date"] = end_date;
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/rapor/odeme-dokumu", "POST", data);
string ResultAuthTicket = Encoding.UTF8.GetString(result);
dynamic json = JValue.Parse(ResultAuthTicket);
if (json.status == "success")
{
Response.Write(json);
}
else if (json.status == "failed")
{
Response.Write("No payment statement was found in the relevant date range");
}
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 = '';
var merchant_key = '';
var merchant_salt = '';
app.get("/", function (req, res) {
var start_date = '2022-09-01';
var end_date = '2022-09-31';
var paytr_token = crypto.createHmac('sha256', merchant_key).update(merchant_id + start_date + end_date + merchant_salt).digest('base64');
var options = {
'method': 'POST',
'url': 'https://www.paytr.com/rapor/odeme-dokumu',
'headers': {
'Content-Type': 'application/x-www-form-urlencoded'
},
form: {
'merchant_id': merchant_id,
'start_date': start_date,
'end_date': end_date,
'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 {
res.end(response.body);
}
});
});
var port = 3200;
app.listen(port, function () {
console.log("Server is running. Port:" + port);
});
Marketplace Payment Statement
1- Send the date you want to see the payment details to https://www.paytr.com/rapor/odeme-dokumu/ via POST method.
| Field name |
Explanation |
| merchant_id |
Merchant No |
| start_date |
Start Date:Date Format: 2022-01-01 (YYYY-MM-DD) |
| end_date |
End Date:Date Format: 2022-01-01 (YYYY-MM-DD ) |
| paytr_token |
You should look at the example codes. |
2- Your response to this request is returned in JSON format.
a. If there is no transaction within the given date duration, the status value returns failed.
b. If there is a transaction within the given date duration the status value returns as "success" with the information in the table below returns.
c. If there is any mistake in the request, the status value returns "error". In this case, you should check the "err_msg" for error details.
When the status value is “successful", the returned values are in the table below.
| Field name |
Explanation |
Values |
| date_paid |
Payment Date |
e.g. 2022-02-07 |
| currency |
Currency |
e.g. TL |
| sales |
Total sales amount |
e.g. 950.95 |
| return |
Total refund amount |
e.g. 12.64 |
| net |
Net amount transferred |
e.g. 938.31 |
| merchant_iban |
Merchant IBAN number |
e.g. TR000000000000000000000000000 |
| currency |
Currency |
e.g. TL, USD |
<?php
$merchant_id = 'XXXXXX';
$merchant_key = 'XXXXXX';
$merchant_salt = 'XXXXXX';
#
$start_date = "2022-09-01";
$end_date = "2022-09-31";
#
############################################################################################
$paytr_token = base64_encode(hash_hmac('sha256', $merchant_id . $start_date . $end_date . $merchant_salt, $merchant_key, true));
$post_vals = array('merchant_id' => $merchant_id,
'start_date' => $start_date,
'end_date' => $end_date,
'paytr_token' => $paytr_token
);
#
############################################################################################
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://www.paytr.com/rapor/odeme-dokumu/");
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);
echo "<pre>";
$result = json_decode($result, 1);
if ($result[status] == 'success')
{
print_r($result);
}
elseif ($result[status] == 'failed')
{
echo "No payment statement was found in the relevant date range.";
}
else
{
echo $result[err_no] . " - " . $result[err_msg];
}
# Python 3.6+
import base64
import hmac
import hashlib
import requests
import json
merchant_id = 'XXXXXX'
merchant_key = 'XXXXXX'
merchant_salt = 'XXXXXX'
start_date = '2022-09-01'
end_date = '2022-09-31'
hash_str = merchant_id + start_date + end_date + merchant_salt
paytr_token = base64.b64encode(hmac.new(merchant_key, hash_str.encode(), hashlib.sha256).digest())
params = {
'merchant_id': merchant_id,
'start_date': start_date,
'end_date': end_date,
'paytr_token': paytr_token
}
result = requests.post('https://www.paytr.com/rapor/odeme-dokumu', params)
res = json.loads(result.text)
if res['status'] == 'success':
print(result.text)
elif res['status'] == 'failed':
print('No payment statement was found in the relevant date range')
else:
print('Error: ' + 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;
namespace WebApplication1.Controllers
{
public class TransactionDetailController : Controller
{
public ActionResult TransactionDetail()
{
string merchant_id = "AAAAAA";
string merchant_key = "XXXXXXXXXXXXXXXX";
string merchant_salt = "XXXXXXXXXXXXXXXX";
//
string start_date = "2022-09-01";
string end_date = "2022-09-31";
string Birlestir = string.Concat(merchant_id, start_date, end_date, 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["start_date"] = start_date;
data["end_date"] = end_date;
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/rapor/odeme-dokumu", "POST", data);
string ResultAuthTicket = Encoding.UTF8.GetString(result);
dynamic json = JValue.Parse(ResultAuthTicket);
if (json.status == "success")
{
Response.Write(json);
}
else if (json.status == "failed")
{
Response.Write("No payment statement was found in the relevant date range");
}
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 = '';
var merchant_key = '';
var merchant_salt = '';
app.get("/", function (req, res) {
var start_date = '2022-09-01';
var end_date = '2022-09-31';
var paytr_token = crypto.createHmac('sha256', merchant_key).update(merchant_id + start_date + end_date + merchant_salt).digest('base64');
var options = {
'method': 'POST',
'url': 'https://www.paytr.com/rapor/odeme-dokumu',
'headers': {
'Content-Type': 'application/x-www-form-urlencoded'
},
form: {
'merchant_id': merchant_id,
'start_date': start_date,
'end_date': end_date,
'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 {
res.end(response.body);
}
});
});
var port = 3200;
app.listen(port, function () {
console.log("Server is running. Port:" + port);
});