Download the PHP package tohidplus/mellat without Composer
On this page you can find all versions of the php package tohidplus/mellat. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download tohidplus/mellat
More information about tohidplus/mellat
Files in tohidplus/mellat
Package mellat
Short Description A Laravel package for connecting to (Iran) Mellat bank gateway.
License MIT
Informations about the package mellat
Laravel package for Mellat bank
This package is built for connecting Iranian websites to Mellat bank gateway.
Installation
-
Run the command below
-
Add the following code to end of the providers array in config/app.php file.
-
Add the following code to end of the aliases array in config/app.php file.
-
Run the command below
-
Migrate the database
- Now you can see a new config file named mellat.php is added to config directory. So open the file...
Fill the array elements
Notice: you can leave callBackUrl here blanked and initialize it dynamically by using setCallBackUrl method as we will explain
- Now you have to exclude callBackUrl from verifyCsrfToken middleware. Open the file app/Http/Middleware/VerifyCsrfToken.php and add the callbackUrl to except array.
mellat.blade.php file
While redirecting user to the bank you will see a simple page with no design which is located inside the resources/views/vendor/mellat directory. So you can open this file and design it as you wish.
Methods
setCallBackUrl
if you haven't set callBackUrl in mellat.php config file you must set it using this method before redirecting user .
Parameters:
- callBackUrl (required)
set
Before redirecting user to the gateway you have to initialize the fields using this method otherwise you will get an exception.
Parameters:
- amount (Required - if the value of convertToRial in mellat.php file is true you must pass the value in Toman otherwise pass it in Rial.)
- orderId (Optional)
- payerId (Optional)
- additionalData (Optional)
redirect
after initializing the fields you can redirect user to the bank by using this method.
Parameters:
- It only accepts one parameter as a callback funtion and if there is an error while redirection the callback function will be triggered with error message as a parameter.
verify
This method indicates if transaction was successful or not.
Parameters:
- success is a callback function which will be triggered if the transaction was successful and accepts an instance of Tohidplus\Mellat\Models\MellatLog as a parameter.
- error is a callback function which will be triggered if the transaction was unsuccessful and accepts an instance of Tohidplus\Mellat\Models\MellatLog as a parameter.
Full example
Transaction Logs
Simply all events are saved in mellat_logs table which is associated with Tohidplus\Mellat\Models\MellatLog model .