Use Faspay as your payment gateway for your project? Then this package is for you. This is a laravel package to communicate with Faspay Payment Gateway API (currently only support DEBIT API)
To get started with Faspay, run this command or add the package to your composer.json
composer require rick20/faspay
After installing the Faspay package, register the Rick20\Faspay\FaspayServiceProvider in your config/app.php file.
Also, add the Faspay and Payment facade to the aliases array in your app configuration file:
'Faspay' => Rick20\Faspay\Facades\Faspay::class,
'Payment' => Rick20\Faspay\Facades\Payment::class,Finally publish the config file:
php artisan vendor:publish --provider="Rick20\Faspay\FaspayServiceProvider"
and change merchant_id, merchant_name, user_id, and password in the config/faspay.php with yours.
After all sets, use this Faspay package as follows:
// Customer class example. You can apply to any model you want.useRick20\Faspay\CustomerInterface;
class Customer implements CustomerInterface
{
publicfunctiongetFaspayCustomerNumber()
{
return'customer-number';
}
publicfunctiongetFaspayCustomerName()
{
return'customer-name';
}
publicfunctiongetFaspayCustomerEmail()
{
return'customer-email';
}
publicfunctiongetFaspayCustomerPhone()
{
return'customer-phone';
}
publicfunctiongetFaspayPreferredCurrency()
{
return'customer-currency';
}
}// Item class example. You can apply to any model you want.useRick20\Faspay\Payable;
class Item implements Payable
{
publicfunctiongetPayableName()
{
return'Product Name';
}
publicfunctiongetPayablePrice()
{
return300000;
}
}// An example how to use the API.
Route::get('/', function () {
$customer = newCustomer();
$payable = newItem();
$payment = Payment::performedBy($customer)
->via('web')
->payWith('tcash')
->addTax(10)
->addMiscFee(1000);
$payment->addItem($payable, 2);
$response = Faspay::registerPayment($payment);
return Faspay::redirectToPay($payment);
});
Route::get('/callback-notif', function(\Illuminate\Http\Request$request) {
return Faspay::notified($request, function(\Rick20\Faspay\Notification$notification) {
return$notification;
});
});To generate a custom billing number/code, you can create a class that implements BillingProfileInterface, for example:
class TopupBillingProfile implements BillingProfileInterface
{
publicfunctiondescription()
{
return'Topup Saldo'; }
publicfunctiongenerate(Payment$payment)
{
returnstr_random(15);
}
}and then pass it as a second argument of registerPayment() method.
This package is far from perfect. It doesn't support BCA KlikPay yet. It doesn't support Faspay Credit API also. Feel free to report me any bug you found or send me pull requests.