定制 farsh4d/laravel-bank 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

farsh4d/laravel-bank

最新稳定版本:1.0.0

Composer 安装命令:

composer require farsh4d/laravel-bank

包简介

A package to connect to any IPG to make a payment

README 文档

README

Packagist License Latest Stable Version Total Downloads

This is a package to connect to any Internet Payment Gateways.
This package now only supports Mellat IPG for now but we are developing other IPGs ASAP.

Installation

Require this package with composer.

composer require farsh4d/laravel-bank

Laravel uses Package Auto-Discovery, so doesn't require you to manually add the ServiceProvider.

Laravel without auto-discovery:

If you don't use auto-discovery, add the ServiceProvider to the providers array in config/app.php

Farsh4d\Bank\Providers\BankServiceProvider::class,

Copy the package config to your local config with the publish command:

php artisan vendor:publish --provider="Farsh4d\Bank\Providers\BankServiceProvider"

Prepare your database

php artisan migrate

Usage

You need 2 routes, one to start a payment and one for callback:

routes.php

Route::get('/payment-start', 'PaymentController@start')->name('payment_start');
Route::any('/payment-callback', 'PaymentController@callback')->name('payment_callback');

Remember to exclude your callback route from CSRF verification.

In start method initialize your desired driver and set required data (price, orderId and callback):

PaymentController.php @start

$amount = 50000;
$orderId = '123456';

$bankDriver = Bank::driver('Mellat');

$bankDriver->price($amount)
    ->orderId($orderId)
    ->callback(route('payment_callback'));

try {
    $bankDriver->ready();
    return $bankDriver->redirect();
} catch (\Exception $e) {
    // Handle failed transaction initiation; ie:
    return view('payment-error');
}

If everything goes right user redirects to IPG and makes a payment and then redirects to your callback.

PaymentController.php @verify

try {
    Bank::verify();
    // Show transaction success view or do sth else; ie:
    return view('payment-success');
} catch (\Exception $e) {
    // Handle failed payment; ie:
    return view('payment-failed');
}

统计信息

  • 总下载量: 4
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 5
  • 点击次数: 4
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 5
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-08-01