thearkaid / laravel-faspay
Unofficial Laravel package for Faspay Payment Gateway
Requires
- karriere/json-decoder: dev-master
README
Unofficial Laravel package for Faspay Payment Gateway.
This Package is a conversion from Faspay Api. PHP.
- Faspay Business Debit
- Faspay Business Credit
Features
- Getting Payment Channel
- Creating Payment
- Checking Payment Status
- Cancelling Payment
- Notification
- Callback
Installation
You can install the package via composer:
composer require thearkaid/laravel-faspay
Publish faspay.php configuration
php artisan vendor:publish --provider='TheArKaID\LaravelFaspay\Providers\LaravelFaspayServiceProvider'
How to Use
- Update faspay.php Configuration in your config directory,
/** * Set true saat dalam Mode Development * Set false saat ke Mode Production */ 'isdev' => true, // Kredensial saat dalam Mode Development 'devcred' => [ 'merchantname' => env('FP_DEV_MERCHANT_NAME', 'OR JUST SET HERE'), 'merchantid' => env('FP_DEV_MERCHANT_ID', 'OR JUST SET HERE'), 'userid' => env('FP_DEV_USER_ID', 'OR JUST SET HERE'), 'password' => env('FP_DEV_PASSWORD', 'OR JUST SET HERE'), 'redirecturl' => env('FP_DEV_REDIRECT_URL', 'OR JUST SET HERE') ], // Kredensial saat dalam Mode Production 'prodcred' => [ 'merchantname' => env('FP_PROD_MERCHANT_NAME', 'OR JUST SET HERE'), 'merchantid' => env('FP_PROD_MERCHANT_ID', 'OR JUST SET HERE'), 'userid' => env('FP_PROD_USER_ID', 'OR JUST SET HERE'), 'password' => env('FP_PROD_PASSWORD', 'OR JUST SET HERE'), 'redirecturl' => env('FP_PROD_REDIRECT_URL', 'OR JUST SET HERE') ]
- Alway Use and Create LaravelFaspay Class
// Require LaravelFaspay class use TheArKaID\LaravelFaspay\LaravelFaspay; // Create an object from LaravelFaspay Class $faspayer = new LaravelFaspay();
- Getting Payment Channel
// Return Payment Channel here return $faspayer->getPaymentChannel();
- Creating Payment
// Define your payment channel, $paymentChannel['pg_code'] = "802"; $paymentChannel['pg_name'] = "Mandiri Virtual Account"; // Create an array for ordered Item $item = Array(); $order["product"] = "Item #1"; // Product Name $order["qty"] = 1; // QTY $order["amount"] = 100000; // Price. Just the real price, without any '.'(dot) or ',' (comma). $order["paymentplan"] = 1; // Payment Plan. See References below. $order["merchantid"] = $faspayer->getConfig()->getUser()->getMerchantId(); // Merchant ID $order["tenor"] = 00; // Tenor. See References below. array_push($item, $order); // Push order, // Loop or push again for more than 1 items. // Create Bill Data $billData["billno"] = "1232123"; // Bill Number $billData["billdesc"] = "Pembayaran RHI"; // Billing Description $billData["billexp"] = 2; // Expired Day Interval (in total days) $billData["billtotal"] = 10000; // Bill Total, Just the real bill, without any '.'(dot) or ',' (comma). $billData["paytype"] = 3 // Pay Type. See References below. // Create User Data $userData["phone"] = "087123123123"; // Phone Number $userData["email"] = "arka.progammer@gmail.com"; // Email $userData["terminal"] = 21; // Terminal $userData["custno"] = "12345"; // Customer No $userData["custname"] = "thearka"; // Customer Name // Proccess the request and return the result. return $faspayer->createPayment($item, $paymentChannel, $billData, $userData);
- Checking Payment Status
// Proccess the request and return the result. return $faspayer->checkPaymentStatus( $reqdesc, // Request Description $trx_id, // Transaction ID $billno // Billing Number );
- Cancelling Payment
// Proccess the request and return the result. return $faspayer->cancelPayment( $trx_id, // Transaction ID $billno, // Billing Number $paymentcancel // Description for Cancellation );
- Notification
When users accept or cancel payment, notification of payment status sent to your server. Don't forget to return this data to the screen, as response to Faspay that their request accepted in your server
// Get the notification. return $faspayer->notifier(); // The Data returned. Take the data for updating your data status. // Success. { "response": "Payment Notification", "response_date": "2020-06-28 17:06:26", "trx_id": "1234567890", // Transaction ID "merchant_id": "12345", // Merchant ID "merchant": "TheArKa", // Merchant Name "response_code": "00", "response_desc": "Sukses" } // Failed { "response": "Payment Notification", "response_date": "2020-06-28 17:06:15", "trx_id": "1234567890", // Transaction ID "merchant_id": "12345", // Merchant ID "merchant": "TheArKa", // Merchant Name "response_code": "01", "response_desc": "Gagal" }
- Callback
Callback will be called when the user transaction has finished paid and get a notification that the transaction has been completed.
// Get the callback data return $faspayer->callbacker(); // The Data returned. Take the data for updating your data status. { "response": "Callback", "response_date": "2020-06-28 17:06:26", "trx_id": "1234567890", // Transaction ID "bill_no": "1234567890", // Bill Number "merchant_id": "12345", // Merchant ID "merchant": "TheArKa", // Merchant Name "bill_ref": "1234567890", // Bill Reference "response_code": "00", "response_desc": "Sukses" }
References
There are informations in Faspay that could help you understanding terms in this package
Discontinued!
This package has been discontinued, but it still works since the last commit, as long as how Faspay works hasn't changed. If you have a reason to continue this package, feel free to fork it or message me for any help.