From 7fb139cd9bf433ad08c120c49e602feaaa21c7ce Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 8 Aug 2022 07:35:00 +1000 Subject: [PATCH] Fixes for stripe catching aborted payments --- app/PaymentDrivers/BaseDriver.php | 4 ++++ app/PaymentDrivers/Stripe/CreditCard.php | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/app/PaymentDrivers/BaseDriver.php b/app/PaymentDrivers/BaseDriver.php index 1a520977060d..d637dfd6a1eb 100644 --- a/app/PaymentDrivers/BaseDriver.php +++ b/app/PaymentDrivers/BaseDriver.php @@ -431,6 +431,10 @@ class BaseDriver extends AbstractPaymentDriver public function sendFailureMail($error) { + if(is_object($error)){ + $error = 'Payment Aborted'; + } + if (! is_null($this->payment_hash)) { $this->unWindGatewayFees($this->payment_hash); } diff --git a/app/PaymentDrivers/Stripe/CreditCard.php b/app/PaymentDrivers/Stripe/CreditCard.php index f0ca05eaa34d..0c29fcb0fb3a 100644 --- a/app/PaymentDrivers/Stripe/CreditCard.php +++ b/app/PaymentDrivers/Stripe/CreditCard.php @@ -167,6 +167,16 @@ class CreditCard $this->stripe->client->company, ); + //if the user has come from a subscription double check here if we need to redirect + + if($payment->invoices()->whereHas('subscription')->exists()){ + $subscription = $payment->invoices()->first()->subscription; + + if($subscription && array_key_exists('return_url', $subscription->webhook_configuration) && strlen($subscription->webhook_configuration['return_url']) >=1) + return redirect($subscription->webhook_configuration['return_url']); + + } + return redirect()->route('client.payments.show', ['payment' => $this->stripe->encodePrimaryKey($payment->id)]); }