labs7in0/omnipay-wechat
最新稳定版本:v1.1.1
Composer 安装命令:
composer require labs7in0/omnipay-wechat
包简介
WeChat driver for the Omnipay PHP payment processing library
README 文档
README
WeChat Payment driver for the Omnipay PHP payment processing library
Deprecated We suggest you to use @lokielse's implementation of WeChatPay for Omnipay at lokielse/omnipay-wechatpay.
There's a pre-built Payment Gateway based on Omnipay at labs7in0/E-cash.
Installation
Omnipay is installed via Composer. To install, simply add it
to your composer.json file:
{
"require": {
"labs7in0/omnipay-wechat": "dev-master"
}
}
And run composer to update your dependencies:
$ curl -s http://getcomposer.org/installer | php
$ php composer.phar update
Basic Usage
The following gateways are provided by this package:
- WeChat Express (WeChat NATIVE)
For general usage instructions, please see the main Omnipay repository.
Example
Make a payment
The WeChat NATIVE payment gateway return a URI which can be opened within WeChat In-App broswer, you can generate a QR code with the URI.
$omnipay = Omnipay::create('WeChat_Express'); $omnipay->setAppId('app_id'); // App ID of your WeChat MP account $omnipay->setAppKey('app_key'); // App Key of your WeChat MP account $omnipay->setMchId('partner_id'); // Partner ID of your WeChat merchandiser (WeChat Pay) account $params = array( 'out_trade_no' => time() . rand(100, 999), // billing id in your system 'notify_url' => $notify_url, // URL for asynchronous notify 'body' => $billing_desc, // A simple description 'total_fee' => 0.01, // Amount with less than 2 decimals places 'fee_type' => 'CNY', // Currency name from ISO4217, Optional, default as CNY ); $response = $omnipay->purchase($params)->send(); $qrCode = new Endroid\QrCode\QrCode(); // Use Endroid\QrCode to generate the QR code $qrCode ->setText($response->getRedirectUrl()) ->setSize(120) ->setPadding(0) ->render();
Verify a payment (especially for asynchronous notify)
completePurchase for Omnipay-WeChat does not require the same arguments as when you made the initial purchase call. The only required parameter is out_trade_no (the billing id in your system) or transaction_id (the trade number from WeChat).
$omnipay = Omnipay::create('WeChat_Express'); $omnipay->setAppId('app_id'); // App ID of your WeChat MP account $omnipay->setAppKey('app_key'); // App Key of your WeChat MP account $omnipay->setMchId('partner_id'); // Partner ID of your WeChat merchandiser (WeChat Pay) account $params = array( 'out_trade_no' => $billing_id, // billing id in your system //or you can use 'transaction_id', the trade number from WeChat ); $response = $omnipay->completePurchase($params)->send(); if ($response->isSuccessful() && $response->isTradeStatusOk()) { $responseData = $response->getData(); // Do something here }
Donate us
License
The MIT License (MIT)
More info see LICENSE
labs7in0/omnipay-wechat 适用场景与选型建议
labs7in0/omnipay-wechat 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 17.54k 次下载、GitHub Stars 达 37, 最近一次更新时间为 2015 年 08 月 11 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「payment」 「pay」 「gateway」 「merchant」 「purchase」 「omnipay」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 labs7in0/omnipay-wechat 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 labs7in0/omnipay-wechat 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 labs7in0/omnipay-wechat 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
repository php library
Payyo Gateway for the Omnipay payment processing library
Библиотека для приема платежей через Альфабанк.
Some pre-defined rules for validation in Omnipay payment processing library.
BluePay gateway for the Omnipay payment processing library
支付宝接口扩展包
统计信息
- 总下载量: 17.54k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 37
- 点击次数: 21
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-08-11