Fix some rubocop issues from previous commit

This commit is contained in:
luisramos0
2020-01-16 18:47:13 +00:00
committed by Luis Ramos
parent 4e84310d63
commit 38fd028a9f
4 changed files with 13 additions and 4 deletions

View File

@@ -58,7 +58,8 @@ module Spree
# Currently can only destroy the whole customer object
def destroy_at_stripe
if @credit_card.payment_method && @credit_card.payment_method.type == "Spree::Gateway::StripeSCA"
if @credit_card.payment_method &&
@credit_card.payment_method.type == "Spree::Gateway::StripeSCA"
options = { stripe_account: stripe_account_id }
end

View File

@@ -1,5 +1,7 @@
class Subscription < ActiveRecord::Base
ALLOWED_PAYMENT_METHOD_TYPES = ["Spree::PaymentMethod::Check", "Spree::Gateway::StripeConnect", "Spree::Gateway::StripeSCA"].freeze
ALLOWED_PAYMENT_METHOD_TYPES = ["Spree::PaymentMethod::Check",
"Spree::Gateway::StripeConnect",
"Spree::Gateway::StripeSCA"].freeze
belongs_to :shop, class_name: 'Enterprise'
belongs_to :customer

View File

@@ -4,7 +4,8 @@ module Api
delegate :serializable_hash, to: :method_serializer
def method_serializer
if object.type == 'Spree::Gateway::StripeConnect' || object.type == 'Spree::Gateway::StripeSCA'
if object.type == 'Spree::Gateway::StripeConnect' ||
object.type == 'Spree::Gateway::StripeSCA'
Api::Admin::PaymentMethod::StripeSerializer.new(object)
else
Api::Admin::PaymentMethod::BaseSerializer.new(object)

View File

@@ -82,13 +82,18 @@ class SubscriptionValidator
def credit_card_ok?
return unless customer && payment_method
return unless payment_method.type == "Spree::Gateway::StripeConnect" || payment_method.type == "Spree::Gateway::StripeSCA"
return unless stripe_payment_method?(payment_method)
return errors.add(:payment_method, :charges_not_allowed) unless customer.allow_charges
return if customer.user.andand.default_card.present?
errors.add(:payment_method, :no_default_card)
end
def stripe_payment_method?(payment_method)
payment_method.type == "Spree::Gateway::StripeConnect" ||
payment_method.type == "Spree::Gateway::StripeSCA"
end
def subscription_line_items_present?
return if subscription_line_items.reject(&:marked_for_destruction?).any?