Download the PHP package hen8y/laravel-vpay without Composer
On this page you can find all versions of the php package hen8y/laravel-vpay. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download hen8y/laravel-vpay
More information about hen8y/laravel-vpay
Files in hen8y/laravel-vpay
Package laravel-vpay
Short Description laravel 8, 9, 10, 11 package for Vpay
License MIT
Informations about the package laravel-vpay
laravel-vpay
Installation
PHP 7.2, LARAVEL, and Composer are required.
To get the latest version of Laravel Vpay, simply require it
Or add the following line to the require block of your composer.json
file.
You'll then need to run composer install
or composer update
to download it and have the autoloader updated.
Once Laravel Vpay is installed, you need to register the service provider. Open up config/app.php and add the following to the providers key.
You can publish the configuration file and assets by running:
Important
The url below is for your vpay webhook, don't include it as part of your routes. Callbacks are not as efficient as webhooks, so we've crafted this package to use webhooks mainly but you can opt for the callback option
Visit Vpay dashboard and add https://yoursite.com/payment/webhook/pay
as your webhook url in the settings
Configuration
If you want to use the webhook make sure to publish the job file:
A file would be created
- Job-file named
VpayJob.php
in theJobs
directory
Details of the Config file
The configuration-file named vpay.php
with some defaults that was placed in your config
directory:
Usage
Exclude the webhook url from CSRF verification
Open your VerifyCsrfToken Middleware
file located in app/Http/Middleware
and add the url like this:
For laravel 11
Open bootstrap/app.php
and add this
Open your .env file and add your public key, secret key, merchant email and payment url like so:
Set up your redirect & callback route :
-
Redirect to the checkout
- Callback
Set up your payment controller to send the payment details
If you opt to use the webhook, if not you can skip this step
Set up your Job to handle the Payment Webhook, The Job was already Published after you ran the php artisan vpay:publish
command:
In app/Jobs you would see a file VpayJob, edit it to handle the webhook data after every successful transaction. Visit Vpay Docs to view the payload data
Sample Html/Bootstrap Form
After clicking the submit button the customer gets redirected a checkout page.
After the customer does some actions there and now gets redirected back to either the success or failure route with callback data.
For webhook
Vpay would send some data to the webhook (remember to exclude the webhook url from CSRF verification). This webhook will contain some information as its payload. Additionally, a JWT token will accompany this payload, with {secret: your_secret_key} as its content.
We must validate if the redirect to our site is a valid request (we don't want imposters to wrongfully place non-paid order).
The webhook url payment/webhook/vpay
is secured using a middleware (you don't have to set up any middleware as it has been set already in this package). This decodes the JWT token and compare its secret payload with the secret-key added in the env file, on success it dispatches a job to queue, check the Job in your App/Job and handle the details
Make sure to run 👇 for the job on queue
Contributing
Please feel free to fork this package and contribute by submitting a pull request to enhance the functionalities.
Don't forget to follow me on twitter!
Thanks! Ogbonna Henry (hen8y).
License
The MIT License (MIT). Please see License File for more information.