Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

如何初始化微信服务商模式Client #391

Closed
rickycoder opened this issue Apr 28, 2024 · 0 comments
Closed

如何初始化微信服务商模式Client #391

rickycoder opened this issue Apr 28, 2024 · 0 comments

Comments

@rickycoder
Copy link
Contributor

wechat.NewClientV3是否可以直传 appId和mchid,官方的例子只需要appId和 mchid

// NewClientV3 初始化微信客户端 v3
// mchid:商户ID 或者服务商模式的 sp_mchid
// serialNo:商户证书的证书序列号
// apiV3Key:apiV3Key,商户平台获取
// privateKey:私钥 apiclient_key.pem 读取后的内容
client, err = wechat.NewClientV3(MchId, SerialNo, APIv3Key, PrivateKey)

官方例子

https://pay.weixin.qq.com/docs/partner/products/partner-jsapi-payment/development.html
//请求URL
HttpPost httpPost = new HttpPost("https://api.mch.weixin.qq.com/v3/pay/transactions/jsapi");
// 请求body参数
String reqdata = "{"
+ ""amount": {"
+ ""total": 100,"
+ ""currency": "CNY""
+ "},"
+ ""mchid": "1900006891","
+ ""description": "Image形象店-深圳腾大-QQ公仔","
+ ""notify_url": "https://www.weixin.qq.com/wxpay/pay.php\","
+ ""payer": {"
+ ""openid": "o4GgauE1lgaPsLabrYvqhVg7O8yA"" + "},"
+ ""out_trade_no": "1217752501201407033233388881","
+ ""goods_tag": "WXG","
+ ""appid": "wxdace645e0bc2c424"" + "}";
StringEntity entity = new StringEntity(reqdata,"utf-8");
entity.setContentType("application/json");
httpPost.setEntity(entity);
httpPost.setHeader("Accept", "application/json");
//完成签名并执行请求
CloseableHttpResponse response = httpClient.execute(httpPost);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant