Closed ycourse closed 9 years ago
I reread your question and it looks like you just pass the option in on subscription creation.
def update_plan(role)
self.role_ids = []
self.add_role(role.name)
unless customer_id.nil?
customer = Stripe::Customer.retrieve(customer_id)
customer.update_subscription(
plan: role.name,
cancel_at_period_end: true
)
end
true
rescue Stripe::StripeError => e
logger.error "Stripe Error: " + e.message
errors.add :base, "Unable to update your subscription. #{e.message}."
false
end
Using the stripe event engine, you can tie into a webhook from stripe.
The gem has been updated since this app was built, I believe, so double check the documentation for stripe event.
You can see the types of events you can hook into here: https://stripe.com/docs/api?lang=ruby#event_types
Here is an example
StripeEvent.configure do |events|
events.subscribe 'customer.subscription.deleted' do |event|
# your logic here
end
end
Hey guys,
I want to cancel automatically subscription for my customers after One year.
I heard that this object can help me....
How can i do this ?
Thank you.