Online Payment Component for Laravel 5+ known as Shaparak component completely compatible with BankTest simulator. Shaparak integrated all Iranian/Shetab payment gateways to one component.
- BankTest is a sandbox service for all Iranian online payment gateways
- بانک تست یک سرویس شبیه ساز درگاه های پرداخت آنلاین ایرانی برای اهداف توسعه و تست نرم افزار می باشد
Please support the package by giving it ⭐ and contributing to its development.
- Mellat Bank Gateway - درگاه بانک ملت (به پرداخت ملت) لاراول
- Saman Bank Gateway - درگاه بانک سامان (پرداخت الکترونیک سامان) لاراول
- Saderat Bank Gateway - درگاه بانک صادرات (پرداخت الکترونیک سپهر) لاراول
- Pasargad Bank Gateway - درگاه بانک پاسارگاد (پرداخت الکترونیک پاسارگاد) لاراول
- Parsian Bank Gateway - درگاه بانک پارسیان (تجارت الکترونیک پارسیان) لاراول
- Melli Bank Gateway - درگاه بانک ملی (سداد) لاراول
- ...
Shaparak require PHP 7.1+
- Installation via php composer
composer require php-monsters/shaparak
- Add package service provider to your app service providers:
PhpMonsters\Shaparak\ShaparakServiceProvider::class,
- Add package alias to your app aliases:
'Shaparak' => PhpMonsters\Shaparak\Facades\Shaparak::class,
- Publish package assets and configs
php artisan vendor:publish --provider="PhpMonsters\Shaparak\ShaparakServiceProvider"
If you complete installation step correctly, you can find Shaparak config file as shaparak.php
in you project config file.
For using sandbox environment you should set SHAPARAK_MODE=development
in your .env file otherwise set SHAPARAK_MODE=production
if you choose development mode, Shaparak uses banktest.ir as its payment gateway.
$table->string('token', 40)->nullable(); // It keeps token that we get from the IPG
$table->string('gateway_ref_id', 40)->nullable(); // It keeps gateway reference id that we get from the IPG on callback
$table->jsonb('gateway_callback_params')->nullable(); // It keeps the IPG callback parameters (just for tracking and debugging)
$table->boolean('verified')->default(false); // Transaction verified or not
$table->boolean('after_verified')->default(false); // Transaction settled or not
$table->boolean('reversed')->default(false); // Transaction revered/refunded or not
$table->boolean('accomplished')->default(false); // Transaction accomplished or not
Your Transaction, Invoice or Order model MUST implement Shaparak Transaction Interface.
<?php
namespace App\Models;
use App\Traits\JsonbField;
use App\Traits\ShaparakIntegration;
use Illuminate\Database\Eloquent\Model;
use PhpMonsters\Shaparak\Contracts\Transaction as ShaparakTransaction;
class Transaction extends Model implements TransactionTransaction
{
// method I: init Shaparak by passing custom gateway options
$gatewayProperties = [
'terminal_id' => 'X1A3B5CY-X1DT4Z',
'terminal_pass' => '12345',
];
$shaparak = Shaparak::with($psp, $transaction, $gatewayProperties)
->setParameters($request->all());
// method II: init shaparak by config based gateway options
// if you don't pass the third item it will use gateway's options from `config/shaparak.php` config file
$shaparak = Shaparak::with($psp, $transaction)
->setParameters($request->all());
Create a form in order to go to payment gateway. This form is auto-submit by default
// create your transaction as you desired
$transaction = new Transaction();
$transaction->user_id = $user->id;
// ...
$transaction->ip_address = $request->getClientIp();
$transaction->description = $request->input('description');
$transaction->save();
try {
$form = Shaparak::with('saman', $transaction)->getForm();
} catch (\Exception $e) {
XLog::exception($e);
flash(trans('gate.could_not_create_goto_bank_form'))->error();
return redirect()->back();
}
Show the form in your blade like:
{!! $form !!}
In your callback action create a Shaparak instance and handle the transaction
$shaparak = Shaparak::with('saman', $order)
->setParameters($request->all());
if ($shaparak->canContinueWithCallbackParameters($request->all()) !== true) {
flash(trans('gate.could_not_continue_because_of_callback_params'))->error();
// do what you need
}
$shaparak->setCallBackParameters($request->all());
$verifyResult = $shaparak->verifyTransaction($request->all());
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
This component is developed by the following person(s) and a bunch of awesome contributors.
Aboozar Ghaffari | Maryam Nabiyan |
The Laravel Online Payment Module is open-sourced software licensed under the MIT license