You can write an Appwrite function to make HTTP request to the endpoints, and also update Appwrite collections that you need to update.
Best case use of webhooks.?
Votes
0
Replies
24
Participants
Unknown
Messages
25
Rank 3: Container
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
Rank 3: Container
Yes yes
Rank 3: Container
The provider sends the json response with payment details like transaction ID, payment and status
Rank 3: Container
So does the cloud function pick this json response or its just triggered
It will be sent in body right?
Rank 3: Container
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
Rank 3: Container
Sorry am left behind.
Rank 3: Container
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
Admin
i highly suggest you take a look at the docs and play around with the functions to get a better idea
Rank 3: Container
Thanks
Rank 3: Container
I've read the docs. I have got an idea where to start.
Rank 3: Container
But I guess you can't pass the json body when you execute on certain events or schedule
Admin
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
Rank 3: Container
What do you mean by payload of the event.??
Admin
so for example, if the event is a document update, the body will be the updated document...
Rank 3: Container
Thanks 🤜🤛