ruby on rails - Automatically Setting a Devise User as a Stripe Customer -
My strategy is:
- Sign up user
- Automatically associate that user with the Stripe ID
I have tried to implement it:
I have created a user controller and it is registered with the registration controller Received:
devise_for: user,: controllers => {: Registration = & gt; 'User'}
After a user has saved I have created a callback:
after_save: set_stripe_customer_id private def set_stripe_customer_id end < / Pre>
Now, I think it needs to be here:
current_user.update_attribute (: stripe_id = & gt; ....
Docs show code like
Stripe :: Customer.create (: description = & gt; "Customer for test@example.com" ,: card = & gt; "tok_1046el4BfU4hLNTvxYcIz4rE" )
The thing is, I do not necessarily want my client to put their card immediately. However, this is not a big deal, I am fine to wait for the real point of purchase to wait for the need to register. My question is is that the easiest, minimum minimum code, do I automatically call my callback to be a stick customer Need?
for all standards
Stripe :: Customer.create Optional, so that you can do some bare bones:
set the def T_stripe_customer_id Customer = Bar :: Client. Create current_user.update_attributes: stripe_id = & gt; Create a subscription for Customer.id end
and then later, or update as much as you need.
However, I would say that this is not really necessary until you actually need to make a customer, there is no real result to wait (for example, because they are subscribing Are).
Comments
Post a Comment