Download the PHP package aminkt/yii2-payment-module without Composer
On this page you can find all versions of the php package aminkt/yii2-payment-module. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package yii2-payment-module
Contribute on this project
If you want i will happy to use your help to improve this project. For contributing please refer to this link.
Contributing guide lines
How to install this module:
Step1: Add flowing line to require part of composer.json
:
Or run bellow command :
Step2: Add flowing lines in your application config:
All time please add Mellat Bank gate in down of gates list because it may make issue in automatic gate selector. Mellat gate throw an exception when it's not available that system can not catch it so the processes may become failed. If you can fix this please contribute.
Step3: Create your own order model and implement aminkt\yii2\payment\interfaces\OrderInterface
in your order model.
Using order model in this module is required.
Note: Using a table as order model is an standard pattern to keep track of every thing you try to sale. refer this link to read more: http://www.databaseanswers.org/data_models/customers_and_orders/index.htm
Database Migrations
Before usage this extension, we'll also need to prepare the database.
Usage:
In your code when you want create a payment request use below code:
Use
$orderModel
to make a connection between your order table and payment data. by defining this you can access to your orders later from payment logs.
When users paid money, they will redirect in a page in you site that you defined.
By default user will redirect to /payment/default/verify
route.
For changing default call back page use below code:
Also you can set callback address globally in module configuration.
In your verify page use below code to verify payment:
$verify
is false
if verify action become failed and otherwise return an true.
Security
Module will check security issues and log them in yii2 log system. You can also define below attribute in payment component config to change default behavior of security system.
Attribute | Default value | Description |
---|---|---|
encryptKey | Null | Encrypt key should be safe and long to encrypt payment token and is required. |
bankTimeout | Null | Time that system can validate bank response. Default is null. Set time in second that if user returned from bank then system accept the response. If user do not return from bank in defined time then response will not accept. |
blockTime | 86400 | This value define if a user blocked how much should prevent action from that. If set null for ever considered. Value should be in second |
allowedCredentialErrors | 5 | Max allowed times that a user can has credential errors |
Gate configuration
Every gate has some configuration. In this module prepared some default gates that you can use.
If you want create your own gate please refer to Create gate class section.
You can contribute your gates to this report and help me to improve productivity.
List of gates:
Name | Bank | Contributor | Configuration array |
---|---|---|---|
\aminkt\yii2\gates\Sep |
Saman | Amin Keshavarz [email protected] | Sep gate configuration |
\aminkt\yii2\gates\MellatGate |
Mellat | Amin Keshavarz [email protected] | Mellat gate configuration |
\aminkt\yii2\gates\Parsian |
Parsian | Amin Keshavarz [email protected] | Parsian gate configuration |
\aminkt\yii2\gates\IranKish |
IranKish | Amin Keshavarz [email protected] | IraniKish gate configuration |
\aminkt\yii2\gates\ZarinPal |
Zarinpal | Amin Keshavarz [email protected] | ZarinPal gate configuration |
Create gate class
To create gate class you should create a new class in your application and extend it from \aminkt\yii2\payment\gates\AbstractGate
.
Implement uncompleted methods and then use below rule to read identity data and configurations from module configuration:
As you know every gate has some configuration that user will prepare that as array. you can access this config from your gate by calling
getIdentity
methods.
For example if user use below configuration:
Then in CustomGate
you can access below methods:
Implement your gate. see examples and if you like contribute it in this repo.
Gate configurations
Sep
MellatGate
Parsian
IranKish
ZarinPal
Reports:
In older versions you can use some routes to see some views in your backend panel for logs but in this current
we improve our module to use in rest modules so you still have a route to read logs but as RESTAPI
.
This part documents not complete yet.
Structure of tables and classes:
All versions of yii2-payment-module with dependencies
yiisoft/yii2 Version ~2.0.11
ext-openssl Version *
ext-soap Version *
yiisoft/yii2-httpclient Version ~2.0.0
aminkt/exceptions Version v1.0.0.x-dev