You can write an Appwrite function to make HTTP request to the endpoints, and also update Appwrite collections that you need to update.
Payments providers have a callback url which is where the response is sent after user has paid. How can I use this to automatically trigger a function that updates my table
Ohh I see, create a function
The function will have it's own domain
Use that domain to be the call back URL
The provider will make a request to that callback URL (i.e. your function)
And you can handle the request how you wish
Yes yes
The provider sends the json response with payment details like transaction ID, payment and status
So does the cloud function pick this json response or its just triggered
It will be sent in body right?
Yes as a json
The body will be passed in
export default async ({ req, res, log }) => {
log(req.bodyRaw); // Raw request body, contains request data
log(JSON.stringify(req.body)); // Object from parsed JSON request body, otherwise string
log(JSON.stringify(req.headers)); // String key-value pairs of all request headers, keys are lowercase
log(req.scheme); // Value of the x-forwarded-proto header, usually http or https
log(req.method); // Request method, such as GET, POST, PUT, DELETE, PATCH, etc.
log(req.url); // Full URL, for example: http://awesome.appwrite.io:8000/v1/hooks?limit=12&offset=50
log(req.host); // Hostname from the host header, such as awesome.appwrite.io
log(req.port); // Port from the host header, for example 8000
log(req.path); // Path part of URL, for example /v1/hooks
log(req.queryString); // Raw query params string. For example "limit=12&offset=50"
log(JSON.stringify(req.query)); // Parsed query params. For example, req.query.limit
return res.send("All the request parameters are logged to the Appwrite Console.");
};
If it's json, req.body will already be parsed automatically
So you can access the request info
Sorry am left behind.
Can you give me an idea how to fetch the json in c.function and use the to perform other tasks like updating payments table
i highly suggest you take a look at the docs and play around with the functions to get a better idea
Thanks
I've read the docs. I have got an idea where to start.
But I guess you can't pass the json body when you execute on certain events or schedule
for events, the body will be the payload of the event. for schedule, it doesn't make sense to have a body...you would use function variables or store data in the database
What do you mean by payload of the event.??
so for example, if the event is a document update, the body will be the updated document...
Thanks 🤜🤛
Recommended threads
- Error with realtime channels
I'm performing a subscription to realtime channels, and after a few seconds I get an exception with this error: {\"type\":\"error\",\"data\":{\"code\":1008,\"me...
- Bug: Cloud Function On Schedule Didn't R...
Heya I have a cloud function with this cron `0 17 * * *` to run at 9AM PT every day. I have not touched this since I set it up, and it has been working fine s...
- functions
Code for function not being created in Github. Permissions are set correctly, repository is created, however no code is in the created repository. Just trying...