Hi, I am processing payment from a financial service provider. It is independent of my Wix's website setup. However, once the payment is done, the payment website send the user back to Wix using POST method. But I am getting a 403 error. I guess I have to create a POST endpoint that when activated, redirects the user to the page I want.
How can I create a endpoint for the payment website to redirect to once it is done. It must be POST.
This is the response I got from my payment provider:
redirection url only should be on server site language i.e java,php, python, java script etc,
Hey @The Canine Company ! I see you use the ok() method. This method is used when you want to send a response with status 200.
If you want to send the status with 301 status try to use a response() method with any custom status code. Demo: https://alexanderz5.wixsite.com/redirect-example/_functions/veloRef
import { response } from 'wix-http-functions'; export function get_veloRef() { const url = 'https://www.wix.com/velo/reference/wix-http-functions/response'; return response({ status: 301, headers: { location: url, }, }); }
Hi, this is the function in my backend. It is being called perfectly. I need to redirect the user when the task is done. In the function, I have mentioned a comment line saying when I need to redirect the user. The link to redirect is also mentioned in line #7 with location:.
Should I try to implement router logic?
import { ok, notFound, serverError, badRequest } from 'wix-http-functions'; import wixData from 'wix-data'; export function post_myResponse(request) { const response = { "status" : 301, "headers": { "Content-Type": "application/json", "Location" : "https://www. thecaninecompany. in/order-success" } }; const today = new Date(); let currentTimestamp = today.toLocaleDateString() + " " + today.toLocaleTimeString(); let toInsert = { "response" : request.headers, "timestamp" : currentTimestamp }; wixData.insert("OrderResponse", toInsert); //Redirect user now return ok(response); }
J.D. is right, you should use http-functions. And you will prob. have to return a 200/ok if all is well. Returning nothing can lead to awkward results, it depends on implementation.
EDIT: look at the provider's docs. I have worked with interfaces where they expected the strangest things, like always returning a 200/ok, but if error, the error was expected to be included inside the returned (200/ok) object.
Right now, I have set it to www. thecaninecompany. in/order-success. But since it is a static web page, I am getting 403 error. I need something like www. thecaninecompany. in/payment-response.js, accepting POST response, which we will then redirect to the above url.
What's the URL of this post request?