hahadu/wechat-pay
Composer 安装命令:
composer require hahadu/wechat-pay
包简介
微信支付,基于官方SDK
README 文档
README
###微信支付(基于官方SDK做PSR4支持)
- 安装:composer require hahadu/wechat-pay
命名空间对应:
Hahadu\WechatPay\Kernel\WxPayData => lib/WxPay.Data.php Hahadu\WechatPay\Kernel\WxPayApi => lib/WxPay.Api.php Hahadu\WechatPay\Kernel\WxPayException => lib/WxPay.Exception.php Hahadu\WechatPay\Kernel\WxPayNotify => lib/WxPay.Notify.php Hahadu\WechatPay\Kernel\config\WxPayConfigInterface => lib/WxPay.Config.Interface.php
使用
use Hahadu\WechatPay\Kernel\config\Config; Hahadu\WechatPay\Kernel\config\WxPayConfig //传入配置: $options = new Config(); $options->AppId = ‘’; //appid $options->MerchantId = ''; //MerchantId $options->NotifyUrl = ''; //NotifyUrl $options->Key = ''; //key $options->AppSecret = ''; //AppSecret // $options->SignType = ''; // SingType 默认值HMAC-SHA256 // $options->sandbox = true; //开启沙箱模式(微信支付仿真系统sandboxnew) $wechatConfig = new WxPayConfig($options);
扫码支付:
use Hahadu\WechatPay\Library\WechatNativePay; use Hahadu\WechatPay\Kernel\WxPayData\WxPayUnifiedOrder; $notify = new WechatNativePay($wechatConfig); $input = new WxPayUnifiedOrder(); $input->SetBody("test"); $input->SetOut_trade_no("sdkphp123456789".date("YmdHis")); $input->SetTotal_fee("1"); $input->SetTime_start(date("YmdHis")); $input->SetTime_expire(date("YmdHis", time() + 600)); $input->SetGoods_tag("test"); $input->SetTrade_type("NATIVE"); $input->SetProduct_id("123456789"); $result = $notify->GetPayUrl($input); $result["code_url"]; //微信支付二维码信息 示例weixin://wxpay/bizpayurl/up?pr=NwY5Mz9&groupid=00
JSAPI支付
use Hahadu\WechatPay\Library\WechatJsApiPay; use Hahadu\WechatPay\Kernel\WxPayData\WxPayUnifiedOrder; use Hahadu\WechatPay\Kernel\WxPayApi; $tools = new WechatJsApiPay($wechatConfig); $openId = $tools->GetOpenid(); //获取微信OpenID //②、统一下单 $input = new WxPayUnifiedOrder(); $input->SetBody("test"); //订单标题 $input->SetOut_trade_no("sdkphp".date("YmdHis")); //商户订单号 $input->SetTotal_fee("1"); //订单金额 $input->SetTime_start(date("YmdHis")); //订单创建时间 $input->SetTrade_type("JSAPI"); //支付方式 $input->SetOpenid($openId); $order = WxPayApi::unifiedOrder($this->wechatConfig, $input); $jsApiParameters = $tools->GetJsApiParameters($order); //获取共享收货地址js函数参数 $editAddress = $tools->GetEditAddressParameters(); $result= [ 'jsApiParameters' =>$jsApiParameters, 'editAddress' => $editAddress, 'order' => $order, ];
hahadu/wechat-pay 适用场景与选型建议
hahadu/wechat-pay 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 12 次下载、GitHub Stars 达 0, 最近一次更新时间为 2020 年 10 月 13 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 hahadu/wechat-pay 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 hahadu/wechat-pay 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 12
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: Apache-2.0
- 更新时间: 2020-10-13