代码拉取完成,页面将自动刷新
<?php
/**
* Created by PhpStorm.
* User: lmg
* Date: 2022/12/9 13:39
*/
require_once __DIR__ . '/vendor/autoload.php';
use Calculation\Payment\wxpay\Pay;
$config = [
// 公众账号ID
'appId' => 'wxf2892bd30a5fff83',
// 微信公众号appSecret
'appSecret' => '799d075e6b7c22e02066f3bf5b1bdaf3',
// 商户号
'mchId' => '1565611061',
// 支付密钥
'key' => 'uedjuuhGgyGGyygbh67t7buUFRttcvgg',
// 签名类型
'signType' => 'RSA2',
// 公众号ID
'publicAppId' => 'wx335071f7faf735e2',
// 小程序ID
'appletsAppId' => 'wxf2892bd30a5fff83',
// 异步通知地址
'notifyUrl' => 'api/v1/pays/wx_notify',
// 证书路径
'sslCertPath' => './src/Payment/wxpay/apiclient_cert.pem',
'sslKeyPath' => './src/Payment/wxpay/apiclient_key.pem',
];
// h5订单支付数据
$order = [
'body' => '测试购买商品',
'goods_name' => '人教版小学数学二年级',
'order_id' => rand(100000000000, 9999999999999),
'goods_total_price' => 0.01,
'return_url' => 'https://test.government.api.vars3cf.com',
];
// 小程序订单支付数据
$order1 = [
'body' => '测试购买商品',
'goods_name' => '人教版小学数学二年级',
'order_id' => rand(100000000000, 9999999999999),
'goods_total_price' => 0.01,
'return_url' => 'https://test.government.api.vars3cf.com',
'openid' => 'oisBUxImVfo30ICJgE5KbNqleM1U',
];
$wxPay = new Pay();
$wxPay->setOptions($config);
// wap支付
// $res = $wxPay->unifiedOrderForWap($order);
// 小程序支付
// $res = $wxPay->unifiedOrderForApplets($order1);
// 公众号支付
// $res = $wxPay->unifiedOrderForPublic($order1);
// 扫码支付
// $res = $wxPay->unifiedOrderForPublicNATIVE($order);
// 查询订单
// $res = $wxPay->query(167039003901800);
var_dump($res);die;
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。