spree / spree_gateway

Huge collection of payment gateways for @spree. Stripe, Braintree, Apple Pay, Authorize.net and many others!
https://spreecommerce.org
BSD 3-Clause "New" or "Revised" License
219 stars 438 forks source link

Do not set @client_secret and @pk_key if order has no valid payments #405

Open AlexeyBoldak opened 2 years ago

AlexeyBoldak commented 2 years ago

This issue happened with this type of cards

The cards in the previous table can’t be attached to a Customer object. To simulate a declined payment with a successfully attached card, use the next one. 4000000000000341

After successfully attaching the card inside CheckoutControllerDecorator#process_payments_and_set_keys we call order.process_payments!, we mark this card (payment method) as invalid. And this behaviour leads to error NoMethodError, undefined methodintent_client_key' for nil:NilClass`

I believe that this fix relates to this issue https://github.com/spree/spree_gateway/issues/379