定制 hamraa/lumen-payment 二次开发

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

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

hamraa/lumen-payment

Composer 安装命令:

composer require hamraa/lumen-payment

包简介

A Lumen package for connecting to payment gateways

README 文档

README

A Lumen package for connecting to payment gateways.

By this package we are able to connect to all Iranian bank with one unique API.

Please inform us once you've encountered bug or issue.

Available Banks:

  1. MELLAT
  2. SADAD (MELLI)
  3. SAMAN
  4. PARSIAN
  5. PASARGAD
  6. ZARINPAL
  7. PAYPAL (New)
  8. ASAN PARDAKHT (New)
  9. PAY.IR (New) (to use : new \Payir())

Installation

First, install the package via Composer:

composer require hamraa/lumen-payment

Copy the required files:

mkdir -p config
cp vendor/hamraa/lumen-payment/config/payment.php config/payment.php
cp vendor/hamraa/lumen-payment/database/migrations/create_payment_transactions_table.php.stub database/migrations/2016_01_01_000000_create_payment_transactions_table.php
cp vendor/hamraa/lumen-payment/database/migrations/create_payment_transactions_status_logs_table.php.stub database/migrations/2016_01_01_000000_create_payment_transactions_status_logs_table.php
cp vendor/hamraa/lumen-payment/resources/views resources/views

Then, in bootstrap/app.php :

  • register the alias:
$app->withFacades(true, [
    'Hamraa\Payment\Gateway' => 'Gateway',
]);
  • register the config file:
$app->configure('payment');
  • register the service provider:
$app->register(\Hamraa\Payment\PaymentServiceProvider::class);

Now, run your migrations:

php artisan migrate

Done!

Usage

You can make connection to bank in several ways (Facade , Service container):

try {
       
   $gateway = \Gateway::make(new \Mellat());

   // $gateway->setCallback(url('/path/to/callback/route')); You can also change the callback
   $gateway
        ->price(1000)
        // setShipmentPrice(10) // optional - just for paypal
        // setProductName("My Product") // optional - just for paypal
        ->ready();

   $refId =  $gateway->refId(); // شماره ارجاع بانک
   $transID = $gateway->transactionId(); // شماره تراکنش

  // در اینجا
  //  شماره تراکنش  بانک را با توجه به نوع ساختار دیتابیس تان 
  //  در جداول مورد نیاز و بسته به نیاز سیستم تان
  // ذخیره کنید .
  
   return $gateway->redirect();
       
} catch (\Exception $e) {
    // نمایش خطای تراکنش
    echo $e->getMessage();
}

You can call the gateway by these ways :

  1. Gateway::make(new Mellat());
  2. Gateway::mellat()
  3. app('gateway')->make(new Mellat());
  4. app('gateway')->mellat();

Instead of MELLAT you can enter other banks Name as we introduced above .

In price method you should enter the price in IRR (RIAL)

and in your callback :

try { 
       
   $gateway = \Gateway::verify();
   $trackingCode = $gateway->trackingCode();
   $refId = $gateway->refId();
   $cardNumber = $gateway->cardNumber();
   
    // تراکنش با موفقیت سمت بانک تایید گردید
    // در این مرحله عملیات خرید کاربر را تکمیل میکنیم
    
} catch (\Hamraa\Payment\Exceptions\RetryException $e) {

    // تراکنش قبلا سمت بانک تاییده شده است و
    // کاربر احتمالا صفحه را مجددا رفرش کرده است
    // لذا تنها فاکتور خرید قبل را مجدد به کاربر نمایش میدهیم
    
    echo $e->getMessage() . "<br>";
    
} catch (\Exception $e) {

    // نمایش خطای بانک
    echo $e->getMessage();
}

Credits

This package is based on larabook/gateway (payment package for laravel) with some major change to compatible with Lumen framework and some code improvments.

Thanks

Special thanks to larabook team.

统计信息

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

GitHub 信息

  • Stars: 3
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-07-10

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固