Get started

The Playsultan Merchant API provides payment gateway to sell your products or your services via online.

To use this API, you need an API key and API Passwords. Please contact us at [email protected] to get your own API key and API passwords.

HASH Calculation

The Playsultan Merchant API using HMAC-SHA256 standard for all operation.

You need generate hmac hash required string with API key and API Passwords and convert it base64 before Post to API endpoint.

GET TOKEN


# Here is a php example
$playsultan_api_key = 'XXXXXXXXXX';//your api key on Playsultan Merchant API
$playsultan_api_password = 'XXXXXXXXXX';//your api password on Playsultan Merchant API
$playsultan_merchant_id = 135711;//your site ID on Playsultan Merchant API
$user_ip = 'XXX.XXX.XXX.XX';//user current ip
$user_mail = '[email protected]';//user mail adress
$user_id = 123456;//user unique id
$user_name = 'myusername';//user name in your site

$hash = base64_encode(hash_hmac('sha256', $playsultan_merchant_id.$user_mail.$user_ip.$user_id.$user_name.$playsultan_api_key, $playsultan_api_password, true));

$post_vals = array(
  'merchant_id' => $playsultan_merchant_id,
  'apikey' => $playsultan_api_key,
  'user_ip' => $user_ip,
  'user_mail' => $user_mail,
  'user_id' => $user_id,
  'user_name' => $user_name,
  'hash' => $hash
);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $playsultan_api_end_point);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1) ;
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_vals);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_FRESH_CONNECT, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
$result = curl_exec($ch);  	
$curl_error = curl_errno($ch);
curl_close($ch);

$result = json_decode($result,1);
if($result['status'] == 'success' && $result['url']){//response success
  header("Location: ".$result['url']);
}else{
  echo 'Error!! '.$result['hata']; 
}  


#Response Success Example:
{"status":"success","url":"http:\/\/www.playsultan.com\/merchant\/api\/index.php?t=XXXXXXXXXXXXXXXXXXXXX"}

#Response Error Example:
{"status":"failed","hata":"Authorized IP address required"}

API Endpoint:

https://www.playsultan.com/merchant/api/token.php

Request Method:

POST

Response Type:

Json Array

QUERY PARAMETERS

Field Type Description Required
apikey String Your Playsultan Merchant API Key required
merchant_id Integer Your Site İd required
user_id String Unique identifier of your customer. required
user_name String Registered user name of your customer. required
user_mail String Registered mail adress of your customer. required
user_ip String Current IP Adress of your customer while start transaction. required
hash String Generated hmac hash with described string. required

1 - Calculate hash with required parameters.
2 - POST all required data to API endpoint.
3 - if response success, redirect user to url (in response json).
Check example

INSTANT PAYMENT NOTIFICATION (IPN)


# Here is a php example
# this only simple example. you must need sanitize post data and check required data before use.

$playsultan_api_key = 'XXXXXXXXXX';//your api key on Playsultan Merchant API
$playsultan_api_password = 'XXXXXXXXXX';//your api password on Playsultan Merchant API
$playsultan_merchant_id = 135711;//your site ID on Playsultan Merchant API

$order_id = $_POST['order_id'];
$merchant_id = $_POST['merchant_id'];
$user_id = $_POST['user_id'];
$user_name = $_POST['user_name'];
$user_mail = $_POST['user_mail'];
$payment_type = $_POST['payment_type'];
$amount = $_POST['amount'];
$charge_amount = $_POST['charge_amount'];
$net_amount = $_POST['net_amount'];
$status = $_POST['status'];
$hash = $_POST['hash'];

$hash_kontrol = base64_encode(hash_hmac('sha256',$merchant_id.$order_id.$user_id.$user_name.$user_mail.$payment_type.$amount.$charge_amount.$net_amount.$status.$playsultan_api_key, $playsultan_api_password, true));
if($hash != $hash_kontrol) die('Hash failure');//hash not equal
#otherwise you can finish order.

Notification Url:

Described from Playsultan Merchant Api user panel

Request Method:

POST

Response Type:

You must response only OK.

Playsultan Merchant API wait for OK. if your page don't response or response other type/text etc. it's mean not response.

After 10 failure response, API stop send request.

POST PARAMETERS

Field Type Description Required
merchant_id Integer Your Site İd required
order_id integer Transaction's Unique order id on Playsultan Merchant API required
user_id integer Sending user id data in get token step required
user_name String Sending user name data in get token step required
user_mail String Sending user mail data in get token step required
payment_type String Payment type in transaction required
amount Float Payment amount in transaction required
charge_amount Float added amount in your user account required
net_amount Float Total amount in your Playsultan Merchant account after commissions required
status String Transaction status (success|failed|pending) required
hash String Generated hmac hash with described string. required

payment_type İnformation

name Description
kk Credit Card
eft Bank Transfer / EFT
mb Mobile Payment
bit Crypto
papara Papara Wallet

1 - Check all required info from POST request.
2 - Calculate hash with required parameters.
3 - if hash validated, you can go complete order.
Check example

Errors



#Response Error Example:
{"status":"failed","hata":"Authorized IP address required"}

The Playsultan Merchant API return all errors with "hata" field in response json data:

API INFO

Version 1.0.