Refund

Payguru Platformuna yapılmış olan ödemelerin yine Payguru Platformu aracılığı ile iade ve geri ödemelerini gerçekleştiren servislerdir. Payguru platformundaki tüm iade süreçleri, aşağıdaki API bileşenleri kullanılarak üye işyeri tarafından başlatılır ve tüm entegrasyonda İşlem Kodu ana taşıyıcı bilgi parçası olarak kullanılır.

Pazaryeri uygulamalarında gerekli olacak "parçalı iade" yapısı temel olarak aynı bileşenleri içerse de gerekli olan ekstra parametreler ve bigliler entagrasyon sürecinde Payguru tarafından üye iş yeri ile paylaşılacaktır

Get

Payguru tarafından iade sürecinde her bir iade işlemi için ayrı ayrı yaratılmış ve üye iş yeri ile paylaşılmış olan iade kodu (refund id) kullanılarak söz konusu iade işlemi ile ilgili detay bilgilerin üye iş yeri tarafından sorgulanmasını sağlayan servistir.

>URL
 https://api.payguru.com/phs/refund/get
>HTTP Method
GET yada POST
>Headers
FieldTypeDescription
merchantInteger - RequiredMerchant ID
tokenString - RequiredToken
>Parameters
FieldTypeDescription
idInteger - RequiredRefund ID

>Success
FieldTypeDescription
statusStringStatus Code: 000
messageStringMessage
dataArray[]Refund Detail
-idStringID
-merchantStringMerchant ID
-serviceStringService ID
-service_codeStringService ID
-transaction_idStringTransaction ID
-statusStringRefund Status #See
-create_timeStringCreate Time
-update_timeStringUpdate Time
-refund_timeStringRefund Time
-amountStringAmount
-refund_contactStringContact Name
-refund_ibanStringContact IBAN
-bank_idStringBank ID
-bank_nameStringBank ID
-bank_noStringBank ID
-bank_receipt_noStringBank Receipt No

>Error
FieldTypeDescription
statusStringStatus Code: #See
messageStringMessage

>Örnek Cevaplar
{
    "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"
}

>Örnek Kodlar
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"

Get By Order

Payguru tarafından iade sürecine sokulmuş tüm sipariş ve işlemlerin işlem kodu (order) aracılığı ile üye iş yeri tarafından sorgulanmasına imkan veren servistir. Pazar yeri uygulamalarında aynı işlem kodu birden fazla alt üye iş yerinin birden fazla siparişini içerebileceğinden sorgulama sonucu birden fazla iade işlemi olabilir.

>URL
 https://api.payguru.com/phs/refund/getByOrder
>HTTP Method
GET yada POST
>Headers
FieldTypeDescription
merchantInteger - RequiredMerchant ID
tokenString - RequiredToken
>Parameters
FieldTypeDescription
orderString - RequiredMerchant Order

>Success
FieldTypeDescription
statusStringStatus Code: 000
messageStringMessage
dataArray[]Refunds Detail
-idStringID
-merchantStringMerchant ID
-serviceStringService ID
-service_codeStringService ID
-transaction_idStringTransaction ID
-statusStringRefund Status #See
-create_timeStringCreate Time
-update_timeStringUpdate Time
-refund_timeStringRefund Time
-amountStringAmount
-refund_contactStringContact Name
-refund_ibanStringContact IBAN
-bank_idStringBank ID
-bank_nameStringBank ID
-bank_noStringBank ID
-bank_receipt_noStringBank Receipt No

>Error
FieldTypeDescription
statusStringStatus Code: #See
messageStringMessage

>Örnek Cevaplar
{
    "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"
}

>Örnek Kodlar
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"

Create

Üye iş yeri tarafından Payguru platformunda gerçekleşmiş ve "henüz kapatılmamış veya ilgili tedarik süreci henüz finalize olmamış" ödeme işlemlerinin iade süreçlerini başlatan web servisidir.

>URL
 https://api.payguru.com/phs/refund/create
>HTTP Method
GET yada POST
>Headers
FieldTypeDescription
merchantInteger - RequiredMerchant ID
tokenString - RequiredToken
>Parameters
FieldTypeDescription
codeString - RequiredService Code
amountString - RequiredAmount
orderString - RequiredMerchant Order
contactArray[] - RequiredContact Fields
-nameString - RequiredName
-ibanString - RequiredIBAN

>Success
FieldTypeDescription
statusStringStatus Code: 000
messageStringMessage
refund_idIntegerPayguru Refund ID

>Error
FieldTypeDescription
statusStringStatus Code: #See
messageStringMessage

>Örnek Cevaplar
{
    "status": "000",
    "message": "Success",
    "refund_id": "123412345678",
}
{
    "status": "ERR_005",
    "message": "Invalid Service"
}

>Örnek Kodlar
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"

Refund Notification

Gün sonunda her bir iade talebinin sonucunu toplu olarak üye iş yerine ileten bildirim servisidir. Banka aracılığıyla Payguru platformundan yapılan iadelerin tamamının durumunu üye iş yerine bildirir.

>URL
 http://yoursite.com/PhsRefundNotifyService
>HTTP Method
GET yada 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)

>Parameters
FieldTypeDescription
refund_idIntegerRefund ID
codeStringPayguru Order
orderStringMerchant Order
statusIntegerRefund Status #See
amountFloatRefund Amount
refund_contactStringRefund Contact Name
refund_ibanStringRefund Contact IBAN
refund_dateDateRefund Date
create_timeDateRefund Request Date
bank_noIntegerBank No
bank_idIntegerBank ID
bank_nameStringBank Name
bank_codeStringBank Code
bank_receipt_noString - RequiredBank Receipt No
keyString - RequiredRefund Notify Key #See

>Örnek Kodlar
<?
$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";
}