API Integration Document
You must have API key, secret key and username information for authorization. You can find this information from Merchant Details page.
The data you submit must be in "URL-Encoded" format and the "Content-Type" header must be "application/x-www-form-urlencoded".
All data you send must have "apiKey", "apiUsername" and "requestHash" parameters. Please review the sample code below to understand how the "requestHash" value is calculated.
<?php
$ch = curl_init();
$apiKey = 'c2ab11a42be64ffb3fcfba06d2e16fdf';
$apiUsername = 'DemoUser';
$secretKey = '7218a378e6282c28a1aa93beb54a4efa';
$data = [
'apiKey' => $apiKey,
'apiUsername' => $apiUsername
];
$data['requestHash'] = hash('sha256', $apiKey . $apiUsername . $secretKey);
curl_setopt_array($ch, [
CURLOPT_URL => 'https://panel.fsfpay.com/api',
CURLOPT_HTTPHEADER => [
'Content-Type: application/x-www-form-urlencoded'
],
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POSTFIELDS => http_build_query($data)
]);
$response = curl_exec($ch);
$response = json_decode($response, true);
if($response['success']) {
print 'API Version: '.$response['apiVersion'];
}
else {
print 'API Error: '.$response['message'];
}
You can get merchant account balances with using API.
Request URL Address | https://panel.fsfpay.com/api/balances |
Response Format | JSON |
Sample Code:
<?php
$ch = curl_init();
$apiKey = 'c2ab11a42be64ffb3fcfba06d2e16fdf';
$apiUsername = 'DemoUser';
$secretKey = '7218a378e6282c28a1aa93beb54a4efa';
$data = [
'apiKey' => $apiKey,
'apiUsername' => $apiUsername
];
$data['requestHash'] = hash('sha256', $apiKey . $apiUsername . $secretKey);
curl_setopt_array($ch, [
CURLOPT_URL => 'https://panel.fsfpay.com/api/balances',
CURLOPT_HTTPHEADER => [
'Content-Type: application/x-www-form-urlencoded'
],
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POSTFIELDS => http_build_query($data)
]);
$response = curl_exec($ch);
$response = json_decode($response, true);
foreach($response['balances'] as $coin => $balance) {
print $coin.' Wallet Balance => '.$balance.'<br>';
}
You can create a payment transaction using the API. After the payment confirmation, a callback request will be sent to the "callbackUrl" field. Please read the "Handle The Callback Request" section.
Request URL Address | https://panel.fsfpay.com/api/payment |
Response Format | JSON |
Required Parameters | |
orderId | This field will be sent back to you with a callback request. |
Payer's Email Address | |
amount | Amount of Payment in Original Currency |
currency | Original Currency (USD, CAD, EUR...) |
cryptocurrency | Cryptocurrency (BTC, DOGE, ETH...) |
testmode | If you will use test mode, type 1, otherwise 0. |
callbackUrl | A callback request will be sent to this address after the payment. |
Optional Parameters | |
successRedirectUrl | You can set a link for forwarding after payment confirmation. |
language | You can set the language for the response and iframe. (en) |
Sample Code:
<?php
$ch = curl_init();
$apiKey = 'c2ab11a42be64ffb3fcfba06d2e16fdf';
$apiUsername = 'DemoUser';
$secretKey = '7218a378e6282c28a1aa93beb54a4efa';
/* You should fetch order details from database. */
$order = [
'id' => 10,
'customer_email' => 'johndoe@gmail.com',
'amount' => 100,
'currency' => 'USD'
];
$data = [
'apiKey' => $apiKey,
'apiUsername' => $apiUsername,
'orderId' => $order['id'],
'email' => $order['customer_email'],
'amount' => $order['amount'],
'currency' => $order['currency'],
'cryptocurrency' => 'BTC',
'testmode' => 0,
'callbackUrl' => 'https://example.com/payment/callback',
'successRedirectUrl' => 'https://example.com/payment/successful',
'language' => 'en'
];
$data['requestHash'] = hash('sha256', $apiKey . $apiUsername . $secretKey);
curl_setopt_array($ch, [
CURLOPT_URL => 'https://panel.fsfpay.com/api/payment',
CURLOPT_HTTPHEADER => [
'Content-Type: application/x-www-form-urlencoded'
],
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POSTFIELDS => http_build_query($data)
]);
$response = curl_exec($ch);
$response = json_decode($response, true);
if($response['success']) {
echo '<script src="'.$response['scriptUrl'].'"></script>';
}
else {
echo 'Payment Error: '.$response['message'];
}
Our system will send a callback request for the link you provided after payment confirmation. Request submission will continue until your website send "OK" text as response. You must validate the request with your secret key to be protected from fraud.
Sample Code:
<?php
if(isset($_POST['requestHash']) && $_POST['paymentStatus'] && $_POST['paymentStatus'] == 'successful') {
$apiKey = 'c2ab11a42be64ffb3fcfba06d2e16fdf';
$apiUsername = 'DemoUser';
$secretKey = '7218a378e6282c28a1aa93beb54a4efa';
if(hash('sha256', $apiKey . $apiUsername . $secretKey) === $_POST['requestHash']) {
$paymentId = $_POST['paymentId'];
/* You can use orderId to complete the order. */
$orderId = $_POST['orderId'];
$amount = $_POST['amount'];
$email = $_POST['email'];
$currency = $_POST['currency'];
$cryptocurrencyAmount = $_POST['cryptocurrencyAmount'];
$testmode = $_POST['testmode'];
die('OK');
}
}