tsaiyihua/laravel-ezpay

laravel的ezpay库

dev-master 2021-05-03 08:51 UTC

This package is auto-updated.

Last update: 2024-09-29 05:28:06 UTC


README

Laravel EZPay 是一个用于接入EZPay的非官方套件

系统需求

  • PHP >= 7
  • Laravel >= 5.7
  • guzzlehttp >= 6.2

安装

composer require tsaiyihua/laravel-ezpay

环境配置

php artisan vendor:publish --tag=ezpay

在.env文件中添加

EZPAY_MERCHANT_ID=
EZPAY_HASH_KEY=
EZPAY_HASH_IV=
  • 金流测试用的参数值请参考接口文件 API_E_wallet_ezPay_1.0.2.pdf 第17页。
  • 查询订单的参数请参考接口文件 API_Trans_ezPay_1.0.0.pdf 第10页。

用法

创建订单

  • 产品资料单笔时可以仅发送itemName及amount
use TsaiYiHua\EZPay\MPG;

class MpgController extends Controller 
{
    public function __construct(MPG $mpg)
    {
        $this->mpg = $mpg;
    }
...

    public function sendOrder()
    {
        $data = [
            'itemName' => 'Donate',
            'amount' => 50
        ];
        return $this->mpg->createOrder($data);
    }

查询订单

use TsaiYiHua\EZPay\Collections\QueryResponseCollection;
use TsaiYiHua\EZPay\Query;

class QueryController extends Controller 
{
    protected $query;
    protected $queryResponse;
    
    public function __construct(Query $query, QueryResponseCollection $queryResponse)
    {
        $this->query = $query;
        $this->>queryResponse = $queryResponse;
    }
    ...
    public function queryInfo()
    {
        $res = $this->query->queryInfo('18120414321996244');
        return $this->queryResponse->collectResponse($res);
    }

开立发票

use TsaiYiHua\EZPay\Collections\InvoiceResponseCollection;
use TsaiYiHua\EZPay\Invoice;

class InvoiceController extends Controller
{
    ...
    public function __construct(Invoice $invoice, InvoiceResponseCollection $invResponse)
    {
        $this->invoice = $invoice;
        $this->invResponse = $invResponse;
    }
    ...
    
    public function issueInvoice()
    {
        $itemData[] = [
            'name' => 'Donate',
            'qty' => 1,
            'unit' => '',
            'price' => 500
        ];
        $invData = [
            'orderId' => StringService::identifyNumberGenerator('O'),
            'items' => $itemData,
            'BuyerName' => 'Buyer Name',
            'BuyerEmail' => 'eamil@address.com',
            'LoveCode' => 919
        ];
        return $this->invResponse->collectResponse($this->invoice->issueInvoice($invData)->query());
    }
  • 已知问题
    • NotifyURL及ReturnURL的参数无效,必须直接到管理平台设置才有设置。
    • 境外转账可以使用支付宝,但也要企业账号才能测试。

参考资料

  • ezPay 简单付电子支付平台技术串接手册 (2017-9-11)
    • 文件编号 ezPay_1.0.2
    • 文件位置 documents/API_E_wallet_ezPay_1.0.2.pdf
  • ezPay 简单付电子支付平台交易状态查询 技术串接手册 (2017-03-23)
    • 文件编号 ezPay_1.0.0
    • 文件位置 documents/API_Trans_ezPay_1.0.0.pdf
  • 线上API文件区
  • https://github.com/s950329/laravel-spgateway
  • 捐赠码清单