امیررضا
1 سال پیش توسط امیررضا مطرح شد
0 پاسخ

درگاه پرداخت با شتابیت

سلام عرض ادب

public function buy($postId)
    {
        $post = (new postRepo())->getFindPost($postId);
        if (!$this->checkManagerFind($post)) {
            return back();
        }
        $payment = \App\Models\Payment\Payment::create([
            'buyer_id' => auth()->id(),
            'seller_id' => $post->user_id,
            'paymentable_id' => $postId,
            'paymentable_type' => Post::class,
            'amount' => $post->price,
            'invoice_id' => Str::random(16),
            'gateway' => 'shetabit',
            'status' => \App\Models\Payment\Payment::STATUS_PENDING,
        ]);
        return Payment::purchase(
            (new Invoice)->amount($post->price),
            function($driver, $transactionId) use ($payment) {
                $payment->update(['invoice_id' => (string) $transactionId]);
            }
        )->pay()->render();
    }

    public function callback(Request $request)
    {
        $get = Cache::get(auth()->id().'transactionId');
        try {
            $transactionId = $request->get('trackId');
            $status = $request->input('status');
            if($get === $transactionId) {

            }
            $payment = \App\Models\Payment\Payment::query()->where('invoice_id', $transactionId)->first();
            if ($status == 1) {
                $payment->update(['status' => \App\Models\Payment\Payment::STATUS_SUCCESS]);
                return redirect()->route('payment.success');
            } else {
                $payment->update(['status' => \App\Models\Payment\Payment::STATUS_FAIL]);
                return redirect()->route('payment.fail')->with('error', 'Payment failed.');
            }
        } catch (InvalidPaymentException $exception) {
            return redirect()->route('payment.fail')->with('error', $exception->getMessage());
        } catch (\Exception $e) {
            return redirect()->route('payment.fail')->with('error', 'An error occurred during the payment process.');
        }
    }

موقعی وارد درگاه میشه اطالعات ذخیره میشه
ولی موقعی ریدایرکت میشه استاتوس ۲ میده ولی پول کم شده ولی بازم استانوس ۱ میده
دلیلش چی هست؟؟