How to execute controller actions after success ajax return
Hello everyone!
I've integrated stripe payment and everything looks great! The only thing I don't know how to continue is how to execute some controller code when the AJAX query return success response. Any ideas? Here is the javascript code:
@laralex What do you mean? If a controller returns a response then it’s done. A controller doesn’t return a response and then do more stuff.
What is it you’re actually trying to do? Because a snippet of Stripe Elements code doesn’t really explain anything about what you want to do in your controller.
@martinbean Currently I have a controller with a method that creates a Payment Intent and gets the "Client Secret" which is required for the AJAX request that I posted above. How can I do something with my database after the payment is successful?
@LarAlex It is just another POST route where you disable CSRF to allow the webhook to call it. Then you process the data in there. The docs normally tell you want kind of data to expect.
@LarAlex implementing yourself other AJAX to records paiment success/failure whatever the first call will reply need to foresee all types of response the payment service can send back to your request.
following @sinnbeck 's approach you keep the responsibility on the service you pay to do so.