laraditz / gkash
Simple laravel package for Gkash Payment Gateway.
Requires
- php: ^7.4|^8.0
- illuminate/support: ^8.0
Requires (Dev)
- orchestra/testbench: ^6.0
- phpunit/phpunit: ^9.0
This package is auto-updated.
Last update: 2024-11-16 12:05:28 UTC
README
Simple laravel package for Gkash Payment Gateway.
Installation
You can install the package via composer:
composer require laraditz/gkash
Before Start
Configure your variables in your .env
(recommended) or you can publish the config file and change it there.
GKASH_MERCHANT_ID=<your_merchant_id_here>
GKASH_SIGNATURE_KEY=<your_signature_key_here>
GKASH_SANDBOX_MODE=true # true or false for sandbox mode
(Optional) You can publish the config file via this command:
php artisan vendor:publish --provider="Laraditz\Gkash\GkashServiceProvider" --tag="config"
Run the migration command to create the necessary database table.
php artisan migrate
Usage
Create Payment
To create payment and get the payment URL to be redirected to. You can use service container or facade.
// Create a payment // Using service container $payment = app('gkash')->refNo('ABC1234')->amount(100)->returnUrl('https://returnurl.com')->createPayment(); // Using facade $payment = \Gkash::refNo('ABC1234')->amount(100)->returnUrl('https://returnurl.com')->createPayment();
Return example:
[ "code" => "5Xpj9IPN", "currency_code" => "MYR", "amount" => 100, "payment_url" => "http://myapp.com/gkash/pay/5Xpj9IPN" ]
Redirect to the payment_url
to proceed to Gkash payment page. Once done, you will be redirected to the returnUrl. Below is the sample response returned.
[ "amount" => "1.00", "code" => "5Xpj9IPN", "currency" => "MYR", "id" => "98043afa-d795-43b1-a6da-af735ba43db0", "merchant_id" => "MXXX-X-XXXXX", "payment_type" => "TnG ECOMM", "ref_no" => "ABC14393647840", "signature" => "0bfe2724c9c29dcd5c086a1f45f28ce0b702dd86dddef8eb40d46001ce76dff76a8f18b9f993f6cbb104206041866f239c4239878f62c043b4252a0c00a3a374", "status" => 3, "status_text" => "Success", "vendor_ref_no" => "MXXX-PO-XXXXXX", ]
Event
This package also provide some events to allow your application to listen to it. You can create your listener and register it under event below.
Testing
composer test
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email raditzfarhan@gmail.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.