我要在这里深刻反思,经常给别人说大小写的问题,到自己这忘记了 搞定了,大小写的问题,我查了三个小时!
使用官方推荐V3版 SDK JSAPI一切OK,但是同样的方式APP无法调起,换回原来的V2,没问题$resp=$this->wxPay ->chain('v3/pay/transactions/jsapi') ->post(['json' => [ 'appid' => $this->getAppId(), 'mchid' => config('wechat_mchid'), 'description' => '商城订单-'.$order->order_sn, 'out_trade_no' => $order['order_sn'], 'time_expire' => date("c", time() + tpCache('shop.pay_time')), 'notify_url' => config("weburl")."/api/WxPay/asyncUpdateOrderStatus", 'amount' => [ 'total' => 1, //正式下单时填写$order['pay_amount']*100 'currency' => 'CNY' ], 'payer'=>[ 'openid'=>$this->getUserOpenId($order->user), ] ]]); $data=(array)json_decode($resp->getBody()->getContents(),true); $merchantPrivateKeyFilePath = 'file://'.config('keyPath'); $merchantPrivateKeyInstance = Rsa::from($merchantPrivateKeyFilePath); $params = [ 'appId' => $this->getAppId(), 'timeStamp' => (string)Formatter::timestamp(), 'nonceStr' => Formatter::nonce(), 'package' => 'prepay_id='.$data['prepay_id'], ]; $params += [ 'paySign' => Rsa::sign(Formatter::joinedByLineFeed(...array_values($params)),$merchantPrivateKeyInstance), 'signType' => 'RSA' ]; $data=[ 'parameters'=>$params, 'order_sn'=>$order['order_sn'], ]; 上面的代码是JSAPI 一切OK $resp=$this->wxPay ->chain('v3/pay/transactions/app') ->post(['json' => [ 'appid' => $this->getAppId(), 'mchid' => config('wechat_mchid'), 'description' => '商城订单-'.$order['order_sn'], 'out_trade_no' => $order['order_sn'], 'time_expire' => date("c", time() + tpCache('shop.pay_time')), 'notify_url' => config("weburl")."/api/WxPay/asyncUpdateOrderStatus", 'amount' => [ 'total' => 1, //正式下单时填写$order['pay_amount']*100 'currency' => 'CNY' ] ]]); $data=(array)json_decode($resp->getBody()->getContents(),true); $merchantPrivateKeyFilePath = 'file://'.config('keyPath'); $merchantPrivateKeyInstance = Rsa::from($merchantPrivateKeyFilePath); $params = [ 'appId' => $this->getAppId(), 'timeStamp' => (string)Formatter::timestamp(), 'nonceStr' => Formatter::nonce(), 'prepayid'=>$data['prepay_id'], ]; $params+= [ 'sign' => Rsa::sign(Formatter::joinedByLineFeed(...array_values($params)),$merchantPrivateKeyInstance), 'partnerid' => config('wechat_mchid'), 'package' => 'Sign=WXPay', ]; $data=[ 'parameters'=>$params, 'order_sn'=>$order['order_sn'], ]; 下面的这段代码,也能解析出prepayid,同样加签也成功,就是报-1,死活无法调起微信APP支付 还遇到一个疑惑,JSAPI虽然成功,但是我自己加签的数据,和用官方提供的加签的工具,加出来的不一样。但是可以使用。 我上面的加签有问题吗? https://github.com/wechatpay-apiv3/wechatpay-php
2021-12-20