1. Go to this page and download the library: Download fasterpay/fasterpay-php library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
fasterpay / fasterpay-php example snippets
y = new FasterPay\Gateway([
'publicKey' => '<your-public-key>',
'privateKey' => '<your-private-key>',
'isTest' => 0, // Use 1 for Test Method
]);
$form = $gateway->paymentForm()->buildForm(
[
'description' => 'Test order',
'amount' => '10',
'currency' => 'USD',
'merchant_order_id' => time(),
'success_url' => 'https://yourcompanywebsite.com/success',
'pingback_url' => 'https://yourcompanywebsite.com/pingback',
'sign_version' => 'v2' // to use version 1 please skip this param or set it 'v1'
],
[
'autoSubmit' => false,
'hidePayButton' => false
]
);
echo $form;
y = new FasterPay\Gateway([
'publicKey' => '<your-public-key>',
'privateKey' => '<your-private-key>',
'isTest' => 0, // Use 1 for Test Mode
]);
$signVersion = \FasterPay\Services\Signature::SIGN_VERSION_1;
if (!empty($_SERVER['HTTP_X_FASTERPAY_SIGNATURE_VERSION'])) {
$signVersion = $_SERVER['HTTP_X_FASTERPAY_SIGNATURE_VERSION'];
}
$pingbackData = null;
$validationParams = [];
switch ($signVersion) {
case \FasterPay\Services\Signature::SIGN_VERSION_1:
$validationParams = ["apiKey" => $_SERVER["HTTP_X_APIKEY"]];
$pingbackData = $_REQUEST;
break;
case \FasterPay\Services\Signature::SIGN_VERSION_2:
$validationParams = [
'pingbackData' => file_get_contents('php://input'),
'signVersion' => $signVersion,
'signature' => $_SERVER["HTTP_X_FASTERPAY_SIGNATURE"],
];
$pingbackData = json_decode(file_get_contents('php://input'), 1);
break;
default:
exit('NOK');
}
if (empty($pingbackData)) {
exit('NOK');
}
if (!$gateway->pingback()->validate($validationParams)) {
exit('NOK');
}
//echo "<pre>";
//print_r($pingbackData);
//echo '</pre>';
#TODO: Write your code to deliver contents to the End-User.
echo "OK";
exit();
y = new FasterPay\Gateway([
'publicKey' => '<your-public-key>',
'privateKey' => '<your-private-key>',
'isTest' => 1
]);
sh
$ cp fasterpay-php path-to-project/lib/fasterpay-php
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.