3

I´m a Stripe beginner and I integrated the (really nice) Stripe checkout form into my Ionic App. Everything is working, the fields get validated and the I get the token and data in the callback.

I have more of an general question:

When everything is validated and the credit card token is generated, the button changes to green and the form closes. But that does not mean that the payment was successful.

Depending on a one-time or recurring payment, I need to send the data to my server, create a customer/charge/plan/subscription and there something can go wrong.

But in the end the user thinks everything is fine. I saw that other people are sending mails if something goes wrong.

What`s the best way to handle such an error?

Nico
  • 1,071
  • 1
  • 23
  • 39
  • I'm having the same issue, and there's not much out there on this. If you figure it out please share your solution.....or start a bounty – garrettmac Oct 27 '15 at 04:51
  • I just reached out to the stripe support. Let`s see what they are saying... – Nico Oct 27 '15 at 10:35
  • Are you testing over ssl? That may be your issue. Also did you integrate this codepen into your project? http://codepen.io/anon/pen/doZxvR. This is what I used a while back and noticed it would behave that way. Also do you have any snippets I may be able to help if I see what's going on. – garrettmac Oct 27 '15 at 19:05
  • Its not about any snippet here. Doesn`t matter if its Ionic or jQuery mobile or whatever. The checkout generates the token and the user thinks after that everything is fine. But the server needs to actually charge the user. The question is now how to handle this situation when something goes wrong. – Nico Oct 27 '15 at 22:25

1 Answers1

3

I got this answer from the Stripe support:

tl;dr

We have to add our own server validation or send an email to the user. I will implement a spinner after the checkout and if the server says OK then redirect the user. Also sending a mail is an option.

Hey there,

Thanks for reaching out to us, I'm happy to help you with this!

When you create a one-time charge or a subscription with Stripe in your backend, the payment is attempted synchronously, so you could simply create code to handle exceptions in your backend and inform the user that their charge failed. You could use this code to send an email or simply display an error message on the resulting page.

There's an outline of this in our API docs here. https://stripe.com/docs/api#errors

You can also use webhooks to inform your application of certain events (such as failed or successful payments) and trigger actions such as sending emails. More on this here:

https://stripe.com/docs/webhooks https://stripe.com/docs/api#event_types https://github.com/boucher/stripe-webhook-mailer

Stripe does not receive any information from you if the token is created but not processed on your backend, so in this case I'd offer a customer support email and if a customer writes in, ask them to enter their card details again through your app and make any adjustments to your integration to ensure you are charging the token after creation.

I hope this helps and please let me know if you have any other questions!

All the best

Nico
  • 1,071
  • 1
  • 23
  • 39
  • Would you happen to have a snippet of this integration? I'm still having a difficult time. – garrettmac Nov 03 '15 at 21:26
  • @Nico + garrett-mac-mac Agreed, I wanna see how other people are doing it. It's saying its processed to the client and its not..frustrating :( it's the worst –  Nov 03 '15 at 21:46