Yes, it goes there but it will look like:
async function cardPayment(customerId, paymentToken, pennies, rando, orderNumber, email, phoneNumber) {
const mySecret = await getSecret("SQUARE");
const url = "https://connect.squareup.com/v2/payments";
let data = {
"idempotency_key": rando,
"amount_money": {
"amount": pennies,
"currency": "GBP"
},
"source_id": paymentToken,
"customer_id": customerId,
"note": "Order Number: " + orderNumber,
"customer_details": { /// inserted here?
"seller_keyed_in": true
}
}
const headers = {
"Square-Version": "2023-09-25",
"Authorization": "Bearer " + mySecret,
"Content-type": "application/json"
};
const request = {
method: 'POST',
headers: headers,
body: JSON.stringify(data)
};
return fetch(url, request)
.then(response => response.json())
.then(json => console.log(JSON.stringify(json),
jsonData(json, phoneNumber, email)
))
.catch((error) => {
console.log('Oops... ' + error);
});
}