Vote count:
0
so I just noticed I had a small problem. I'm using stripe as my payment processor, and what happened was quite simple. I had a bug in my code which didn't allow me to save the customer_id_token and change a boolean called subscription active.
However the payment still went through (confirmed in stripe logs). Thus it's obvious I don't have proper validations in place as this should never happen. Here's what my code looks like now:
def create
customer = Stripe::Customer.create(
:email => current_user.email,
:plan => params[:plan_id],
:card => params[:stripeToken]
)
current_user.update_attributes!(
:stripe_customer_token => customer.id,
:subscription_active => true,
:plan_id => params[:plan_id]
)
redirect_to root_url, notice: 'Successfully subscribed'
rescue Stripe::CardError => e
flash[:error] = e.message
redirect_to charges_path
end
I can see that they are obviously not really connected with one another, and my question is how can I turn this into something that if the customer_token f.ex isn't saved it won't go through with the payment either?
asked 1 min ago
Unable to verify stripe payment correctly in controller
Aucun commentaire:
Enregistrer un commentaire