Fix rubocop issues in credit_cards_controller

This commit is contained in:
luisramos0
2020-01-13 19:27:16 +00:00
committed by Luis Ramos
parent ec7b91bb68
commit 1b820ea85c

View File

@@ -10,10 +10,14 @@ module Spree
render json: @credit_card, serializer: ::Api::CreditCardSerializer, status: :ok
else
message = t(:card_could_not_be_saved)
render json: { flash: { error: I18n.t(:spree_gateway_error_flash_for_checkout, error: message) } }, status: :bad_request
render json: { flash: { error: I18n.t(:spree_gateway_error_flash_for_checkout,
error: message) } },
status: :bad_request
end
rescue Stripe::CardError => e
render json: { flash: { error: I18n.t(:spree_gateway_error_flash_for_checkout, error: e.message) } }, status: :bad_request
render json: { flash: { error: I18n.t(:spree_gateway_error_flash_for_checkout,
error: e.message) } },
status: :bad_request
end
def update
@@ -54,17 +58,22 @@ module Spree
# Currently can only destroy the whole customer object
def destroy_at_stripe
options = { stripe_account: stripe_account_id } if @credit_card.payment_method.type == "Spree::Gateway::StripeSCA"
if @credit_card.payment_method.type == "Spree::Gateway::StripeSCA"
options = { stripe_account: stripe_account_id }
end
stripe_customer = Stripe::Customer.retrieve(@credit_card.gateway_customer_profile_id, options || {})
stripe_customer = Stripe::Customer.retrieve(@credit_card.gateway_customer_profile_id,
options || {})
stripe_customer.delete if stripe_customer
end
def stripe_account_id
StripeAccount.find_by_enterprise_id(@credit_card.payment_method.preferred_enterprise_id).andand.stripe_user_id
StripeAccount.
find_by_enterprise_id(@credit_card.payment_method.preferred_enterprise_id).
andand.
stripe_user_id
end
def create_customer(token)
Stripe::Customer.create(email: spree_current_user.email, source: token)
end