為了購(gòu)買積分滿足這個(gè)需求 我們需要二開(kāi),跟官方手冊(cè)和實(shí)際PayServices有差距,所有怎么實(shí)現(xiàn)自定義生成統(tǒng)一下單??
這個(gè)官方提到的
$payServices = new PayServices();
$payType = '支付類型';//支持類型 routine weixinh5 weixin
$openid = '用戶的openid';//當(dāng)$payType == 'weixinh5 ' 時(shí)$openid可為空
$orderInfo['order_id'] = '訂單號(hào)';
$orderInfo['pay_price'] = '訂單金額';//以元為單位
$successAction = 'test' ;//支付成功回調(diào)執(zhí)行方法
$body = '冬裝上新,潮流男款西褲';
$payServices->pay($payType, $openid, $orderInfo['order_id'], $orderInfo['pay_price'], $successAction, $body);
crweb實(shí)際上的PayServices
$payServices = new PayServices();
$payType = "routine";
$user = app()->make(WechatUserServices::class);$openid = $user->uidToOpenid($request->uid(),$payType);
$order_id = "E" . md5(time());
$pay_price = 0.01;
$unipay = $payServices->pay($payType,$order_id,$pay_price,"test","test");
你們發(fā)現(xiàn)了嗎有一個(gè)參數(shù)不一樣,就是他opened
下面PayServices里面pay函數(shù)根本沒(méi)有官方說(shuō)的opened參數(shù)
public function pay(string $payType, string $orderId, string $price, string $successAction, string $body, array $options = [])
所以導(dǎo)致了缺少opened這樣的一個(gè)錯(cuò)誤
{
"status":400,
"msg":"缺少openid",
"data":{}
}
所以這么解決這個(gè)自定義統(tǒng)一下單???官方求解