Open FanaHOVA opened 9 years ago
Yes, I'd go with overwriting finalize_new_subscription!
in subscription.
However, the syntax for that would be:
def finalize_new_subscription!
# code goes here
end
To those who interested (not strongly related to the topic):
if you want to top up user credits every month (upon successful prolongation of subscription), then you should use this method:
class Subscription < ActiveRecord::Base
include Koudoku::Subscription
belongs_to :user
belongs_to :coupon
def payment_succeeded(amount)
user.update_attribute(:paid_subscription, true) unless user.paid_subscription?
user.credit.increment!(:amount, 10) # add 10 credits
end
def finalize_cancelation!
user.update_attribute(:paid_subscription, false) if user.paid_subscription?
end
end
maybe it will help someone. P.S.: Don't forget to add webhooks to your stripe account.
Hi
I've koudoku installed in my app; my user model has a "credits" column, credits are obtained on sign up to each subscription level so I'd like to do something like this:
How can it be done? The documentation on that part is really vague, I imagine this on the Subscription model could work?
Thanks in advance.