Download the PHP package devinweb/laravel-hyperpay without Composer
On this page you can find all versions of the php package devinweb/laravel-hyperpay. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download devinweb/laravel-hyperpay
More information about devinweb/laravel-hyperpay
Files in devinweb/laravel-hyperpay
Package laravel-hyperpay
Short Description Laravel package for Hyperpay payment gateway in MENA.
License MIT
Homepage https://github.com/devinweb/laravel-hyperpay
Informations about the package laravel-hyperpay
Laravel HyperPay
Laravel HyperPay provides an easy way to handle all the transactions with different states.
Installation
You can install the package via composer:
Database migration
Laravel-hyperpay
provides a migration to handle its own transaction, don't forget to publish the migration after installation
Then migrate
This migration has a model named Transaction
, if your app use multi-tenancy, you can create a new transaction model based on the hyperpay transaction
model.
then don't forget the update the transaction_model
path in the config file app/hyperpay.php
Setup and configuration
You can also publish the config file using
After that you can see the file in app/hyperpay.php
Before start using Laravel-hyperpay
, add the ManageUserTransaction
trait to your User model, this trait provides mutliple tasks to allow you to perform the transaction process from the given user.
This package use User model that will be App\User
or App\Models\User
, if else you can define your user model using the .env
HyperPay Keys
Next, you should configure your hyperpay environment in your application's .env
Creating a transaction
To create a transaction in hyperpay using this package, we need to to prepare the checkout then generate the form.
Prepare the checkout
you can also attach the billing data to the checkout by creating the billing class using this command, all billing files you can find them in app/Billing
folder.
then use
You can also generate your own merchantTransactionId and tell the package to use it, by using addMerchantTransactionId($id)
Next the response returned by the prepareCheckout
actions
To create the payment form you just need to add the following lines of HTML/JavaScript to your page.
Payment status
After the transaction process hyperpay redirect the user to the merchant page using the shopperResultUrl
that you can configure it in the config file app/hyperpay.php
, by updating the redirect_url
value.
You can also add redirect_url
dynamically via addRedirectUrl($url)
that can override the default config redirect_url
if you want to add a dynamic url like if you use multi-tenant or add some parameters to your redirection url.
After redirection you can use an action the handle the finalize step
Events handlers
Laravel-hyperpay
providers two events during the transaction process, after finalize this package fire for successfull transaction
Event | Description |
---|---|
Devinweb\LaravelHyperpay\Events\SuccessTransaction | success transaction |
Devinweb\LaravelHyperpay\Events\FailTransaction | fail transaction |
Each event of them contains the trackable_data
and hyperpay_data
that used to prepare the checkout
Listener exemple
First we start by creating a new listener using
After that go to app/Providers/EventServiceProvider
and register the event with your listener
In each success transaction laravel-hyperpay
package fire an event with the necessary data take a look at our TransactionSuccessListener
class.
The same you can do with Devinweb\LaravelHyperpay\Events\FailTransaction
event.
Testing
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 [email protected] instead of using the issue tracker.
Credits
- darbaoui imad
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
Laravel hyperpay Boilerplate
You can use this repository to check the integration of the package laravel-hyperpay-boilerplate.