class CashOut::Payments::Customer::Create
Public Instance Methods
execute()
click to toggle source
# File lib/cash_out/payments/customer/create.rb, line 10 def execute customer = create_stripe_customer user.stripe_id = customer["id"] if customer.is_a?(Stripe::Customer) validate_and_save(user) end
Private Instance Methods
create_stripe_customer()
click to toggle source
# File lib/cash_out/payments/customer/create.rb, line 18 def create_stripe_customer Stripe::Customer.create(source: stripe_token) rescue *STRIPE_ERRORS => e if e.class == Stripe::CardError errors.add(:stripe, I18n.t('cash_out.customer.invalid_card')) else errors.add(:stripe, e.to_s) end end
customer_is_nil()
click to toggle source
# File lib/cash_out/payments/customer/create.rb, line 29 def customer_is_nil unless user.stripe_id.blank? errors.add(:stripe, I18n.t('cash_out.customer.account_already_exists')) end end