itsfaqih/faspay

Unofficial Faspay SDK

Fund package maintenance!
itsfaqih

0.5.0 2022-07-10 15:22 UTC

README

Latest Version on Packagist Tests Total Downloads

Installation

You can install the package via composer:

composer require itsfaqih/faspay

Usage

Configure the credentials and the client.

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());

Payment Channel Inquiry

$faspayClient->paymentChannelInquiry();

Post Data Transaction

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', 'john.smith@example.com');
$item = new BillItem('Red Shoes', 1, '250000');

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

Inquiry Payment Status

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

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

Cancel Transaction

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

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

Testing

composer test

License

The MIT License (MIT). Please see License File for more information.