This package provides laravel implementations for Paynet FPX services.
You can install the package via composer:
composer require aimensasi/fpx
Then run the publish command to publish the config files and support controller
php artisan vendor:publish --provider="Aimensasi\FPX\FPXServiceProvider"
This will generate the following files
- The config file with default setup for you to override
fpx.php
- The controller that will receive payment response and any host-to-host events
Http/Controllers/FPX/Controller.php
- Add your redirect urls and your Seller and Exchange Id to the
.env
file.
FPX_INDIRECT_URL=https://app.test/payments/fpx/callback
FPX_INDIRECT_PATH=payments/fpx/callback
FPX_DIRECT_URL=https://app.test/payments/fpx/direct-callback
FPX_DIRECT_PATH=payments/fpx/direct-callback
FPX_EXCHANGE_ID=
FPX_SELLER_ID=
- After generating your certificates add them to your app. By default, we look for the certificates inside the following directives.
'certificates' => [
'uat' => [
'disk' => 'local', // S3 or Local. Don't put your certificate in public disk
'dir' => '/certificates/uat',
],
'production' => [
'disk' => 'local', // S3 or Local. Don't put your certificate in public disk
'dir' => '/certificates/prod',
]
],
You can override the defaults by updating the config file.
- Run migration to add the banks table
php artisan migrate
- First run the following commands to seed the banks list.
php artisan fpx:banks
you should schedule the fpx:banks Artisan command to run daily:
$schedule->command('fpx:banks')->daily();
- Add one the
x-fpx-pay
component with the following attributes
<x-fpx-pay
:reference-id="$invoice->id"
:datetime="$invoice->created_at->format('Ymdhms')"
:amount="$invoice->total"
:customer-name="$company->name"
:customer-email="$company->owner->email"
product-description="Salary Invoice">
During testing, you can use the test-mode
attribute to override the provided amount to 'MYR 1.00'
<x-fpx-pay
:reference-id="$invoice->id"
:datetime="$invoice->created_at->format('Ymdhms')"
:amount="$invoice->total"
:customer-name="$company->name"
:customer-email="$company->owner->email"
product-description="Salary Invoice"
test-mode>
- Handle the payment response in
Http/Controllers/FPX/Controller.php
/**
* This will be called after the user approve the payment
* on the bank side
*
* @param Request $request
* @return Response
*/
public function callback(Request $request) {
$response = $request->handle();
// Update your order status
}
/**
* This will handle any direct call from FPX
*
* @param Request $request
* @return string
*/
public function webhook(Request $request) {
$response = $request->handle();
// Update your order status
return 'OK';
}
Please see CHANGELOG for more information what has changed recently.
Please see CONTRIBUTING for details.
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.
This package was generated using the Laravel Package Boilerplate.