add remove_shop_authorizations method to controller

This commit is contained in:
Andy Brett
2020-10-22 14:36:04 -07:00
parent c60dcc75cd
commit 6fdcd6218d

View File

@@ -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, {})