Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stripe payments - specific card numbers produce 500 error #379

Open
grzeszet opened this issue Mar 24, 2021 · 1 comment
Open

Stripe payments - specific card numbers produce 500 error #379

grzeszet opened this issue Mar 24, 2021 · 1 comment
Labels

Comments

@grzeszet
Copy link

grzeszet commented Mar 24, 2021

While making payments with Stripe, using specific card numbers that produce specific responses, a 500 error is occurring.

Number with Stripe description:

4000000000000341 - "Attaching this card to a Customer object succeeds, but attempts to charge the customer fail."

4100000000000019 - Results in a charge with a risk_level of highest. The charge is blocked as it's considered fraudulent.

https://sentry.io/share/issue/7a7d79e56ba44a53b5b708de3517850f/

Environment:
Affected version: spee.4.3.0.alpha (ruby 2.7.2; rails 6.0.0)
Configuration:
gem ‘spree’
gem ‘spree_gateway’
gem ‘spree_auth_devise’
gem ‘spree_static_content’
gem ‘spree_related_products’
gem ‘spree_sitemap’
gem ‘spree_analytics_trackers’
gem ‘spree_braintree_vzero’
gem ‘spree_i18n’

@alexboldak
Copy link

alexboldak commented May 26, 2022

@grzeszet Hey there, I am faced with this issue too

The problem was inside spree_gateway/lib/spree_frontend/controllers/spree/checkout_controller_decorator.rb

You can solve it by defining your own CheckoutControllerDecorator override

Something like this

# frozen_string_literal: true

module Spree
  module CheckoutControllerDecorator
    def self.prepended(base)
      base.before_action :process_payments_and_set_keys, only: :edit, if: proc { params[:state] == 'payment_confirm' }
    end

    def process_payments_and_set_keys
      @order.tap do |order|
        order.process_payments!
        payment = order.reload.payments.valid.where.not(intent_client_key: nil).last

        @client_secret = payment&.intent_client_key
        @pk_key = payment&.payment_method&.preferred_publishable_key
      end
    end
  end
end

::Spree::CheckoutController.prepend Spree::CheckoutControllerDecorator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants