Download the PHP package tohidplus/zarrinpal without Composer
On this page you can find all versions of the php package tohidplus/zarrinpal. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download tohidplus/zarrinpal
More information about tohidplus/zarrinpal
Files in tohidplus/zarrinpal
Package zarrinpal
Short Description A Laravel package for connectiong to (Iran) Zarrinpal gateway
License MIT
Informations about the package zarrinpal
Laravel package for Zarinpal
This package is built for connecting Iranian websites to Zarrinpal 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 zarrinpal.php is added to config directory. So open the file...
Add the merchantId , description and the callBackUrl which you want to redirect the user from bank after transaction is finished.
Notice: you can leave callbackUrl and description here blanked and define it when you call setData method dynamically as we will explain in the next part.
Methods
setData method
Before redirecting user to the gateway you have to initialize the fields using this method otherwise you will get an exception.
Parameters:
- amount (Required)
- email (Optional)
- mobile (Optional)
- description ( If you haven't defined it in config file you must set it here )
- callBackUrl ( If you haven't defined it in config file you must set it here )
redirect method
after initializing the fields you can redirect user to the bank 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 status code as parameter.
verify method
This method indicates if transaction is successful or not.
Parameters
- request is the request which you get from bank and you have to pass it to verify method.
- success is a callback function which will be triggered if transaction is successful and accepts refId as parameter.
- error is a callback function which will be triggered if transaction is unsuccessful.
Full example
Transaction Logs
Simply all events are saved in zarrinpal_logs table which is associated with Tohidplus\Zarrinpal\Models\ZarrinpalLog model