1. Go to this page and download the library: Download andreas22/omnipay-fasapay 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/ */
andreas22 / omnipay-fasapay example snippets
use Omnipay\Omnipay;
$gateway = Omnipay::create('Fasapay');
// Example form data
$purchaseOptions = array(
'accountTo' => 'FPX6553',
'accountFrom' => 'FPX6685',
'item' => 'MyItem',
'amount' => 1000.0,
'currency' => 'IDR',
'comments' => 'No comment',
'transactionId' => '1311059195',
'returnUrl' => 'http://requestb.in/zo1agozo', //Success url
'successMethod' => 'GET',
'cancelUrl' => 'http://requestb.in/zo1agozo', //Cancel url
'failMethod' => 'GET',
'notifyUrl' => 'http://requestb.in/1l8z6pl1', //Callback url - server to server
'statusMethod' => 'POST',
);
$response = $gateway->purchase($purchaseOptions)->setTestMode(true)->send();
// Process response
if ($response->isSuccessful()) {
// Payment was successful
echo 'SUCCESS';
}
elseif ($response->isRedirect()) {
// Redirect to offsite payment gateway
$response->redirect();
}
else {
// Payment failed
echo 'FAILED :: ' .$response->getMessage();
}
use Omnipay\Omnipay;
$gateway = Omnipay::create('Fasapay');
// Send purchase request
$response = $gateway->completePurchase()->send();
// Process response
if ($response->isSuccessful())
{
echo '[success] TransactionReference=' . $response->getTransactionReference();
}
else
{
echo 'Fail';
}
use Omnipay\Omnipay;
$gateway = Omnipay::create('Fasapay');
// Example form data
$purchaseOptions = array(
'accountTo' => 'FPX6553', //Client that will send you the money
'store' => 'MyStore',
'item' => 'MyItem',
'amount' => 1000.0,
'currency' => 'IDR',
'comments' => 'No comment',
'transactionId' => '1311059195',
);
$response = $gateway->purchase($purchaseOptions)->setTestMode(true)->send();
// Process response
if ($response->isSuccessful()) {
// Payment was successful
echo 'SUCCESS';
}
elseif ($response->isRedirect()) {
// Redirect to offsite payment gateway
$response->redirect();
}
else {
// Payment failed
echo 'FAILED :: ' .$response->getMessage();
}