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()
{
$userId = $GLOBALS['data']['userid'];
if (empty($userId)) {
return show("未登录!", NEED_LOGIN);
$clientToken = Request::get('token');
$orderId = Request::get('order_id');
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')
->suffix(false)
->domain(true);
$config = Config::get('wechat.payment');
$payment = Factory::payment($config);
$unify = $payment->order->unify([
dump($notifyUrl);
dd($order);
$config = Config::get('wechat.payment');
$payment = Factory::payment($config);
$unify = $payment->order->unify([
'body' => '商品订单',
'out_trade_no' => time(),
'total_fee' => 100,