Module: Pay::Billable::Stripe
- Defined in:
- lib/pay/billable/stripe.rb
Instance Method Summary collapse
- #create_stripe_subscription(name, plan) ⇒ Object
- #stripe_customer ⇒ Object
- #stripe_subscription(subscription_id) ⇒ Object
- #update_stripe_card(token) ⇒ Object
Instance Method Details
#create_stripe_subscription(name, plan) ⇒ Object
15 16 17 18 19 |
# File 'lib/pay/billable/stripe.rb', line 15 def create_stripe_subscription(name, plan) stripe_sub = stripe_customer.subscriptions.create(plan: plan) subscription = create_subscription(stripe_sub, 'stripe', name, plan) subscription end |
#stripe_customer ⇒ Object
4 5 6 7 8 9 10 11 12 13 |
# File 'lib/pay/billable/stripe.rb', line 4 def stripe_customer if processor_id? customer = ::Stripe::Customer.retrieve(processor_id) else customer = ::Stripe::Customer.create(email: email, source: card_token) update(processor: 'stripe', processor_id: customer.id) end customer end |
#stripe_subscription(subscription_id) ⇒ Object
29 30 31 |
# File 'lib/pay/billable/stripe.rb', line 29 def stripe_subscription(subscription_id) ::Stripe::Subscription.retrieve(subscription_id) end |
#update_stripe_card(token) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/pay/billable/stripe.rb', line 21 def update_stripe_card(token) customer = stripe_customer token = ::Stripe::Token.retrieve(token) return if token.card.id == customer.default_source save_stripe_card(token, customer) end |