Yêu cầu thg 11 11, 2022 4:13 CH 92 0 1
  • 92 0 1
0

Tài khoản bị logout khi thanh toán bằng online thành công !

Chia sẻ
  • 92 0 1

Anh chị cho em hỏi chút! khi em thanh toán thành công bằng hình thức thanh toán online thì em chuyển hướng về trang cảm ơn ! Nhưng khi về đây thì tài khoản bị logout ạ! Trường hopư này mk xử lý sao ạ! em cảm ơn

1 CÂU TRẢ LỜI


Đã trả lời thg 11 13, 2022 6:13 SA
0

bạn sau khi thanh toán xong có xoá session hay gì ko ?

Chia sẻ
Avatar June @phuocbt698
thg 11 13, 2022 7:37 SA

@xdorro em không xóa, hay là chuyển trang bị mất session ạ, nếu mất thì trường hợp này mình sử lý sao ạ

Avatar Anh Nguyen @xdorro
thg 11 13, 2022 1:26 CH

@phuocbt698 chưa rõ bạn xử lý như nào nên khó giúp quá

Avatar June @phuocbt698
thg 11 13, 2022 1:48 CH

@xdorro hiện tại thì em chưa xử lý gì hết! Chỉ là khi em thanh toán bằng quét mã QR của momo , khi thanh toán xong momo sẽ redirect về trang mà mk cung cấp trong $returnUrl , khi về quay về trang thì tài khoản đang login trước đó bị logout á anh

Avatar June @phuocbt698
thg 11 13, 2022 1:50 CH
Avatar June @phuocbt698
thg 11 13, 2022 1:51 CH

@phuocbt698 @xdorro ` public function callApiMomo($infoOrder) {

    $endpoint = env('MOMO_ENDPOINT');
    $partnerCode = env('MOMO_PARTNER_CODE');
    $accessKey = env('MOMO_ACCESS_KEY');
    $serectKey = env('MOMO_SECRET_KEY');
    $orderId = "$infoOrder->id";
    $orderInfo = "Thanh toán đơn hàng có mã $orderId";
    $amount = "$infoOrder->total_price";
    $bankCode = 'SML';
    $returnUrl = route('momo.hookCallBack');
    $requestId = time() . "";
    $requestType = "captureMoMoWallet";
    $extraData = "";
    $notifyUrl = route('momo.hookCallBack');
    $lang = 'vn';
    // echo $serectkey;die;
    $rawHash = "partnerCode=" . $partnerCode . "&accessKey=" . $accessKey .
        "&requestId=" . $requestId . "&amount=" . $amount . "&orderId=" . $orderId .
        "&orderInfo=" . $orderInfo . "&returnUrl=" . $returnUrl .
        "&notifyUrl=" . $notifyUrl . "&extraData=" . $extraData;
    $signature = hash_hmac("sha256", $rawHash, $serectKey);

    $data =  array(
        'partnerCode' => $partnerCode,
        'accessKey' => $accessKey,
        'requestId' => $requestId,
        'amount' => $amount,
        'orderId' => $orderId,
        'orderInfo' => $orderInfo,
        'returnUrl' => $returnUrl,
        'bankCode' => $bankCode,
        'extraData' => $extraData,
        'requestType' => $requestType,
        'signature' => $signature,
        'notifyUrl' => $notifyUrl,
        'lang' => $lang
    );

    $result = $this->execPostRequest($endpoint, json_encode($data));
    $jsonResult = json_decode($result, true); // decode json
    if (empty($jsonResult['payUrl'])) {
        return redirect()->back();
    }
    return $jsonResult['payUrl'];
}

public function hookCallBack()
{
    if (request('errorCode') == 00) {
        $orderId = request('orderId');
        $order = OrderModel::find($orderId);
        if ($order->payment_type == 0) {
            $order->update([
                'payment_type' => 1,
                'payment' => 'MOMO'
            ]);
            return view('customer.thankyou');
        }
    }
    return redirect()->route('shop.checkout')
    ->withErrors(['errorMessage' => 'Thanh toán đơn hàng không thành công! Vui lòng thử lại!']);
}

`

Avatar June @phuocbt698
thg 11 13, 2022 2:03 CH

@phuocbt698 đây là đoạn code em viết thanh toán bằng momo , hookCallBack nhận thông tin thanh toán từ momo gửi về và rediẻct \

Avatar Anh Nguyen @xdorro
thg 11 14, 2022 9:05 SA

@phuocbt698 mình nghĩ có lẽ view('customer.thankyou') của bạn đang dính middleware hay gì đó r, bạn check lại route middleware chỗ này thử xem

Avatar Hạ Quỳnh Nguyễn @quynhnguyentk2
thg 11 14, 2022 10:35 SA

Trường hợp điều hướng bị logout thì có liên quan đến việc bạn bị mất token khi chuyển router. Bạn xem lại bạn lưu token ở đâu? (cookie, session hay localStorage)

Viblo
Hãy đăng ký một tài khoản Viblo để nhận được nhiều bài viết thú vị hơn.
Đăng kí