- sdk下载平台证书报错?
[GuzzleHttp\Exception\RequestException] Verify the response's data with: timestamp=1755073150, nonce=879967edfa4b1c8b4166f6ff66e42f28, signature=L3gTQr6zt6fBsMSFsy5ZQAu8ry3T WzFA3cKJQdeLcf2Dsx0JneKusSHbwi7B9KpPS6P+KLlVeyKGdpI3/8vDYnfA9g2Fcz3gEQnl2eAyusl73QXQ/WKGLgWNVDPP9kg+cA/dWu9vqu9DRxKnT+Hil6y9HnluVgqUh 2DJCejTXw0XLqjxstHs3yYrQnp/0UJVoCX0UNXVwyNz7kLy/ivTpsywVXi/OL4vivKVK1AzHuPmDwfIQBvp7I8q5TOeueoEF3uRNdYo+Ctx0eGzyPWppWtG0jZT2w5Y9gIkUt IjHj5i8lL2wliyH36fo+aWkMmVrIF0r1Pl0kI5Qh5eAmtGxw==, cert=[50824E646E99D28C342ED5B3F4BCC2F110D5BFEB => ...] failed. [think\exception\ErrorException] openssl_verify(): supplied key param cannot be coerced into a public key
星期三 16:24 - sdk查询订单?
/** * 查询支付订单 * @param string $outTradeNo 商户订单号 * @return array 查询结果 */ public function queryTransaction($outTradeNo, $subMchId = null) { dump($outTradeNo); $resp = $this->instance ->chain("v3/pay/partner/transactions/out-trade-no/{$outTradeNo}?sp_mchid={$this->merchantId}&sub_mchid={$subMchId}") ->get(); return json_decode((string)$resp->getBody(), true); } string(16) "G811056952376119" [GuzzleHttp\Exception\ClientException] Client error: `GET https://api.mch.weixin.qq.com/v3/pay/partner/transactions/out-trade-no/-g811056952376119?sp_mchid=1723325576 &sub_mchid=1724710712` resulted in a `404 Not Found` response: {"code":"ORDER_NOT_EXIST","message":"订单不存在"} 访问接口订单号就变了
08-12 - sdk解密报错?
Decrypting the input $ciphertext failed, please checking your $key and $iv whether or nor correct.
08-12 - 支付回调解析?
array(5) { ["original_type"] => string(11) "transaction" ["algorithm"] => string(16) "AEAD_AES_256_GCM" ["ciphertext"] => string(644) "3Oco8PrfpiSJJwh6stg+YkGZ3ZJQSfhY/nIJ2Ph6B2VeGgv6Laf+yl1XBoZrVe/mC+xFJ2lku8UFIOi2a8YsvaTc2u4wESf/vn3Kwf/G7BFISgLsVKC/ojB26/r16b9vzBIhRIs8tIXdtPVj2p+7pL1xouLlK/MGCjKDDL9a+/1i6bqN2qQ6iEKlpSnoWo6sPqIj78I11rvr0qg7Cfr9qGeAtIAhG0cgO/kwcutpkzeEwJCPXzsnlW0RUJKm/Hi3ypKjaJH5RzBEbiJA7eaQK9i6g5bA9quzhfitR0flDUfVoL4cdWUfS1y5msMvGw6oJtwucX5X7qX57rl6+D+h+DKAuXD+qZT/leN7e6E2rPHdmjfJHH2MRr4J5U/DvbLWPL+BFW8/aaBXkXIuk4Rj+x/3cGX5GGBdB9BAJAJfDcF6T/wyR3KBefDXS2/r+RUPfNBrzPdfnKR08qWSLzMvkW+rVyfYjwsPUk+t3oQZapcJdk++4FzAnqhQZTAZCewvnqs+6vSWErvadnQRSfQQcon4ILj5n+2kfOg6YVBJBxeqySqTIhDeREscR43oJ1lz1155APWXDovQAmc6yTcAbuXHXimVLbmilHKwdhp0KNcV4kE7QLqH5I9LJ4OOY4A4GZPb" ["associated_data"] => string(11) "transaction" ["nonce"] => string(12) "fdybR6WuEb6b" } string(32) "7fH9q2Wb4Kp6Lm8n3Rt0yZ1xVc5Ds9aJ" $decryptedData = AesGcm::decrypt( base64_decode($resource['ciphertext']), $config['api_v3_key'], $resource['nonce'], $resource['associated_data'] ); [UnexpectedValueException] Decrypting the input $ciphertext failed, please checking your $key and $iv whether or nor correct. 解密失败
08-11 - jsapi验签失败?
string(162) "appId=wx75f0bf3a2ae49cd9&nonceStr=uo4l1jadj2pzg7cp117vqeggt1s0huay&package=prepay_id=wx11161647032576b0db7e005476b28d0000&signType=RSA-SHA256&timeStamp=1754900206" 下面是生成的签名 array(6) { ["appId"] => string(18) "wx75f0bf3a2ae49cd9" ["timeStamp"] => string(10) "1754900206" ["nonceStr"] => string(32) "uo4l1jadj2pzg7cp117vqeggt1s0huay" ["package"] => string(46) "prepay_id=wx11161647032576b0db7e005476b28d0000" ["signType"] => string(10) "RSA-SHA256" ["paySign"] => string(344) "i77AYWV1mSD+0T6UWMoaFeRerCKxIDZCYJVRZ3HEB4TsElB4pGiffOHI+REZWmlBkkgxra77i7JHOXI58GN0J+It5V92E+irCzNo2pEGvM7R7ozOcfR2qU1HZ3cIXpqi05l6rjhLHPN2y+Httrt0BFbTpXqrBygEv2O6rRxqv87+xcrx9RREeA8EkxkpmiE7thpgCUAKSbw8Bnh9G9v5rThS51qkQKS30mb3dxVxS32Xdbnall/qgOJQxPt9IIdDcIqhk0JFzrY60S/LruUKjD3iAoo399kp+P0tDXPbyUfe2KtdC7xz5k/uAkN9MBo1dKNVqkj+bUHu7kcWI8bvyg==" } 这是生成的方法 /** * 生成签名 * @param array $params 待签名参数 * @param string $key 密钥 * @return string 签名结果 */ protected function generateSign($params, $key) { dump($params); ksort($params); // 按key字母排序 $signStr = ''; foreach ($params as $k => $v) { $signStr .= "{$k}={$v}&"; } $signStr = rtrim($signStr, '&'); // 去除最后一个& dump($signStr); // 2. 用私钥生成RSA-SHA256签名 openssl_sign($signStr, $signature, $key, OPENSSL_ALGO_SHA256); $paySign = base64_encode($signature); // 必须Base64编码 return $paySign; } 前端调用报签名失败
08-11 - 服务商jsapi支付?
sdk支付 /** * 创建支付订单(JSAPI) * @param array $data 支付参数 * @return array 支付结果 */ public function createTransaction($data) { $resp = $this->instance ->chain('v3/pay/partner/transactions/jsapi') ->post(['json' => $data]); return json_decode((string)$resp->getBody(), true); } 具体参数 array(8) { ["sb_appid"] => string(18) "wx75f0bf3a2ae49cd9" ["sb_mchid"] => string(10) "1723325576" ["sub_mchid"] => string(10) "1724710712" ["out_trade_no"] => string(22) "PAY_202508111135002211" ["description"] => string(18) "测试商品购买" ["amount"] => array(2) { ["total"] => int(1) ["currency"] => string(3) "CNY" } ["payer"] => array(1) { ["openid"] => string(28) "o6_bmjrPTlm6_2sgVt7hMZOPfL2M" } ["notify_url"] => string(33) "https://yourdomain.com/notify.php" } 报错 [GuzzleHttp\Exception\ClientException] Client error: `POST https://api.mch.weixin.qq.com/v3/pay/partner/transactions/jsapi` resulted in a `400 Bad Request` re sponse: {"code":"PARAM_ERROR","detail":{"location":"body","value":""},"message":"输入源“/body/sp_appid”映射到字段“ (truncated.. .)
08-11 - 特约商户进件进度查询?
[GuzzleHttp\Exception\ClientException] Client error: `GET https://api.mch.weixin.qq.com/v3/applyment4sub/applyment/2000002675725445` resulted in a `405 Method Not Allowed` response 用的sdk /** * 查询进件进度 * @param string $applymentId 进件单号 * @return array 查询结果 */ public function queryApplyment($applymentId) { $resp = $this->instance ->chain("v3/applyment4sub/applyment/{$applymentId}") ->get(); return json_decode((string)$resp->getBody(), true); }
08-09 - sdk下载平台证书报解密报错?
Decrypting the input $ciphertext failed, please checking your $key and $iv whether or nor correct.
08-08 - 公司注册了合作伙伴还需要注册普通商户吗?
公司不参与收款,只参与分账
08-08 - 特约商户进件?
$params = [ 'business_code' => 'SUB_' . date('YmdHis') . rand(1000, 9999), 'subject_info' => [ "subject_type" => "INDIVIDUAL", // 正确字段名:type(必须是type) 'individual_license' => [ 'license_copy' => base64_encode(file_get_contents(Env::get('root_path') . 'public/uploads/20250714/0a44aa7ca8139ad7f05c72e59426f526.jpg')), // 必传,营业执照照片 'license_number' => '92440101MA5XXXXXXX', // 必传,注册号 'merchant_name' => 'XX小吃店', // 必传,与执照一致 'operator' => '张三', // 必传,经营者姓名 'address' => '广东省深圳市XX区XX路XX号', // 必传,注册地址ƒƒ√ 'valid_date' => '2020-01-01至长期' // 必传,有效期 ], 'operator' => [ 'id_card_copy' => base64_encode(file_get_contents(Env::get('root_path') . 'public/uploads/20250714/0a44aa7ca8139ad7f05c72e59426f526.jpg')), // 必传,身份证正面 'id_card_national' => base64_encode(file_get_contents(Env::get('root_path') . 'public/uploads/20250714/0a44aa7ca8139ad7f05c72e59426f526.jpg')), // 必传,身份证反面 'id_card_number' => '440301XXXXXXXXXXXX', // 必传,身份证号 'name' => '张三', // 必传,与身份证一致 'id_card_valid_time' => '2020-01-01至长期' // 必传,有效期 ] ], 'contact_info' => [ 'contact_name' => '张三', 'mobile_phone' => '13800138000', // 11位有效手机号 'contact_email' => 'zhangsan@example.com' ], 'business_info' => [ 'merchant_shortname' => 'XX小吃店', 'service_phone' => '13800138000' ], 'settlement_info' => [ 'bank_account_type' => 'ACCOUNT_TYPE_PRIVATE', 'account_name' => '张三', 'account_number' => '622848XXXXXXXXXXXX', 'bank_name' => '中国农业银行', 'bank_branch_id' => '103584000018' ] ]; $downloader = new WechatPayService(); $downloader->apply($params); 这是调用sdk <?php namespace app\service; use think\Exception; use think\facade\Config; use WeChatPay\Builder; use WeChatPay\Crypto\Rsa; class WechatPayService { //创建一个实例 private $instance; //商户私钥 private $merchantPrivateKeyInstance; //商户证书序列号 private $merchantCertificateSerial; //平台证书序列号 private $platformPublicKeyInstance; //平台证书序列号 private $platformCertificateSerial; //平台公钥ID private $platformPublicKeyId; //微信支付公钥 private $twoPlatformPublicKeyInstance; //商户号 private $merchantId; //加密器 private $encryptor; /** * 构造函数 * @param array $config 配置参数 * @throws Exception */ public function __construct() { //获取配置 $config = Config::get('main.WXPAYV3', []); // 商户号 $this->merchantId = $config['mch_id']; // 从本地文件中加载「商户API私钥」,「商户API私钥」会用来生成请求的签名 $this->merchantPrivateKeyInstance = Rsa::from(file_get_contents($config['private_key_path']), Rsa::KEY_TYPE_PRIVATE); // 「商户API证书」的「证书序列号」 $this->merchantCertificateSerial = $config['cert_serial']; // 补充平台证书(建议配置) $this->platformPublicKeyInstance = Rsa::from(file_get_contents($config['cert_path']), Rsa::KEY_TYPE_PUBLIC); //平台证书序列号 $this->platformCertificateSerial = $config['cert_serial_no']; //平台公钥ID $this->platformPublicKeyId = $config['platform_cert_id']; // 从本地文件中加载「微信支付公钥」,用来验证微信支付应答的签名 $this->twoPlatformPublicKeyInstance = Rsa::from(file_get_contents($config['wechatpay_pub_key']), Rsa::KEY_TYPE_PUBLIC); // 构造一个 APIv3 客户端实例 $this->instance = Builder::factory([ 'mchid' => $this->merchantId, 'serial' => $this->merchantCertificateSerial, 'privateKey' => $this->merchantPrivateKeyInstance, 'verify' => false, 'certs' => [ $this->platformCertificateSerial => $this->platformPublicKeyInstance, $this->platformPublicKeyId => $this->twoPlatformPublicKeyInstance, ], ]); $platformPublicKeyInstance = $this->platformPublicKeyInstance; $this->encryptor = static function (string $msg) use ($platformPublicKeyInstance): string { return Rsa::encrypt($msg, $platformPublicKeyInstance); }; } //特约商户进件 public function apply($params = []) { $resp = $this->instance ->chain('v3/applyment4sub/applyment/') ->post([ 'json' => $params, 'headers' => [ // $platformCertificateSerialOrPublicKeyId 见初始化章节 'Wechatpay-Serial' => $this->platformPublicKeyId, ], ]); dump($resp); } } 报错 liyongai@DJ-Ocean-J-MacBook-Pro api % php think task [GuzzleHttp\Exception\ClientException] Client error: `POST https://api.mch.weixin.qq.com/v3/applyment4sub/applyment/` resulted in a `400 Bad Request` response: {"code":"PARAM_ERROR","message":"请确认待处理的消息是否为加密后的密文"} liyongai@DJ-Ocean-J-MacBook-Pro api % php think task [GuzzleHttp\Exception\ClientException] Client error: `POST https://api.mch.weixin.qq.com/v3/applyment4sub/applyment/` resulted in a `400 Bad Request` response: {"code":"PARAM_ERROR","detail":{"location":"body","value":"INDIVIDUAL"},"message":"无法将 JSON 输入源“/body/subj (truncated...) liyongai@DJ-Ocean-J-MacBook-Pro api %
08-07