diff --git a/config/bazar_stripe.php b/config/bazar_stripe.php index dff6a7b..a86f9f7 100644 --- a/config/bazar_stripe.php +++ b/config/bazar_stripe.php @@ -8,8 +8,8 @@ 'secret' => env('STRIPE_SECRET'), - 'success_url' => env('STRIPE_SUCCESS_URL', '/?session_id={CHECKOUT_SESSION_ID}'), + 'success_url' => env('STRIPE_SUCCESS_URL', '/'), - 'failure_url' => env('STRIPE_FAILURE_URL', '/?session_id={CHECKOUT_SESSION_ID}'), + 'failure_url' => env('STRIPE_FAILURE_URL', '/'), ]; diff --git a/src/StripeDriver.php b/src/StripeDriver.php index 6d826ad..fcbafc6 100644 --- a/src/StripeDriver.php +++ b/src/StripeDriver.php @@ -58,6 +58,22 @@ public function getCaptureUrl(Order $order): string ]).'?session_id={CHECKOUT_SESSION_ID}'; } + /** + * {@inheritdoc} + */ + public function getSuccessUrl(Order $order): string + { + return parent::getSuccessUrl($order).'?session_id={CHECKOUT_SESSION_ID}'; + } + + /** + * {@inheritdoc} + */ + public function getFailureUrl(Order $order): string + { + return parent::getFailureUrl($order).'?session_id={CHECKOUT_SESSION_ID}'; + } + /** * Create a new Stripe session. */ @@ -99,7 +115,11 @@ public function handleCheckout(Request $request): Response { $response = parent::handleCheckout($request); - return $response->url($this->session->url); + if (! is_null($this->session)) { + $response->url($this->session->url); + } + + return $response; } /**