Those are the services managing the entire refund process for the payments made through the Payguru Payment Platform. All the refund process should be started by the merchant using the API components described below. Order Code is the main identifier for all the transactions to be refunded.
It is the service enabling merchant to query Payguru Platform in order to access the refund details of a transaction by using the refund id generated by Payguru Platform and shared with the merchant beforehand.
https://api.payguru.com/phs/refund/get
GET or POST
Field | Type | Description |
---|---|---|
merchant | Integer - Required | Merchant ID |
token | String - Required | Token |
Field | Type | Description |
---|---|---|
id | Integer - Required | Refund ID |
Field | Type | Description |
---|---|---|
status | String | Status Code: 000 |
message | String | Message |
data | Array[] | Refund Detail |
-id | String | ID |
-merchant | String | Merchant ID |
-service | String | Service ID |
-service_code | String | Service ID |
-transaction_id | String | Transaction ID |
-status | String | Refund Status #See |
-create_time | String | Create Time |
-update_time | String | Update Time |
-refund_time | String | Refund Time |
-amount | String | Amount |
-refund_contact | String | Contact Name |
-refund_iban | String | Contact IBAN |
-bank_id | String | Bank ID |
-bank_name | String | Bank ID |
-bank_no | String | Bank ID |
-bank_receipt_no | String | Bank Receipt No |
Field | Type | Description |
---|---|---|
status | String | Status Code: #See |
message | String | Message |
{
"status": "000",
"message": "Success",
"data": {
"id": 13,
"merchant_name": "PAYGURU DEMO",
"merchant_id": 1,
"service_name": "DEMO",
"service_id": 4,
"transaction_id": 28120,
"status": 1,
"create_time": "2018-01-18 13:48:39",
"update_time": null,
"refund_time": null,
"amount": "0.50",
"update_userid": null,
"requested_by": null,
"description": null,
"note": null,
"refund_contact": "Erdinç Karaman",
"refund_iban": "TR800011100000000036888459",
"bank_id": null,
"bank_name": null,
"bank_code": null,
"bank_receipt_no": null
}
}
{
"status": "ERR_005",
"message": "Invalid Service"
}
curl -X GET -H "token: {3E53E639-5173-D1B6-9368-68FCBCF72342}" -H "merchant: 123" --globoff "https://api.payguru.com/phs/refund/get?id=12345"
<?php
$curl = curl_init();
$url = "https://api.payguru.com/phs/refund/get";
$data = [
"id"=>"12345",
];
$headers = [
"token: {3E53E639-5173-D1B6-9368-68FCBCF72342}",
"merchant: 123"
];
curl_setopt_array($curl, array(
CURLOPT_URL => $url."?".http_build_query($data),
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => $headers,
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
var client = new RestClient("https://api.payguru.com/phs/refund/get?id=12345");
var request = new RestRequest(Method.GET);
request.AddHeader("merchant", "123");
request.AddHeader("token", "{3E53E639-5173-D1B6-9368-68FCBCF72342}");
IRestResponse response = client.Execute(request);
var o = JObject.Parse(response);
if (o["status"] == "000") {
MessageBox.Show((string)o["data"]["id"]);
} else {
MessageBox.Show((string)o["message"]);
}
import requests,json
url = "https://api.payguru.com/phs/refund/get"
querystring = {"id":"12345"}
headers = {
"token": "{3E53E639-5173-D1B6-9368-68FCBCF72342}",
"merchant": "123"
}
response = requests.request("GET", url, headers=headers, params=querystring)
if response.status_code == 200:
o = json.loads(response.text)
if o["status"] == "000":
print o["data"]["id"]
else:
print o["message"]
else:
print "Request Error"
It is basically the same service as the GET but using the order code instead of refund id. It enables the merchant to query the refund status of a particular order that could consist of more than one sub-orders, mainly in Market Place implementations. Since a unique order id may consist of multiple purchases from multiple sub-merchants under the same market place, this query may bring more than one refund records.
https://api.payguru.com/phs/refund/getByOrder
GET or POST
Field | Type | Description |
---|---|---|
merchant | Integer - Required | Merchant ID |
token | String - Required | Token |
Field | Type | Description |
---|---|---|
order | String - Required | Merchant Order |
Field | Type | Description |
---|---|---|
status | String | Status Code: 000 |
message | String | Message |
data | Array[] | Refunds Detail |
-id | String | ID |
-merchant | String | Merchant ID |
-service | String | Service ID |
-service_code | String | Service ID |
-transaction_id | String | Transaction ID |
-status | String | Refund Status #See |
-create_time | String | Create Time |
-update_time | String | Update Time |
-refund_time | String | Refund Time |
-amount | String | Amount |
-refund_contact | String | Contact Name |
-refund_iban | String | Contact IBAN |
-bank_id | String | Bank ID |
-bank_name | String | Bank ID |
-bank_no | String | Bank ID |
-bank_receipt_no | String | Bank Receipt No |
Field | Type | Description |
---|---|---|
status | String | Status Code: #See |
message | String | Message |
{
"status": "000",
"message": "Success",
"data": [
{
"id": 13,
"merchant_name": "PAYGURU DEMO",
"merchant_id": 1,
"service_name": "DEMO",
"service_id": 4,
"transaction_id": 28120,
"status": 1,
"create_time": "2018-01-18 13:48:39",
"update_time": null,
"refund_time": null,
"amount": "0.50",
"requested_by": null,
"description": null,
"note": null,
"refund_contact": "Payguru Test",
"refund_iban": "TR12345678",
"bank_id": null,
"bank_name": null,
"bank_code": null,
"bank_receipt_no": null
},
{
"id": 14,
"merchant_name": "PAYGURU DEMO",
"merchant_id": 1,
"service_name": "DEMO",
"service_id": 4,
"transaction_id": 28120,
"status": 2,
"create_time": "2018-01-18 15:09:08",
"update_time": "2018-01-19 15:09:08",
"refund_time": null,
"amount": "0.40",
"requested_by": null,
"description": null,
"note": null,
"refund_contact": "Payguru Test",
"refund_iban": "TR12345678",
"bank_id": null,
"bank_name": null,
"bank_code": null,
"bank_receipt_no": null
},
{
"id": 15,
"merchant_name": "PAYGURU DEMO",
"merchant_id": 1,
"service_name": "DEMO",
"service_id": 4,
"transaction_id": 28120,
"status": 3,
"create_time": "2018-01-18 15:09:08",
"update_time": "2018-01-19 15:09:08",
"refund_time": "2018-01-19 09:00:00",
"amount": "5",
"requested_by": null,
"description": "Complated at 09:00",
"note": null,
"refund_contact": "Payguru Test",
"refund_iban": "TR12345678",
"bank_id": 1,
"bank_name": "Ziraat",
"bank_code": "ziraatbank",
"bank_receipt_no": "DEKONT1234"
}
]
}
{
"status": "ERR_005",
"message": "Invalid Service"
}
curl -X GET -H "token: {3E53E639-5173-D1B6-9368-68FCBCF72342}" -H "merchant: 123" --globoff "https://api.payguru.com/phs/refund/getByOrder?order=12345"
<?php
$curl = curl_init();
$url = "https://api.payguru.com/phs/refund/getByOrder";
$data = [
"order"=>"12345",
];
$headers = [
"token: {3E53E639-5173-D1B6-9368-68FCBCF72342}",
"merchant: 123"
];
curl_setopt_array($curl, array(
CURLOPT_URL => $url."?".http_build_query($data),
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => $headers,
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
var client = new RestClient("https://api.payguru.com/phs/refund/getByOrder?order=12345");
var request = new RestRequest(Method.GET);
request.AddHeader("merchant", "123");
request.AddHeader("token", "{3E53E639-5173-D1B6-9368-68FCBCF72342}");
IRestResponse response = client.Execute(request);
var o = JObject.Parse(response);
if (o["status"] == "000") {
MessageBox.Show((string)o["transaction"]["id"]);
} else {
MessageBox.Show((string)o["message"]);
}
import requests,json
url = "https://api.payguru.com/phs/refund/getByOrder"
querystring = {"order":"12345"}
headers = {
"token": "{3E53E639-5173-D1B6-9368-68FCBCF72342}",
"merchant": "123"
}
response = requests.request("GET", url, headers=headers, params=querystring)
if response.status_code == 200:
o = json.loads(response.text)
if o["status"] == "000":
print o["data"][0]["id"]
else:
print o["message"]
else:
print "Request Error"
It is the web service that creates a refund request. Merchant is expected to call this service to start a refund process for the transactions that are not "completed" or for the "purchase orders not fullfilled" yet.
https://api.payguru.com/phs/refund/create
GET or POST
Field | Type | Description |
---|---|---|
merchant | Integer - Required | Merchant ID |
token | String - Required | Token |
Field | Type | Description |
---|---|---|
code | String - Required | Service Code |
amount | String - Required | Amount |
order | String - Required | Merchant Order |
contact | Array[] - Required | Contact Fields |
-name | String - Required | Name |
-iban | String - Required | IBAN |
Field | Type | Description |
---|---|---|
status | String | Status Code: 000 |
message | String | Message |
refund_id | Integer | Payguru Refund ID |
Field | Type | Description |
---|---|---|
status | String | Status Code: #See |
message | String | Message |
{
"status": "000",
"message": "Success",
"refund_id": "123412345678",
}
{
"status": "ERR_005",
"message": "Invalid Service"
}
curl -X GET -H "token: {3E53E639-5173-D1B6-9368-68FCBCF72342}" -H "merchant: 123" --globoff "https://api.payguru.com/phs/refund/create?code=XXX&order=ORDER&contact[name]=Qwe ASD&contact[iban]=TR12345671234567&amount=1.00"
<?php
$curl = curl_init();
$url = "https://api.payguru.com/phs/refund/create";
$data = [
"code"=>"XXX",
"order"=>"ORDER",
"contact"=>["name"=>"Qwe ASD","iban"=>"TR12345671234567"],
"amount"=>1.00,
];
$headers = [
"token: {3E53E639-5173-D1B6-9368-68FCBCF72342}",
"merchant: 123"
];
curl_setopt_array($curl, array(
CURLOPT_URL => $url."?".http_build_query($data),
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => $headers,
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo json_decode($response,true)["refund_id"];
}
var client = new RestClient("https://api.payguru.com/phs/refund/create?code=XXX&order=ORDER&contact[name]=QweASD&contact[iban]=TR12345671234567&amount=1.00");
var request = new RestRequest(Method.GET);
request.AddHeader("merchant", "123");
request.AddHeader("token", "{3E53E639-5173-D1B6-9368-68FCBCF72342}");
IRestResponse response = client.Execute(request);
var o = JObject.Parse(response);
if (o["status"] == "000") {
MessageBox.Show((string)o["refund_id"]);
} else {
MessageBox.Show((string)o["message"]);
}
import requests,json
url = "https://api.payguru.com/phs/refund/create"
querystring = {"code":"XXX","order":"ORDER","contact[name]":"Qwe ASD","contact[iban]":"TR12345671234567","amount":"1.00"}
headers = {
"token": "{3E53E639-5173-D1B6-9368-68FCBCF72342}",
"merchant": "123"
}
response = requests.request("GET", url, headers=headers, params=querystring)
if response.status_code == 200:
o = json.loads(response.text)
if o["status"] == "000":
print o["data"][0]["id"]
else:
print o["message"]
else:
print "Request Error"
This service is used to transmit the results to the merchant of all the refund requests within a day. All the refunds made during that day are sent to the merchant with a single call to the notification url on the merchant platform.
http://yoursite.com/PhsRefundNotifyService
GET or POST/JSON
Notify Key: md5( Service code + Merchant ID + Refund ID + Payguru Reference Code(Code In Request) + Order RefNo + Amount + Bank Code + Merchant Private Key + Service Private Key)
Field | Type | Description |
---|---|---|
refund_id | Integer | Refund ID |
code | String | Payguru Order |
order | String | Merchant Order |
status | Integer | Refund Status #See |
amount | Float | Refund Amount |
refund_contact | String | Refund Contact Name |
refund_iban | String | Refund Contact IBAN |
refund_date | Date | Refund Date |
create_time | Date | Refund Request Date |
bank_no | Integer | Bank No |
bank_id | Integer | Bank ID |
bank_name | String | Bank Name |
bank_code | String | Bank Code |
bank_receipt_no | String - Required | Bank Receipt No |
key | String - Required | Refund Notify Key #See |
<?
$data = $_GET;
//$data["refund_id"] = Refund ID
//$data["code"] = Transaction Code
//$data["order"] = Order Refno
//$data["status"] = Refund Status
//$data["amount"] = Refund Amount
//$data["refund_contact"] = Refund Contact Name
//$data["refund_iban"] = Refund Contact IBAN
//$data["refund_date"] = Refund Date
//$data["create_time"] = Refund Request Date
//$data["bank_no"] = Bank No
//$data["bank_id"] = Bank ID
//$data["bank_name"] = Bank Name
//$data["bank_code"] = Bank Code
//$data["bank_receipt_no"] = Bank Receipt No
//$data["key"] = Notify Key
$localKey = md5("Service Code"."Merchant ID".$data["refund_id"].$data["code"].$data["order"].$data["amount"].$data["bank_code"]."Merchant Private Key"."Service Private Key");
if($localKey = $data["key"]){
echo "OK";//If you accept this request, you must response with "OK"
//find transaction with order
}else{
echo "Wrong Data";
}
<?
$data = json_decode(file_get_contents("php://input"),true);
//$data["refund_id"] = Refund ID
//$data["code"] = Transaction Code
//$data["order"] = Order Refno
//$data["status"] = Refund Status
//$data["amount"] = Refund Amount
//$data["refund_contact"] = Refund Contact Name
//$data["refund_iban"] = Refund Contact IBAN
//$data["refund_date"] = Refund Date
//$data["create_time"] = Refund Request Date
//$data["bank_no"] = Bank No
//$data["bank_id"] = Bank ID
//$data["bank_name"] = Bank Name
//$data["bank_code"] = Bank Code
//$data["bank_receipt_no"] = Bank Receipt No
//$data["key"] = Notify Key
$localKey = md5("Service Code"."Merchant ID".$data["refund_id"].$data["code"].$data["order"].$data["amount"].$data["bank_code"]."Merchant Private Key"."Service Private Key");
if($localKey = $data["key"]){
echo "OK";//If you accept this request, you must response with "OK"
//find transaction with order
}else{
echo "Wrong Data";
}