From e63fbd68e607472f675cec30d3b338000f3a101e Mon Sep 17 00:00:00 2001 From: Lars Kusch Date: Tue, 12 Oct 2021 16:18:13 +0200 Subject: [PATCH] Removed BACS-Support as Stripe dropped it --- app/Models/GatewayType.php | 2 - app/Models/PaymentType.php | 3 +- app/PaymentDrivers/Stripe/BACS.php | 163 ------------------ app/PaymentDrivers/StripePaymentDriver.php | 11 -- .../gateways/stripe/bacs/authorize.blade.php | 84 --------- .../gateways/stripe/bacs/bacs_debit.blade.php | 29 ---- .../gateways/stripe/bacs/pay.blade.php | 29 ---- 7 files changed, 1 insertion(+), 320 deletions(-) delete mode 100644 app/PaymentDrivers/Stripe/BACS.php delete mode 100644 resources/views/portal/ninja2020/gateways/stripe/bacs/authorize.blade.php delete mode 100644 resources/views/portal/ninja2020/gateways/stripe/bacs/bacs_debit.blade.php delete mode 100644 resources/views/portal/ninja2020/gateways/stripe/bacs/pay.blade.php diff --git a/app/Models/GatewayType.php b/app/Models/GatewayType.php index 4eadceb1d5e4..a9f04a56d008 100644 --- a/app/Models/GatewayType.php +++ b/app/Models/GatewayType.php @@ -80,8 +80,6 @@ class GatewayType extends StaticModel return ctrans('texts.giropay'); case self::EPS: return ctrans('texts.eps'); - case self::BACS: - return ctrans('text.bacs'); case self::BECS: return ctrans('tets.becs'); default: diff --git a/app/Models/PaymentType.php b/app/Models/PaymentType.php index 4558df44cfe3..937c5daa37ff 100644 --- a/app/Models/PaymentType.php +++ b/app/Models/PaymentType.php @@ -50,8 +50,7 @@ class PaymentType extends StaticModel const GIROPAY = 39; const PRZELEWY24 = 40; const EPS = 41; - const BACS = 43; - const BECS = 44; + const BECS = 43; public static function parseCardType($cardName) { diff --git a/app/PaymentDrivers/Stripe/BACS.php b/app/PaymentDrivers/Stripe/BACS.php deleted file mode 100644 index 160653b43e7b..000000000000 --- a/app/PaymentDrivers/Stripe/BACS.php +++ /dev/null @@ -1,163 +0,0 @@ -stripe = $stripe; - } - - public function authorizeView($data) - { - return render('gateways.stripe.bacs.authorize', $data); - } - - public function paymentView(array $data) { - $data['gateway'] = $this->stripe; - $data['payment_method_id'] = GatewayType::BACS; - $data['stripe_amount'] = $this->stripe->convertToStripeAmount($data['total']['amount_with_fee'], $this->stripe->client->currency()->precision, $this->stripe->client->currency()); - $data['client'] = $this->stripe->client; - $data['customer'] = $this->stripe->findOrCreateCustomer()->id; - $data['country'] = $this->stripe->client->country->iso_3166_2; - $data['payment_hash'] = $this->stripe->payment_hash->hash; - - $intent = \Stripe\PaymentIntent::create([ - 'amount' => $data['stripe_amount'], - 'currency' => 'eur', - 'payment_method_types' => ['bacs_debit'], - 'customer' => $this->stripe->findOrCreateCustomer(), - 'description' => $this->stripe->decodeUnicodeString(ctrans('texts.invoices') . ': ' . collect($data['invoices'])->pluck('invoice_number')), - - ]); - - $data['pi_client_secret'] = $intent->client_secret; - - $this->stripe->payment_hash->data = array_merge((array) $this->stripe->payment_hash->data, ['stripe_amount' => $data['stripe_amount']]); - $this->stripe->payment_hash->save(); - - return render('gateways.stripe.bacs.pay', $data); - } - - public function paymentResponse(PaymentResponseRequest $request) - { - - $gateway_response = json_decode($request->gateway_response); - - $this->stripe->payment_hash->data = array_merge((array) $this->stripe->payment_hash->data, $request->all()); - $this->stripe->payment_hash->save(); - - if (property_exists($gateway_response, 'status') && $gateway_response->status == 'processing') { - - $this->stripe->init(); - $this->storePaymentMethod($gateway_response); - - return $this->processSuccessfulPayment($gateway_response->id); - } - - return $this->processUnsuccessfulPayment(); - - } - - public function processSuccessfulPayment(string $payment_intent) - { - $this->stripe->init(); - - $data = [ - 'payment_method' => $payment_intent, - 'payment_type' => PaymentType::BACS, - 'amount' => $this->stripe->convertFromStripeAmount($this->stripe->payment_hash->data->stripe_amount, $this->stripe->client->currency()->precision, $this->stripe->client->currency()), - 'transaction_reference' => $payment_intent, - 'gateway_type_id' => GatewayType::BACS, - ]; - - $this->stripe->createPayment($data, Payment::STATUS_PENDING); - - SystemLogger::dispatch( - ['response' => $this->stripe->payment_hash->data, 'data' => $data], - SystemLog::CATEGORY_GATEWAY_RESPONSE, - SystemLog::EVENT_GATEWAY_SUCCESS, - SystemLog::TYPE_STRIPE, - $this->stripe->client, - $this->stripe->client->company, - ); - - return redirect()->route('client.payments.index'); - } - - public function processUnsuccessfulPayment() - { - $server_response = $this->stripe->payment_hash->data; - - PaymentFailureMailer::dispatch( - $this->stripe->client, - $server_response, - $this->stripe->client->company, - $this->stripe->convertFromStripeAmount($this->stripe->payment_hash->data->stripe_amount, $this->stripe->client->currency()->precision, $this->stripe->client->currency()) - ); - - $message = [ - 'server_response' => $server_response, - 'data' => $this->stripe->payment_hash->data, - ]; - - SystemLogger::dispatch( - $message, - SystemLog::CATEGORY_GATEWAY_RESPONSE, - SystemLog::EVENT_GATEWAY_FAILURE, - SystemLog::TYPE_STRIPE, - $this->stripe->client, - $this->stripe->client->company, - ); - - throw new PaymentFailed('Failed to process the payment.', 500); - } - - - private function storePaymentMethod($intent) - { - try { - - $method = $this->stripe->getStripePaymentMethod($intent->payment_method); - - $payment_meta = new \stdClass; - $payment_meta->brand = (string) \sprintf('%s (%s)', $method->sepa_debit->bank_code, ctrans('texts.bacs')); - $payment_meta->last4 = (string) $method->sepa_debit->last4; - $payment_meta->state = 'authorized'; - $payment_meta->type = GatewayType::BACS; - - $data = [ - 'payment_meta' => $payment_meta, - 'token' => $intent->payment_method, - 'payment_method_id' => GatewayType::BACS, - ]; - - $this->stripe->storeGatewayToken($data, ['gateway_customer_reference' => $method->customer]); - } catch (\Exception $e) { - return $this->stripe->processInternallyFailedPayment($this->stripe, $e); - } - } -} diff --git a/app/PaymentDrivers/StripePaymentDriver.php b/app/PaymentDrivers/StripePaymentDriver.php index 3aaf0f158074..2673ba974ca0 100644 --- a/app/PaymentDrivers/StripePaymentDriver.php +++ b/app/PaymentDrivers/StripePaymentDriver.php @@ -39,7 +39,6 @@ use App\PaymentDrivers\Stripe\iDeal; use App\PaymentDrivers\Stripe\EPS; use App\PaymentDrivers\Stripe\Bancontact; use App\PaymentDrivers\Stripe\BECS; -use App\PaymentDrivers\Stripe\BACS; use App\PaymentDrivers\Stripe\UpdatePaymentMethods; use App\PaymentDrivers\Stripe\Utilities; use App\Utils\Traits\MakesHash; @@ -89,7 +88,6 @@ class StripePaymentDriver extends BaseDriver GatewayType::IDEAL => iDeal::class, GatewayType::EPS => EPS::class, GatewayType::BANCONTACT => Bancontact::class, - GatewayType::BACS => BACS::class, GatewayType::BECS => BECS::class, ]; @@ -204,13 +202,6 @@ class StripePaymentDriver extends BaseDriver && in_array($this->client->country->iso_3166_3, ["BEL"])) $types[] = GatewayType::BANCONTACT; - if ($this->client - && $this->client->currency() - && ($this->client->currency()->code == 'GBR') - && isset($this->client->country) - && in_array($this->client->country->iso_3166_3, ["GBP", "DEU"])) - $types[] = GatewayType::BACS; - if ($this->client && $this->client->currency() && ($this->client->currency()->code == 'AUD') @@ -253,8 +244,6 @@ class StripePaymentDriver extends BaseDriver return 'gateways.stripe.eps'; case GatewayType::BANCONTACT: return 'gateways.stripe.bancontact'; - case GatewayType::BACS: - return 'gateways.stripe.bacs'; case GatewayType::BECS: return 'gateways.stripe.becs'; default: diff --git a/resources/views/portal/ninja2020/gateways/stripe/bacs/authorize.blade.php b/resources/views/portal/ninja2020/gateways/stripe/bacs/authorize.blade.php deleted file mode 100644 index 78f859b75c30..000000000000 --- a/resources/views/portal/ninja2020/gateways/stripe/bacs/authorize.blade.php +++ /dev/null @@ -1,84 +0,0 @@ -@extends('portal.ninja2020.layout.payments', ['gateway_title' => 'SEPA', 'card_title' => 'SEPA-Lastschrift']) - -@section('gateway_head') - @if($gateway->company_gateway->getConfigField('account_id')) - - - @else - - @endif -@endsection - -@section('gateway_content') - @if(session()->has('sepa_error')) -
-

{{ session('sepa_error') }}

-
- @endif - -
- @csrf - - - - - - - -
- - - - @component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.account_holder_type')]) - - - {{ __('texts.individual_account') }} - - - - {{ __('texts.company_account') }} - - @endcomponent - - @component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.account_holder_name')]) - - @endcomponent - - @component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.country')]) - - @endcomponent - - @component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.currency')]) - - @endcomponent - - @component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.routing_number')]) - - @endcomponent - - @component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.account_number')]) - - @endcomponent - - @component('portal.ninja2020.components.general.card-element-single') - - - @endcomponent - - @component('portal.ninja2020.gateways.includes.pay_now', ['id' => 'save-button']) - {{ ctrans('texts.add_payment_method') }} - @endcomponent -@endsection - -@section('gateway_footer') - - -@endsection diff --git a/resources/views/portal/ninja2020/gateways/stripe/bacs/bacs_debit.blade.php b/resources/views/portal/ninja2020/gateways/stripe/bacs/bacs_debit.blade.php deleted file mode 100644 index f6a6b23d9aab..000000000000 --- a/resources/views/portal/ninja2020/gateways/stripe/bacs/bacs_debit.blade.php +++ /dev/null @@ -1,29 +0,0 @@ -
- @component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.name')]) - -
- @csrf - - - - - - - - - -
- - -
-
- @endcomponent -
diff --git a/resources/views/portal/ninja2020/gateways/stripe/bacs/pay.blade.php b/resources/views/portal/ninja2020/gateways/stripe/bacs/pay.blade.php deleted file mode 100644 index 979946e63d7a..000000000000 --- a/resources/views/portal/ninja2020/gateways/stripe/bacs/pay.blade.php +++ /dev/null @@ -1,29 +0,0 @@ -@extends('portal.ninja2020.layout.payments', ['gateway_title' => 'BACS', 'card_title' => 'BACS']) - -@section('gateway_head') - - - - - - -@endsection - -@section('gateway_content') - - - @include('portal.ninja2020.gateways.includes.payment_details') - - @component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.payment_type')]) - {{ ctrans('texts.bacs') }} ({{ ctrans('texts.bank_transfer') }}) - @endcomponent - - @include('portal.ninja2020.gateways.stripe.bacs.bacs_debit') - @include('portal.ninja2020.gateways.includes.save_card') - @include('portal.ninja2020.gateways.includes.pay_now') -@endsection - -@push('footer') - - -@endpush