fix: 更新支付案例及配置

This commit is contained in:
邹景立 2025-03-03 19:25:51 +08:00
parent 1095b6c192
commit 78c941a558
14 changed files with 92 additions and 31 deletions

View File

@ -57,9 +57,9 @@ abstract class BasicWePay
'mch_v3_key' => '', // 微信商户密钥,需要配置
'cert_serial' => '', // 商户证书序号,无需配置
'cert_public' => '', // 商户公钥内容,需要配置
'cert_private' => '', // 商户密钥内容,需要配置Ï
'cert_private' => '', // 商户密钥内容,需要配置
'mp_cert_serial' => '', // 平台证书序号,无需配置 ( 新平台,当做微信支付证书用 )
'mp_cert_content' => '', // 平台证书内容,无需配置 ( 新平台,当做微信支付证书Ï用 )
'mp_cert_content' => '', // 平台证书内容,无需配置 ( 新平台,当做微信支付证书用 )
];
/**

View File

@ -45,13 +45,8 @@ return [
'appid' => 'wx60a43dd8161666d4',
'appsecret' => 'b4e28746f1bd73b5c6684f5e01883c36',
'encodingaeskey' => 'BJIUzE0gqlWy0GxfPp4J1oPTBmOrNDIGPNav1YFH5Z5',
// 配置商户支付参数
'mch_id' => "1332187001",
'mch_key' => 'A82DC5BD1F3359081049C568D8502BC5',
// 配置商户支付双向证书目录 p12 | key,cert 二选一两者都配置时p12优先
'ssl_p12' => __DIR__ . DIRECTORY_SEPARATOR . 'cert' . DIRECTORY_SEPARATOR . '1332187001_20181030_cert.p12',
// 'ssl_key' => __DIR__ . DIRECTORY_SEPARATOR . 'cert' . DIRECTORY_SEPARATOR . '1332187001_20181030_key.pem',
// 'ssl_cer' => __DIR__ . DIRECTORY_SEPARATOR . 'cert' . DIRECTORY_SEPARATOR . '1332187001_20181030_cert.pem',
// 配置缓存目录,需要拥有写权限
'cache_path' => '',
// 其他支付参数可以合并在这里
// ...
];

54
_test/pay-config.php Normal file
View File

@ -0,0 +1,54 @@
<?php
// +----------------------------------------------------------------------
// | WeChatDeveloper
// +----------------------------------------------------------------------
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
// +----------------------------------------------------------------------
// | 官方网站: https://thinkadmin.top
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// | 免责声明 ( https://thinkadmin.top/disclaimer )
// +----------------------------------------------------------------------
// | gitee 代码仓库https://gitee.com/zoujingli/WeChatDeveloper
// | github 代码仓库https://github.com/zoujingli/WeChatDeveloper
// +----------------------------------------------------------------------
// =====================================================
// 配置缓存处理函数 ( 适配其他环境 )
// -----------------------------------------------------
// 数据缓存 (set|get|del) 操作可以将缓存写到任意位置或Redis
// 文件缓存 (put) 只能写在本地服务器,还需要返回可读的文件路径
// 未配置自定义缓存处理机制时,默认在 cache_path 写入文件缓存
// // =====================================================
// \WeChat\Contracts\Tools::$cache_callable = [
// 'set' => function ($name, $value, $expired = 360) {
// var_dump(func_get_args());
// return $value;
// },
// 'get' => function ($name) {
// var_dump(func_get_args());
// return $value;
// },
// 'del' => function ($name) {
// var_dump(func_get_args());
// return true;
// },
// 'put' => function ($name) {
// var_dump(func_get_args());
// return $filePath;
// },
// ];
return [
'appid' => 'wx60a43dd8161666d4',
// 配置商户支付参数
'mch_id' => "1332187001",
'mch_key' => 'A82DC5BD1F3359081049C568D8502BC5',
// 配置商户支付双向证书目录 p12 | key,cert 二选一两者都配置时p12优先
'ssl_p12' => __DIR__ . DIRECTORY_SEPARATOR . 'cert' . DIRECTORY_SEPARATOR . '1332187001_20181030_cert.p12',
// 'ssl_key' => __DIR__ . DIRECTORY_SEPARATOR . 'cert' . DIRECTORY_SEPARATOR . '1332187001_20181030_key.pem',
// 'ssl_cer' => __DIR__ . DIRECTORY_SEPARATOR . 'cert' . DIRECTORY_SEPARATOR . '1332187001_20181030_cert.pem',
// 配置缓存目录,需要拥有写权限
'cache_path' => '',
];

View File

@ -20,7 +20,7 @@ try {
include "../include.php";
// 2. 准备公众号配置参数
$config = include "./config.php";
$config = include "./pay-config.php";
// 3. 创建接口实例
// $wechat = new \WeChat\Pay($config);

View File

@ -20,7 +20,7 @@ try {
include "../include.php";
// 2. 准备公众号配置参数
$config = include "./config.php";
$config = include "./pay-config.php";
// 3. 创建接口实例
// $wechat = new \WeChat\Pay($config);

View File

@ -20,7 +20,7 @@ try {
include "../include.php";
// 2. 准备公众号配置参数
$config = include "./config.php";
$config = include "./pay-config.php";
// 3. 创建接口实例
// $wechat = new \WeChat\Pay($config);

View File

@ -20,7 +20,7 @@ try {
include "../include.php";
// 2. 准备公众号配置参数
$config = include "./config.php";
$config = include "./pay-config.php";
// 3. 创建接口实例
// $wechat = new \WeChat\Pay($config);

View File

@ -20,7 +20,7 @@ try {
include "../include.php";
// 2. 准备公众号配置参数
$config = include "./config.php";
$config = include "./pay-config.php";
// 3. 创建接口实例
// $wechat = new \WeChat\Pay($config);

View File

@ -20,7 +20,7 @@ try {
include "../include.php";
// 2. 准备公众号配置参数
$config = include "./config.php";
$config = include "./pay-config.php";
// 3. 创建接口实例
// $wechat = new \WePay\Redpack($config);

View File

@ -20,7 +20,7 @@ try {
include "../include.php";
// 2. 准备公众号配置参数
$config = include "./config.php";
$config = include "./pay-config.php";
// 3. 创建接口实例
// $wechat = new \WeChat\Pay($config);

View File

@ -20,7 +20,7 @@ try {
include "../include.php";
// 2. 准备公众号配置参数
$config = include "./config.php";
$config = include "./pay-config.php";
// 3. 创建接口实例
// $wechat = new \WeChat\Pay($config);

View File

@ -20,7 +20,7 @@ try {
include "../include.php";
// 2. 准备公众号配置参数
$config = include "./config.php";
$config = include "./pay-config.php";
// 3. 创建接口实例
// $wechat = new \WeChat\Pay($config);

View File

@ -20,7 +20,7 @@ try {
include "../include.php";
// 2. 准备公众号配置参数
$config = include "./config.php";
$config = include "./pay-config.php";
// 3. 创建接口实例
// $wechat = new \WeChat\Pay($config);

View File

@ -16,16 +16,24 @@
$certPublic = <<<CERT
-----BEGIN CERTIFICATE-----
你的微信商户证书公钥内容
具体证书全文内容
-----END CERTIFICATE-----
CERT;
$certPrivate = <<<CERT
-----BEGIN PRIVATE KEY-----
你的微信商户证书私钥内容
具体证书全文内容
-----END PRIVATE KEY-----
CERT;
// 支付证书内容
$certPayment = <<<CERT
-----BEGIN PUBLIC KEY-----
具体证书全文内容
-----END PUBLIC KEY-----
CERT;
// =====================================================
// 配置缓存处理函数 ( 适配其他环境 )
// -----------------------------------------------------
@ -54,17 +62,21 @@ CERT;
return [
// 可选公众号APPID
'appid' => '',
'appid' => 'wxbbc5782d4d77a43b',
// 必填微信商户编号ID
'mch_id' => '',
'mch_id' => '1643053551',
// 必填微信商户V3接口密钥
'mch_v3_key' => '',
// 可选,微信商户证书序列号,可从公钥中提取
'mch_v3_key' => 'ThinkAdminThinkAdminThinkAdminTh',
// 可选,微信商户证书序列号,可从公钥中提取,请求签名使用
'cert_serial' => '',
// 必填,微信商户证书公钥,支持证书内容或文件路径
// 必填,微信商户证书公钥,支持证书内容或文件路径,仅用于提取序号
'cert_public' => $certPublic,
// 必填,微信商户证书私钥,支持证书内容或文件路径
// 必填,微信商户证书私钥,支持证书内容或文件路径,用请求数据签名
'cert_private' => $certPrivate,
// 可选,微信平台证书序号或支付证书序号,用于接口请求序号
'mp_cert_serial' => 'PUB_KEY_ID_0116430535512025030300389200001906',
// 可选,微信平台证书内容或支付证书内容
'mp_cert_content' => $certPayment,
// 可选,运行时的文件缓存路径
'cache_path' => ''
];