Laravel 5.* 的 Epay.bg API 包装器

1.0.2 2017-09-30 07:00 UTC

This package is not auto-updated.

Last update: 2024-09-28 18:36:58 UTC


README

Laravel 对 Epay.bg API 的包装。与 Laravel 5.1 兼容

安装

通过 Composer

$ composer require angelbachev/epay
  • 将服务提供者添加到 config/app.php 文件中的 $providers 数组中,例如
AngelBachev\Epay\EpayServiceProvider::class
  • 将别名添加到 config/app.php 文件中的 $aliases 数组中,例如
'Epay' => AngelBachev\Epay\Facades\Epay::class
  • 根据需要运行以下命令之一以发布包配置
    • 仅发布 angelbachev/epay 包配置
    php artisan vendor:publish --provider="AngelBachev\Epay\EpayServiceProvider"
    
    • 发布您使用的所有包的配置
    php artisan vendor:publish --tag="config"
    
    • 发布所有包的所有资产
    php artisan vendor:publish
    
  • 将以下行添加到您的 .env 文件中
# Epay configuration values
EPAY.mode=stage   # if you want to make real payments set this to prod
# Settings for testing purposes
EPAY.stage.client_id=   #Add your Customer number
EPAY.stage.secret=      #Add your Secret key
EPAY.stage.success_url= #URL where you want the customer to be redirected after confirming payment
EPAY.stage.cancel_url=  #URL where you want the customer to be redirected if he rejects the payment
# Production settings
EPAY.prod.client_id=    #Add your Customer number
EPAY.prod.secret=       #Add your Secret key
EPAY.prod.success_url=  #URL where you want the customer to be redirected after confirming payment
EPAY.stage.cancel_url=  #URL where you want the customer to be redirected if he rejects the payment

使用方法

    $invoice     = mt_rand(1, 1000000);
    $amount      = 150.63;
    $expiration  = '01.03.2016 08:30:00';
    $description = 'Invoice Description';

    Epay::setData(
        $invoice,     // accepts only positive integer values
        $amount,      // accepts only positive integers and float numbers with 1 or 2 digits after decimal point
        $expiration,  // accepts time in format DD.MM.YYYY[ hh:mm[:ss]]
        $description, // max length 100 symbols
        [$currency],  // optional, accepts only "BGN", "USD", "EUR" ("BGN" by default)
        [$encoding]   // optional, accepts only "utf-8"
    );

通知接收路由(POST)

    Route::post('receive', function() { # replace 'receive' with your real route for handling Epay notifications

        $receiver = Epay::receiveNotification(Input::all());

        /**
        * Update order or status of payment
        *
        *    array (
        *      'invoice' => '1500',
        *      'status' => 'PAID',
        *      'pay_date' => '20160221143730',
        *      'stan' => '036257',
        *      'bcode' => '036257',
        *    ),
        *
        **/
        // Do something with the response
        foreach($receiver['items'] as $item) {
            Log::info($item);
            Log::info($item['status']);
            Log::info($item['invoice']);
        }

        return $receiver['response'];
    });

视图中的表单

    <form action="{{ Epay::getSubmitUrl() }}" method="post">
        {!! Epay::generateHiddenInputs() !!}

        // your code here

        <button type=submit>Send</button>
    </form>

支持

该包目前仅支持 Laravel 5 及 5.1 和 5.2。

  • 如有任何问题,请在“问题”部分创建一个问题。
  • 如果您想做出贡献
    • 在此仓库上创建分支。
    • 实现您的功能。
    • 生成拉取请求。

变更日志

请参阅 CHANGELOG 了解最近更改的更多信息。

安全性

如果您发现任何与安全相关的问题,请通过电子邮件发送至 angelbachev@gmail.com,而不是使用问题跟踪器。

鸣谢

许可证

MIT 许可证 (MIT)。请参阅 许可证文件 了解更多信息。

https://packagist.org.cn/packages/angelbachev/epay