From 1b820ea85c6df06dacd65bdb36f6d00214979194 Mon Sep 17 00:00:00 2001 From: luisramos0 Date: Mon, 13 Jan 2020 19:27:16 +0000 Subject: [PATCH] Fix rubocop issues in credit_cards_controller --- .../spree/credit_cards_controller.rb | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/app/controllers/spree/credit_cards_controller.rb b/app/controllers/spree/credit_cards_controller.rb index a46937eb6c..3da82cd698 100644 --- a/app/controllers/spree/credit_cards_controller.rb +++ b/app/controllers/spree/credit_cards_controller.rb @@ -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