vpn99/coinpayment

此包已被放弃,不再维护。没有建议的替代包。

CoinPayment PHP 客户端用于 Laravel

v1.1.4 2018-11-26 10:32 UTC

README

Latest Stable Version Total Downloads License

CoinPayment 是一个 Laravel 模块,用于处理来自 CoinPayment 的交易,如创建交易、历史交易等。 示例

要求

  • Laravel ^5.6
  • PHP >= ^7.1
  • GuzzleHttp
  • Nesbot/Carbon

安装

您可以通过 composer 安装此包

$ composer require hexters/coinpayment

发布供应商

$ php artisan vendor:publish --tag=coinpayment-publish

首先,您应该在 User 模型上添加 trait 类并使用此 trait Hexters\CoinPayment\Entities\CoinPaymentuserRelation,以下是一个示例

    <?php
        namespace App;

        use Illuminate\Notifications\Notifiable;
        use Illuminate\Foundation\Auth\User as Authenticatable;
        use Hexters\CoinPayment\Entities\CoinPaymentuserRelation;

        class User extends Authenticatable {
            use Notifiable, CoinPaymentuserRelation;
            ...

安装 CoinPayment 配置

$ php artisan coinpayment:install

在您的文件 app > console > kernel 中设置检查交易是否成功的计划。示例

...
    protected function schedule(Schedule $schedule) {
        // If IPN is enable set the schedule for ->daily()
        // And if IPN is disable set schedule for ->everyMinute()
         $schedule->command('coinpayment:transaction-check')
            ->daily();

    }
...

访问 计划文档

安装交易表

$ php artisan migrate

安装完成。

入门

创建交易按钮。示例放置在您的控制器中

use CoinPayment; // use outside the class
...
    /*
    *   @required true
    */
    $trx['amountTotal'] = 50; // USD
    $trx['note'] = 'Note for your transaction';

    /*
    *   @required true
    *   @example first item
    */
    $trx['items'][0] = [
        'descriptionItem' => 'Product one',
        'priceItem' => 10, // USD
        'qtyItem' => 2,
        'subtotalItem' => 20 // USD
    ];

    /*
    *   @example second item
    */
    $trx['items'][1] = [
        'descriptionItem' => 'Product two',
        'priceItem' => 10, // USD
        'qtyItem' => 3,
        'subtotalItem' => 30 // USD
    ];

    /*
    *   if you want to remember your data at a later date, you can add the parameter below
    */
    $trx['payload'] = [
        // your custom array here
        'foo' => [
            'foo' => 'bar'
        ]
    ];

    $link_transaction = CoinPayment::url_payload($trx);
    ...
    /*
    *   On your blade
    *   <a href="{{ $link_transaction }}" target="_blank">Pay Now</a>
    */
...

请在文件 app > Http > Middleware > VerifyCsrfToken.php 中接受来自 csrf 处理的路由

    ...
    protected $except = [
        ...
        '/coinpayment/ipn'
        ...
    ];
    ...

打开文件 app > Jobs > coinPaymentCallbackProccedJob.php 以处理交易过程

并打开 app > Jobs > IPNHandlerCoinPaymentJob.php 以处理 IPN 过程

路由访问

路由名称 路由 URL 方法 描述
coinpayment.transaction.histories /transactions/histories GET 访问交易历史的路由

给我一杯咖啡

BTC: 1388MHjeHmq6kUC7WpSS6pPtgG7hm7fCau