This commit is contained in:
2022-09-09 16:55:16 +08:00
parent 58ab2aa239
commit ad89890c2a

View File

@@ -80,19 +80,31 @@ class Wechat
*/ */
public function payment() public function payment()
{ {
$userId = $GLOBALS['data']['userid']; $clientToken = Request::get('token');
if (empty($userId)) { $orderId = Request::get('order_id');
return show("未登录!", NEED_LOGIN); if ($clientToken) {
$tk = json_decode(authcode($clientToken), true);
$userId = $tk['userid'];
}
$user = AppUser::findOrEmpty($userId);
if (! $user) {
exit('NO USER');
} }
$user = AppUser::find($userId); $order = \app\model\Order::find($orderId);
$notifyUrl = Route::buildUrl('wechat/paid') $notifyUrl = Route::buildUrl('wechat/paid')
->suffix(false) ->suffix(false)
->domain(true); ->domain(true);
$config = Config::get('wechat.payment');
$payment = Factory::payment($config); dump($notifyUrl);
$unify = $payment->order->unify([
dd($order);
$config = Config::get('wechat.payment');
$payment = Factory::payment($config);
$unify = $payment->order->unify([
'body' => '商品订单', 'body' => '商品订单',
'out_trade_no' => time(), 'out_trade_no' => time(),
'total_fee' => 100, 'total_fee' => 100,