From 3544b7de7ae8ca4f9222d3669169d0905f7e9e56 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Mon, 7 Jun 2021 20:37:27 +0100 Subject: [PATCH 1/2] Remove Stripe Decorator The method being overridden here is the same in the upstream --- app/models/spree/gateway/stripe_sca.rb | 1 - .../billing/gateways/stripe_decorator.rb | 19 ------------------- 2 files changed, 20 deletions(-) delete mode 100644 lib/active_merchant/billing/gateways/stripe_decorator.rb diff --git a/app/models/spree/gateway/stripe_sca.rb b/app/models/spree/gateway/stripe_sca.rb index 7ede0aa252..b89163a5f0 100644 --- a/app/models/spree/gateway/stripe_sca.rb +++ b/app/models/spree/gateway/stripe_sca.rb @@ -5,7 +5,6 @@ require 'stripe/credit_card_cloner' require 'stripe/authorize_response_patcher' require 'stripe/payment_intent_validator' require 'active_merchant/billing/gateways/stripe_payment_intents' -require 'active_merchant/billing/gateways/stripe_decorator' module Spree class Gateway diff --git a/lib/active_merchant/billing/gateways/stripe_decorator.rb b/lib/active_merchant/billing/gateways/stripe_decorator.rb deleted file mode 100644 index fcd23a6446..0000000000 --- a/lib/active_merchant/billing/gateways/stripe_decorator.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -# Here we bring commit 823faaeab0d6d3bd75ee037ec894ab7c9d95d3a9 from ActiveMerchant v1.98.0 -# This is needed to make StripePaymentIntents work correctly -# This can be removed once we upgrade to ActiveMerchant v1.98.0 -ActiveMerchant::Billing::StripeGateway.class_eval do - def authorization_from(success, url, method, response) - return response.fetch('error', {})['charge'] unless success - - if url == 'customers' - [response['id'], response.dig('sources', 'data').first&.dig('id')].join('|') - elsif method == :post && - (url.match(%r{customers/.*/cards}) || url.match(%r{payment_methods/.*/attach})) - [response['customer'], response['id']].join('|') - else - response['id'] - end - end -end From 15b386bce38d253c3cfe797b530734c79725c176 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Mon, 7 Jun 2021 22:47:16 +0100 Subject: [PATCH 2/2] Set :execute_threed option to explicitly handle 3DS responses --- app/models/spree/gateway/stripe_sca.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/models/spree/gateway/stripe_sca.rb b/app/models/spree/gateway/stripe_sca.rb index b89163a5f0..8e77d3f258 100644 --- a/app/models/spree/gateway/stripe_sca.rb +++ b/app/models/spree/gateway/stripe_sca.rb @@ -111,6 +111,7 @@ module Spree options[:description] = "Spree Order ID: #{gateway_options[:order_id]}" options[:currency] = gateway_options[:currency] options[:stripe_account] = stripe_account_id + options[:execute_threed] = true # Handle 3DS responses options end