Sha256: f8f8a0d838b6a6f12dea0d8e312b7fd7dbd5a1dc20ea5534bdb26c10e243f7ce

Contents?: true

Size: 480 Bytes

Versions: 9

Compression:

Stored size: 480 Bytes

Contents

Spree::User.class_eval do
  has_many :subscriptions

  def find_or_create_stripe_customer(token=nil)
    return api_customer if stripe_customer_id?
    customer = if token
      Stripe::Customer.create(description: email, email: email, card: token)
    else
      Stripe::Customer.create(description: email, email: email)
    end
    update_column(:stripe_customer_id, customer.id)
    customer
  end

  def api_customer
    Stripe::Customer.retrieve(stripe_customer_id)
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
spree_account_recurring-2.0.0 app/models/spree/user_decorator.rb
spree_account_recurring-1.3.1 app/models/spree/user_decorator.rb
spree_account_recurring-1.2.1 app/models/spree/user_decorator.rb
spree_account_recurring-1.3.0 app/models/spree/user_decorator.rb
spree_account_recurring-1.2.0 app/models/spree/user_decorator.rb
spree_account_recurring-1.1.5 app/models/spree/user_decorator.rb
spree_account_recurring-1.0.7 app/models/spree/user_decorator.rb
spree_account_recurring-1.1.4 app/models/spree/user_decorator.rb
spree_account_recurring-1.0.6 app/models/spree/user_decorator.rb