Fetching 3rd-party get each 2 hours

Hello,
I’m building a payment resource for my client on Wix. I created a way to redirect users to this 3rd party payment service and after the client pays for the product, the API sends a notification via a POST method which contains a code that allows the API user to consult the payment status. I already created a post_notification function on a http-functions.js file.

What I need now is a way to use this notification code to verify the payment status each 2 hours and if the order was paid, I need to include the client’s information (given by this GET method) to a list. Any ideas how to do that?

I was thinking in adding these codes to a collection and go through the collections and using a webmodule to check for each code, but I think this would take too much time to run and how would I call this method in a .jsw file?

Here is the code:

export function post_notification (request) {
let options = {
“headers”: {
“Content-Type”: ‘application/json’,
}
}
return request.body.text()
.then((body) => {
let requestBody = {
“notificationCode”: body.slice(body.indexOf(“=”)+1, body.indexOf(“&”)),
“notificationType”: body.slice(body.lastIndexOf(“=”)+1, body.length)
}

return wixData.insert(“Transacoes”, requestBody);
})
.then((results) => {
options.body = {
“inserted”: results
}
return created(options);
})
. catch ((error) => {
options.body = {
“error”: error
};
return serverError(options);
})
}

Hi,

what you need to do, is create yet another http function to go and look for paid orders and invoke it externally every 2 hours.
we currently do not have a clock like execution capability at wix code, so i am sure you can find such alternative on the web and just supply it with your site http function it should invoke using http every 2 hours.
i think you can configure iftt to execute a url every time interval. please share with us when you set it up
thanks,
Shlomi

I had exactly the same need. I solved this problem via zapier and a post request all hours in backend Wix, if you are interested to have more details, I’ll send you the code.
Francis

Hi,

very interesting!
as such executions are starting to be more popular with Wix Code i am sure many people of the community will gain a lot of value if you could please share your code, the business story behind your site and if you could, also a reference to how you accomplished it with Zapier

thanks,
Shlomi