I am setting up an endpoint to handle a webhook from a payment gateway in Toddle. According to the documentation: "Once the customer's browser is redirected, Flow will respond via a POST request to the callback URL provided by the merchant in the url_return parameter, passing a parameter called token. The merchant must implement a page to capture the token parameter sent by Flow and then consume the customer/getRegisterStatus service to obtain the registration result." The webhook sends a POST request with the content type application/x-www-form-urlencoded, and I need to capture a parameter called token located in the body of the request. How can I configure a handler in Toddle to receive and process this type of data correctly? Additionally, are there any extra configurations or best practices I should consider when handling POST requests in this format within Toddle?
Also, sounds like this is a merchant/payment type of call
Which should probably be made from a backend as well
Since these calls typically have secret keys which cannot be used in the frontend
Gabriel Salazar
16 days ago
Jan 23, 2025, 11:25 PM
The problem occurs because when registering a form in the payment gateway, the URL configured as a webhook is also used to redirect the user after completing the process. However, a webhook is designed to automatically receive data from the payment gateway server and not to be visited directly by the user. For example, if you configure a webhook with a tool like Buildship, when the user is redirected to that URL, instead of processing the information as a server would do, it simply displays the error message you see in the image.
Lucas G
16 days ago
Jan 24, 2025, 12:58 AM
Why would the webhook be the same as the redirect URL
Sounds like you could maybe use URL parameters to make it work
And run the status check onLoad if the parameters exist
Gabriel Salazar
16 days ago
Jan 24, 2025, 1:06 AM
This is what the documentation for that payment platform indicates. I have already solved it by creating a supabase edge function that serves as a webhook and when the user is redirected to the edge function URL, it redirects him to another URL.