Hi everyone,
We are integrating Square payment into our site, can I ask a few straight questions ? in Square website I saw a code like blow : and MY QUESTION is how do we pass amount we got from other payment page of our site and pass it to backend,
I tried to get amount from cookie and put it in JSON.stringify({ }) function and convert to Long in backend but that doesn’t seem to work so that’s why I feel urgent to ask , are we allowed to put amount in JSON.stringify({ }) and pass it to backend, if no, could anyone shed some lights on how do we pass amount we got from frontend and pass to backend ? thanks
async function createPayment(token) {
const body = JSON.stringify({
locationId,
sourceId: token,
});
const paymentResponse = await fetch( payments, {
method: ‘POST’,
headers: {
‘Content-Type’: ‘application/json’,
},
body,
});
if (paymentResponse.ok) {
return paymentResponse.json();
}
const errorBody = await paymentResponse.text();
throw new Error(errorBody);
}