How to add an action after_create after a user selects a stripe plan

Borja Soler
I am following this video to have a referral system.

Following it I have found easy to add a complete_referral! in the user model after a user is created.

  before_validation :set_referral_code, on: :create
  # after_create :complete_referral!
  validates :referral_code, uniqueness: true

  def set_referral_code
    loop do
    self.referral_code = SecureRandom.hex(6)
    break unless self.class.exists?(referral_code: referral_code)

  # def complete_referral!
  #  update(referral_completed_at:
    # add credit to referred_by user
  # end 

But I would like how can I add the after_create :complete_referral! after a user selects a plan and has a subscription in the jumpstart

You’re not receiving notifications from this thread.
© 2021 GoRails, LLC