1.如果遇到系統繁忙,請稍後再試?
答案:多半是自己參數的問題,請認真核對參數,確保,參數於官方的參數保持一致
2.wechatpay-api-v3簽名是微信分基本都會需要的驗籤,列出微信文檔需要注意的以下事項:
(1)message參數問題$method參數爲POST 或者GET請求,$body爲POST請求體的參數參數如下面片段代碼:
$c即可爲$body,請注意的$message 裏的\n,也會導致驗籤失敗
$a['out_order_no'] = $out_order_no;
$a['service_id'] = config('miniprogram.wx.service_id');;
$a['appid'] = $appId;
$c = json_encode($a);
$message = "{$method}\n".
$canonical_url."\n".
$timestamp."\n".
$nonce."\n".
$body."\n";
(2)私鑰一定是路徑的,請注意,服務器與win系統的/問題,裏面的$raw_sign參數可以設置爲空
//生成簽名
$path = Env::get('config_path').'cert/apiclient_key.pem';
openssl_sign($message, $raw_sign,openssl_pkey_get_private(file_get_contents($path)) , 'sha256WithRSAEncryption');
(3)提供給大家隨機字符串的生成的源碼:
public function createNoncestr( $length = 32 )
{
$chars = "abcdefghijklmnopqrstuvwxyz0123456789";
$str ="";
for ( $i = 0; $i < $length; $i++ ) {
$str.= substr($chars, mt_rand(0, strlen($chars)-1), 1);
}
return $str;
}
(4)接收不到微信的回調請求:
首先可以查看自己創建訂單的:notify_url: "https://***/wechat/notify",是否爲可訪問地址,請確保https請求而不是http,官方已經做了聲明。
請記得在商戶後臺設置api_v3私鑰,千萬和mch_key區分開,雖然都是32位但是兩個不同的東西!!
後面api_v3私鑰需要用來解密回調參數
回調參數,用戶也可以根據postman,來自行調整解決,微信那邊的參數也是如此:
參數中時間格式請大家注意自行轉換
$timesp = strtotime('20091225091010');
$order_update= date('Y-m-d H:i:s',$timesp);
5.訂單微信分支付異常狀態,支付失敗,金額不夠無法扣款
["collection"]=>
array(5) {
["details"]=>
array(0) {
}
["paid_amount"]=>
int(0)
["paying_amount"]=>
int(10)
["state"]=>
string(11) "USER_PAYING"
["total_amount"]=>
int(10)
}
["state"]=>
string(5) "DOING"
["state_description"]=>
string(12) "MCH_COMPLETE"
扣款失敗導致,訂單無法繼續,微信那邊一直顯示扣款中
如有任何疑問請私信作者~