老项目要上新功能,建议混合PHP版本开发, PHP7.1及以上使用 wechatpay-php 做个内部http接口服务,php56直接调用这个http服务,省却折腾环境了。 另外,从crypto_aead_aes256gcm_is_available 方法的官方文档看,貌似是你的硬件不支持AESGCM,详细见: https://www.php.net/manual/en/function.sodium-crypto-aead-aes256gcm-is-available.php [图片]
微信支付 php5.6 安装libsodium-php 运行还是报错,不能使用微信支付服务端接入报错 服务端 php 5.6 接的是 wechatpay-guzzle-middleware,运行代码报错如下: download failed, message=[AEAD_AES_256_GCM需要PHP 7.1以上或者安装libsodium-php] exception 'RuntimeException' with message 'AEAD_AES_256_GCM需要PHP 7.1以上或者安装libsodium-php' 由于php版本5.6,比较旧的版本,按照提示安装的libsodium-php [图片] 下载libsodium 1.0.6 版本,扩展成功 [图片] 运行代码还是失败, function_exists('\Sodium\crypto_aead_aes256gcm_is_available' ) 可以检测到方法,但是返回false \Sodium\crypto_aead_aes256gcm_decrypt 方法不存在, 请问有没有人遇到这个问题啊,怎么解决呢?
2022-05-26使用Java加载密钥时,抛出异常InvalidKeyException: Illegal key size受到美国法律的约束,早期Java的运行时限制了JCE支持的密钥长度,即默认不支持256位的AES。解决的方法有三个: (推荐)升级Java 8u162+,默认使用ulimited policyJava 8u151和8u152,可以在你的程序中直接放开策略Security.setProperty("crypto.policy", "unlimited"); 其他版本,下载无限强度权限策略文件补丁包,并使用其中的文件覆盖[代码]$JAVA_HOME/lib/security[代码]目录下的对应的[代码]local_policy.jar[代码] 和[代码]US_export_policy.jar[代码]Java9及以上,均无限制。
微信支付,如何加载商户私钥,提示Illegal base64 character 2d,如果解決[图片] [图片]
2022-05-24从APIv3到APIv2再到企业微信,这款微信支付开发包的README你应该来读一读
/v3/pay/transactions 签名错误,检查充实参数 qurry:{ // 应用ID appid:"******", // 直连商户号 mchid:"*****", // 商品描述 description: "不良资产交易", // 商户订单号 out_trade_no:"100860", // 通知地址 notify_url:"*****", amount:{ total:1, currency:"CNY" }, payer:{ openid:"**********" } 签名 let str = JSON.stringify(this.data.qurry); let autograph='post'+'\n'+'/v3/pay/transactions/jsapi'+'\n'+'1653314370'+'\n'+'593BEC0C930BF1AFEB40B4A08C8FB242'+'\n'+str+'\n'; let SHA=EncryptUtils.SHA256(autograph) console.log("签名",SHA) base64加密 let base64=EncryptUtils.Base64EnCode(SHA) 报错 "code: "SIGN_ERROR" detail: {detail: {issue: "sign not match"}, field: "signature", location: "authorization",…} detail: {issue: "sign not match"} issue: "sign not match" field: "signature" location: "authorization" sign_information: {method: "POST", sign_message_length: 320,…} method: "POST" sign_message_length: 320 truncated_sign_message: "POST↵/v3/pay/transactions/jsapi↵1653314370↵593BEC0C930BF1AFEB40B4A08C8FB242↵{"appid"↵" url: "/v3/pay/transactions/jsapi" message: "签名错误,请检查后再试" cod
2022-05-24当前已知这个客诉图片下载的图片URL上,可能含percent-encoded字符串,这个如果稍微不注意就会报400错误(签名失败),如果你使用的是PHPsdk,建议参考这里的测试用例,进行校准实现。 https://github.com/wechatpay-apiv3/wechatpay-php/blob/main/tests/OpenAPI/V3/MerchantService/Images/DownloadTest.php#L168-L214
消费者投诉—图片下载API 接口返回状态码400消费者投诉—图片下载接口,有的media_url接口调用失败,返回400; 1. 部分图片显示不了,不是全部。调用"下载图片"接口,返回只返回状态码为400; 2. 图片是通过调用"提交回复"接口上传的(经过了"商户上传反馈图片"接口); 3. 存在同时上传两张图片,一张正常下载,另一张下载失败的情况; 4. 对应的有效期为1个小时的图片链接能够正常显示; 5. c端用户问题图片可以正常显示; 6. 商户后台问题图片也显示不了; 7. 上传的图片大小,格式正常; 微信投诉单号:200298120220406100525162386;微信支付单号:4200001348202203036740973661;商户号:1520058051;问题图片对应历史协商记录流水号:300298120220406170526095864; ps. 下面截图中,上面一条meida_url是失败的,下面一条media_url是成功的。 [图片] ps.后台查询投诉协商历史记录(红框圈出的是显示失败的图片),证明了"存在同时上传两张图片,一张正常下载,另一张下载失败的情况" [图片] ps.下面是对应的c端显示截图 [图片] ps. 使用postman请求图片成功与失败截图: [图片] curl --location --request GET 'https://api.mch.weixin.qq.com/v3/merchant-service/images/ChsyMDAyOTgxMjAyMjAzMjgxODA1MTAzNTAyMDUSGzMwMDI5ODEyMDIyMDMyOTE0MDUxMTYzODUxOBgBINDb2JIGKAMwAjgB' \ --header 'Authorization: WECHATPAY2-SHA256-RSA2048 mchid="1520058051",serial_no="48169270ABF64B3FC91CBC60EBF2B9D8017D6F89",nonce_str="1649920239019",timestamp="1649920239",signature="uVdVx3xFjAY/mzkdgTe2GwBTyPnGC59ioDxZO+InnTg3EMUJ/ODbaCqjLSAPChWsB8+nMN/XapjCIp+PA6cWqrN+qkSbdBwp9uczXz1sFxfBiEpVEtGb26ByjRj7+SwtyxiUvPN2dJzqKM4m4H2h/eOkHSxTKvBHO2y6Nb0ujdiLdWm5xqEeCgi4hGpkNqjo+TYlmnQ69ia3JHSy2+EHjydcVGKe+X1WQtoEfe0UbQ7vOYSzq0mRggkspLuoZ2/8rJct6YVDMw+xNjeJF8fuYBOpvjmFWcijbfYc2XGmwV1Cdaiv/t73os+tiQntKXZ5C01/Ub7S4WnKvoLgVwKd5A=="' [图片] curl --location --request GET 'https://api.mch.weixin.qq.com/v3/merchant-service/images/ChsyMDAyOTgxMjAyMjA0MDYxMDA1MjUxNjIzODYSGzMwMDI5ODEyMDIyMDQwNzE0MDUyNzUzODg4MRgBIJuQupIGKAMwAjgB' \ --header 'Authorization: WECHATPAY2-SHA256-RSA2048 mchid="1520058051",serial_no="48169270ABF64B3FC91CBC60EBF2B9D8017D6F89",nonce_str="1649920208112",timestamp="1649920208",signature="xPxG9ER2hqZPV0g98pH4Rlb3ThrdRKftSkRkQBjv9MafKmTgYPcGx26wMlNeRHH2FDTQSl06gd3O5WeTsNiGZpqPCqmzXzlL1xqnnC7HLhDKcc1JEEqkxiUy1jO+fDXGBFuVYPqHcXZM+vvRrEkADNfdoYeACqoMgfpJy/juW3REKPVa8LwWvtEFDMzxg7PUitFn1e//FMFu1Ek4FfpM+fFzM93oIxkgJRhWcdzFzne2HiQtza4DmLMakq4239iUwW9QeESAiXMAsY5DdGZfJj8Nxt/erh7q6X6KZXVvPvHjhLdxopUhqHC0ZKqZKt5zy5Kqf46PaTDBzgprAt3W5Q=="' [图片] postman中安装了wechatpay-apiv3脚本
2022-04-01<?php print_r($instance);exit; 即打印出类似如下的信息,以此就可以按照README上的例子,发起HTTP请求了: <?php ArrayIterator@anonymous Object ( [driver:protected] => WeChatPay\ClientDecorator Object ( [v2:protected] => GuzzleHttp\Client Object ( [config:GuzzleHttp\Client:private] => Array ( [base_uri] => GuzzleHttp\Psr7\Uri Object ( [scheme:GuzzleHttp\Psr7\Uri:private] => https [userInfo:GuzzleHttp\Psr7\Uri:private] => [host:GuzzleHttp\Psr7\Uri:private] => api.mch.weixin.qq.com [port:GuzzleHttp\Psr7\Uri:private] => [path:GuzzleHttp\Psr7\Uri:private] => / [query:GuzzleHttp\Psr7\Uri:private] => [fragment:GuzzleHttp\Psr7\Uri:private] => [composedComponents:GuzzleHttp\Psr7\Uri:private] => ) [headers] => Array ( [Accept] => text/xml, text/plain, application/x-gzip [Content-Type] => text/xml; charset=utf-8 [User-Agent] => wechatpay-php/1.4.3 GuzzleHttp/7 curl/7.82.0 (Darwin/17.7.0) PHP/8.1.3 ) [allow_redirects] => Array ( [max] => 5 [protocols] => Array ( [0] => http [1] => https ) [strict] => [referer] => [track_redirects] => ) [http_errors] => 1 [decode_content] => 1 [verify] => 1 [cookies] => [idn_conversion] => ) ) [v3:protected] => GuzzleHttp\Client Object ( [config:GuzzleHttp\Client:private] => Array ( [base_uri] => GuzzleHttp\Psr7\Uri Object ( [scheme:GuzzleHttp\Psr7\Uri:private] => https [userInfo:GuzzleHttp\Psr7\Uri:private] => [host:GuzzleHttp\Psr7\Uri:private] => api.mch.weixin.qq.com [port:GuzzleHttp\Psr7\Uri:private] => [path:GuzzleHttp\Psr7\Uri:private] => / [query:GuzzleHttp\Psr7\Uri:private] => [fragment:GuzzleHttp\Psr7\Uri:private] => [composedComponents:GuzzleHttp\Psr7\Uri:private] => ) [headers] => Array ( [Accept] => application/json, text/plain, application/x-gzip, application/pdf, image/png, image/*;q=0.5 [Content-Type] => application/json; charset=utf-8 [User-Agent] => wechatpay-php/1.4.3 GuzzleHttp/7 curl/7.82.0 (Darwin/17.7.0) PHP/8.1.3 ) [allow_redirects] => Array ( [max] => 5 [protocols] => Array ( [0] => http [1] => https ) [strict] => [referer] => [track_redirects] => ) [http_errors] => 1 [decode_content] => 1 [verify] => 1 [cookies] => [idn_conversion] => ) ) ) [storage:ArrayIterator:private] => Array ( ) )
微信支付wechatpay-php,构建APIv3 客户端实例出错,返回空值PHP执行以下语句时,返回[],请各位大神帮忙解决! $instance = Builder::factory([ 'mchid' => $merchantId, 'serial' => $merchantCertificateSerial, 'privateKey' => $merchantPrivateKeyInstance, 'certs' => [ $platformCertificateSerial => $platformPublicKeyInstance, ], ]);
2022-03-16要查你调用的是哪个接口,对于要求ssl证书的接口,当没设置时,很容易在https建立连接之时就被断开连接了,respond 就啥都没有。
api.mch.weixin.qq.com:443 failed to respond?javax.xml.ws.WebServiceException: org.apache.http.NoHttpResponseException: api.mch.weixin.qq.com:443 failed to respond 发起预支付的时候,线上偶尔出现此异常,一天只有十几笔,我们现在http用的 apache 的 httpclient 工具
2022-03-16不支持
企业付款至零钱 是否支持沙盒环境https://api.mch.weixin.qq.com/xdc/apiv2sandbox/mmpaymkttransfers/promotion/transfers 企业付款至零钱 是否支持沙盒环境
2022-03-16登录 pay.weixin.qq.com 在产品中心 -> aped授权管理 -> 发起绑定,只有绑定后才可以用此appid发起支付。详见 商家商户号与AppID账号关联管理
微信app支付开通了不同主体商户号联合运营,但下单报错appid和mch_id不匹配,请问什么原因?微信app支付开通了不同主体商户号联合运营,但下单报错appid和mch_id不匹配,请问这是什么原因?
2022-03-16`multipart/form-data; boundary=xxxx` 缺了点儿东西。。。
上传临时素材提示media data missing?[图片] [图片] [图片]
2022-03-11谢邀:建议用官方的jar包,https://github.com/wechatpay-apiv3/wechatpay-apache-httpclient Central源就能安装到。。。。 https://search.maven.org/artifact/com.github.wechatpay-apiv3/wechatpay-apache-httpclient
Http头Authorization值格式错误,请参考《微信支付商户REST API签名规则》?按照官方文档https://pay.weixin.qq.com/wiki/doc/apiv3/wechatpay/wechatpay4_0.shtml的步骤, 获取签名时,依然报 ‘Http头Authorization值格式错误,请参考《微信支付商户REST API签名规则》’。但是我觉得最离谱的是,把官网的命令复制下来执行后,依然报此错误,按理说是报数据错误,各非格式问题。有人员能解答一下吗? [图片][图片] 以下是获取签名信息的代码,同样也是官方给的示例代码: public static void main(String[]args) throws Exception { //认证类型 String schema = "WECHATPAY2-SHA256-RSA2048"; String httpurl = "/v3/certificates"; String httpAuthorization = getAuthorization("GET", httpurl, ""); String curl = "curl https://api.mch.weixin.qq.com/v3/certificates -H 'Authorization: WECHATPAY2-SHA256-RSA2048 " + httpAuthorization + "'"; System.out.println(curl); } /** * 得到签名信息 * @param method * @param url * @param body * @return * @throws Exception */ public static String getAuthorization(String method, String url, String body) throws Exception { String nonceStr = StrUtil.generateNonceStr(); long timestamp = System.currentTimeMillis() / 1000; //获取签名串 String message = buildMessage(method, url, timestamp, nonceStr, body); System.out.println("签名串:"+message); //得到签名 String signature = sign(message.getBytes("utf-8")); System.out.println("签名值:"+signature); //五项签名信息,无顺序要求 String httpAuthorization = "mchid=\"" + MCHID_JDKJ + "\"," + "nonce_str=\"" + nonceStr + "\"," + "signature=\"" + signature + "\"," + "timestamp=\"" + timestamp + "\"," + "serial_no=\"" + MCHSERIALNO_JDKJ + "\"" ; System.out.println("httpAuthorization:" + httpAuthorization); return httpAuthorization; } /** * 获取签名值 * @param message * @return * @throws Exception */ public static String sign(byte[] message) throws Exception { Signature sign = Signature.getInstance("SHA256withRSA"); //# 示例:私钥存储在文件 // PrivateKey merchantPrivateKey = PemUtil.loadPrivateKey(new FileInputStream("D:\\test\\apiclient_key.pem")); PrivateKey merchantPrivateKey = getPrivateKey("D:\\test\\apiclient_key.pem"); sign.initSign(merchantPrivateKey); sign.update(message); return Base64.getEncoder().encodeToString(sign.sign()); } /** * 获取私钥。 * @param filename 私钥文件路径 (required) * @return 私钥对象 */ public static PrivateKey getPrivateKey(String filename) throws IOException { String content = new String(Files.readAllBytes(Paths.get(filename)), "utf-8"); try { String privateKey = content.replace("-----BEGIN PRIVATE KEY-----", "") .replace("-----END PRIVATE KEY-----", "") .replaceAll("\\s+", ""); KeyFactory kf = KeyFactory.getInstance("RSA"); return kf.generatePrivate( new PKCS8EncodedKeySpec(Base64.getDecoder().decode(privateKey))); } catch (NoSuchAlgorithmException e) { throw new RuntimeException("当前Java环境不支持RSA", e); } catch (InvalidKeySpecException e) { throw new RuntimeException("无效的密钥格式"); } } /** * 构造签名串 * 签名串一共有五行,每一行为一个参数。行尾以 \n(换行符,ASCII编码值为0x0A)结束,包括最后一行。如果参数本身以\n结束,也需要附加一个\n * HTTP请求方法\n * URL\n * 请求时间戳\n * 请求随机串\n * 请求报文主体\n * @param method * @param url * @param timestamp * @param nonceStr * @param body * @return * @throws Exception */ public static String buildMessage(String method, String url, long timestamp, String nonceStr, String body) { return method + "\n" + url + "\n" + timestamp + "\n" + nonceStr + "\n" + body + "\n"; } 最后生成的签名信息如下: [图片] 最后使用命令执行结果如下: [图片] 请问这是哪里的问题
2022-03-10