
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
- How to reduce DB Reads?
I just noticed that I hit the 500k db reads limit on my very small next js app with the most data being present in one collection having around 50 documents. ...
- Getting issue while migrating from Self ...
i try to migrating my project but when do this error come and dont allow to crate that migration
- error code:524 for functions running lon...
We are having this issue, no longer the function runtime or code, if it goes longer than 1 minute, there's no logs at all, just this error: **error code: 524**
