PHP code example of itsfaqih / faspay

1. Go to this page and download the library: Download itsfaqih/faspay 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/ */

    

itsfaqih / faspay example snippets


use ItsFaqih\Faspay\Client;
use ItsFaqih\Faspay\Entities\User;
use ItsFaqih\Faspay\Enums\Environment;

$user = new User('bot98765', 'p@ssw0rd', '98765', 'FASPAY');

$faspayClient = new Client($user, Environment::DEVELOPMENT());

$faspayClient->paymentChannelInquiry();

use ItsFaqih\Faspay\Entities\Bill;
use ItsFaqih\Faspay\Entities\BillItem;
use ItsFaqih\Faspay\Entities\Customer;
use ItsFaqih\Faspay\Entities\Payment;
use ItsFaqih\Faspay\Enums\PaymentChannel;
use ItsFaqih\Faspay\Enums\PaymentType;

$bill = new Bill('TRX-123', new \DateTime(), (new \DateTime())->modify('+1 day'), 'Red Shoes with special price', '250000');
$payment = new Payment(PaymentChannel::LINKAJA(), PaymentType::FULL_SETTLEMENT());
$customer = new Customer('001', 'John Smith', '08123456789', '[email protected]');
$item = new BillItem('Red Shoes', 1, '250000');

$faspayClient->postDataTransaction($bill, $payment, $customer, [$item]);

$trxId = '9876530200004184';
$billNo = 'TRX-123';

$faspayClient->inquiryPaymentStatus($trxId, $billNo);

$trxId = '9876530200004184';
$billNo = 'TRX-123';
$reason = 'Wrong order';

$faspayClient->cancelTransaction($trxId, $billNo, $reason);