Download the PHP package qinii/wechat-payment without Composer

On this page you can find all versions of the php package qinii/wechat-payment. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package wechat-payment

qinii/wechat-payment

基于 EasyWeChat 6 的微信支付业务封装。扩展包按普通商户、服务商、合单、退款、商家转账、分账、子商户进件和通知划分业务边界,并根据当前账号配置中的 version 自动选择 API V2 或 API V3,调用方不需要选择版本 DTO。

完整的方法、DTO 和版本支持情况请查看 已实现功能清单。清单中未列出的方法,不代表微信支付没有该能力,只表示本扩展包目前没有提供对应封装。

环境要求

安装

已实现模块

模块 门面入口 API 版本 主要能力
普通商户支付 $payment->payment() V2 / V3 下单、查单、关单、退款、退款查询、异常退款
服务商支付 $payment->partner() V2 / V3 下单、查单、关单、退款、账单及 V2 付款码配套接口
合单支付 $payment->combine() V3 JSAPI/小程序、APP、H5、Native、查单、关单、退款
商家转账到零钱 $payment->transfer() V3 转账、撤销、查询、电子回单、免确认收款授权流程
分账 $payment->profitSharing() V2 / V3 普通商户、服务商和电商收付通分账
子商户进件 $payment->merchant() V3 特约商户、电商收付通二级商户进件及资料上传
回调通知 $payment->notify() V2 / V3 支付、退款、转账、分账通知验签、解密和应答

“已实现”表示扩展包已提供请求组装和调用入口。接口能否在真实商户号下使用,仍取决于微信支付产品权限、商户类型和产品开通状态。

配置

配置第一层是账号组。每个账号组包含应用配置,以及普通商户 payment、服务商 partner 两个支付配置。支付节点中的 app_id 会根据支付类型从 official_account、mini_program 或 app 节点读取,不需要重复配置。

配置注意事项:

创建门面

也可以通过容器注入 Qinii\WechatCore\Config\ConfigResolver 后实例化 Payment。多账号配置使用 account() 切换;它会返回新门面,不会修改原实例:

普通商户下单

同一个 PaymentDto 同时用于 V2/V3,具体版本由 payment.version 决定。

支持的 pay_type:

pay() 是 create() 的兼容别名。下单发生网络中断、SYSTEMERROR 或付款码返回 USERPAYING 时,不应直接判定失败,应主动调用查单接口确认最终状态。

服务商下单

服务商仍从配置中的 app_id、mch_id 读取服务商 AppID 和商户号,Builder 会在请求时转换为微信接口要求的 sp_appid、sp_mchid。为了统一调用方式,服务商 AppID 下的用户标识仍通过 DTO 的 openid 传入。

使用子商户 AppID 下的用户标识时,同时传入 sub_appid 和 sub_openid。服务商 V2/V3 均支持 JSAPI/小程序、APP、H5 和 Native;付款码仅 V2 支持。

查单与关单

API V2 查询和关单需要原下单 AppID。普通商户可以通过第二个参数传入原支付类型;服务商可以通过第三个参数传入原下单 sub_appid。

退款

退款使用独立 DTO,不复用支付 DTO。普通退款与服务商退款均根据各自配置自动选择 V2/V3。

平台收付通退款不会根据字段自动推断,调用方应显式使用 ecommerceRefund()。普通退款、平台收付通退款、合单退款和异常退款的完整入口见 退款功能清单。

商家转账到零钱

未单独设置 payment.app_id 时,默认使用 payment.default_application 对应的 AppID。若收款人的 OpenID 属于其他应用,在服务入口选择该应用;选择操作返回新实例,不影响原服务:

同一入口可继续调用查询、撤销、电子回单和免确认收款授权等方法。application('mini_program') 从当前账号组的 mini_program.app_id 读取 AppID;也可选择 official_account 或 app。应用配置缺失时会抛出配置异常。

回调通知

通知入口接收 PSR-7 ServerRequestInterface。内部复用 EasyWeChat 完成 V2 XML 或 V3 JSON 的验签与解密,并返回统一的 Notification 对象。

其他入口为 refund()、transfer() 和 profitSharing()。验签或解密失败时会抛出 PaymentException,业务端不得返回成功应答。

HTTP Client

setHttpClient() 接收实现 Symfony\Contracts\HttpClient\HttpClientInterface 的实例,不接受类名字符串。设置后的客户端会被支付请求、证书下载及各业务模块共同使用。

在 Swoole 环境中应注入兼容的客户端实例,避免底层 cURL 客户端设置 Swoole 不支持的选项。

异常处理

验证

协议测试不会连接微信或产生真实交易。正式上线前仍应使用真实商户环境分别验收下单、前端调起、支付/退款通知、主动查单、关单、异常流程及已开通的增值能力。

相关文档


All versions of wechat-payment with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
nyholm/psr7 Version ^1.5
psr/http-message Version ^1.0|^2.0
w7corp/easywechat Version ^6.19.1
qinii/wechat-core Version ^1.0.0
symfony/http-client-contracts Version ^3.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package qinii/wechat-payment contains the following files

Loading the files please wait ...