I’m trying to work out how to get access to the email entered on the Square checkout form so that we can email a custom receipt. I can’t find any way to get access to this email below:
const order = await square.ordersApi.retrieveOrder(orderId);
const fullPayment = await square.paymentsApi.getPayment(order.result.order.tenders[0].id);
I would have expected fullPayment to contain buyerEmailAddress, but it’s undefined? We aren’t creating a customer for the purchase so customerId is also undefined.
The email that is entered into the checkout will create a Square customer if one does not already exist with that email. If customer already exists, their ID will be associated with the order.
@josh-square thanks for the reply. I’ve managed to find the customer that has been created with the email, however I don’t seem to be able to link it to the payment.
When doing
const order = await square.ordersApi.retrieveOrder(orderId);
The customerId is undefined and is also undefined under the payment/tender.
app id: sandbox-sq0idb-CbInicNI0l7tvsCgvUHLmw
customer id: 0MHKXWX61SYEVZ7SK27KDYPX5W (I’m not sure if this is the correct one for the payment as it doesn’t seem to be linked)
payment id: rJQB51mQK5q5DfsuIm1fVpvFuaB
order id: pmBmBE5cUcdY30D4R4XEqIF4h7JZY
When calling “Retrieve order” I would expect the customer_id field to be populated, or when calling “Get payment”, buyer_email_address.
I don’t actually need a customer, just the email provided.
Hey @aejb, we actually noticed in your screenshot that you’re using the old Checkout API endpoint (CreateCheckout). It has since been replaced with CreatePaymentLink. While CreateCheckout remains available to use, I’d definitely recommend using CreatePaymentLink, if possible. It will allow for the email behavior described above and will also be the endpoint to receive new feature updates in the future.