Class: SpreeStripe::AttachCustomerToCreditCardJob

Inherits:
BaseJob
  • Object
show all
Defined in:
app/jobs/spree_stripe/attach_customer_to_credit_card_job.rb

Instance Method Summary collapse

Instance Method Details

#perform(order_id) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'app/jobs/spree_stripe/attach_customer_to_credit_card_job.rb', line 3

def perform(order_id)
  return if Spree.user_class.blank?

  order = Spree::Order.find_by(id: order_id)
  return if order.blank? || order.user_id.blank?

  gateway = order.store.stripe_gateway
  return if gateway.blank?

  user = Spree.user_class.find_by(id: order.user_id)
  return if user.blank?

  gateway.attach_customer_to_credit_card(user)
end