
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
- Cannot find module failure
Sorry, Newbe question here. I just installed Appwrite and am trying to install my first Function an am having absolutely no luck what-so-ever getting this done...
- CSV Not Importing
We don’t seem to having any luck importing a simple .csv file. The import function acts like it’s working but no data imports or is shown in the collection The...
- Can't push functions when self-hosting o...
Hello, I'm a bit new to appwrite functions and recently hosted a fresh 1.7.4 on my portainer setup. Tried to create a new function and when trying to push it I ...
