I am trying to implement the Razorpay payment gateway in my React app, using Appwrite for the backend and Appwrite functions for handling payments. I have created a cloud function to process the payment, receiving data such as amount, currency, and orderId from the frontend. However, I am encountering an issue where these values (amount, currency, orderId) appear as undefined when checked via console logs in the cloud function. It seems like the data is not being properly passed to the cloud function. Below, I am providing the relevant code for both my placeYourOrder function and the cloud function.
placeYourOrder Code:) let amountInPaisa = Math.round(total * 100); if (isNaN(amountInPaisa) || amountInPaisa < 100) { toast.warn("The minimum amount should be ₹1", { autoClose: 1500 }); return; }
fetch(
"https://cloud.appwrite.io/v1/functions/function_id/executions",
{
method: "POST",
headers: {
"Content-Type": "application/json",
"X-Appwrite-Project": "projectId",
"X-Appwrite-Key":"API_KEY",
},
body: JSON.stringify({
amount: amountInPaisa ,
currency: "INR",
receipt: "receipt123",
}),
}
)
.then((response) => response.json())
.then((data) => {
console.log("Response from cloud function:", data);
})
.catch((error) => {
console.error("Error calling cloud function:", error);
});
Also attach the cloud function code.
Please help me as soon as possible.
Please somebody help me!
Recommended threads
- Transaction Error
AppwriteException: Transaction with the requested ID could not be found. at Generator.next (<anonymous>) { code: 404, type: 'transaction_not_found', r...
- Can not get the logged in user data in N...
I'm trying to get the user data after i log in with otp but it get this error : AppwriteException: User (role: guests) missing scopes (["account"]) at Gen...
- Operators and relationships
Do operators allow modification of array of relationships?