diff --git a/app/controllers/spree/credit_cards_controller.rb b/app/controllers/spree/credit_cards_controller.rb index 9b4c2d971d..bd623d4154 100644 --- a/app/controllers/spree/credit_cards_controller.rb +++ b/app/controllers/spree/credit_cards_controller.rb @@ -27,6 +27,7 @@ module Spree authorize! :update, @credit_card if @credit_card.update(credit_card_params) + remove_shop_authorizations if credit_card_params["is_default"] render json: @credit_card, serializer: ::Api::CreditCardSerializer, status: :ok else update_failed @@ -56,6 +57,10 @@ module Spree private + def remove_shop_authorizations + @credit_card.user.customers.update_all(allow_charges: false) + end + # It destroys the whole customer object def destroy_at_stripe stripe_customer = Stripe::Customer.retrieve(@credit_card.gateway_customer_profile_id, {})