Simple laravel package for Gkash Payment Gateway.
You can install the package via composer:
composer require laraditz/gkash
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
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",
]
Payment Status | Description |
---|---|
1 | Created |
2 | Pending |
3 | Success |
4 | Failed |
5 | Cancelled |
6 | None |
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.
Event | Description |
---|---|
Laraditz\Gkash\Events\BackendReceived | Received backend response from Gkash for a payment. Can use to update your payment status and other details |
composer test
Please see CHANGELOG for more information what has changed recently.
Please see CONTRIBUTING for details.
If you discover any security related issues, please email raditzfarhan@gmail.com instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.