Send an email upon successful payment to the buyer email

Requirement:
Send an email upon successful payment to the buyer email.

We are using the Payment API of the Java SDK to make credit card payments. We are not creating any Order/Customer/Invoice. Instead, we are directly using the Payment API to make the payment. Code details as below -

Scenario -
The frontend provides a token based on the card input and this token is used as source id for payment.

Backend Java code snippet for reference -

CreatePaymentRequest paymentRequest = CreatePaymentRequest.builder()
	.sourceId(request.getPaymentToken())
	.idempotencyKey(UUID.randomUUID().toString())
	.amountMoney(money)
	.autocomplete(true)
	.locationId(locationId)
	.buyerEmailAddress(<<valid email id>>)
	.build();

CreatePaymentResponse paymentResponse = squareClient.payments().create(paymentRequest);
Payment payment = paymentResponse.getPayment().get();

Based on the above code, the payment is successful but, no email is received in the buyerEmailAddress.

Does Square support sending email automatically on successful payments. We are currently using the Sandbox environment for testing purposes.

Is there any other possibility using Square to send emails automatically.

:waving_hand: I’m Square Dev AI, here to help answer your question!
Based on the information you’ve provided, the following documentation will help answer your question:

Additional Documentation

Take Payments
Take Payments
Download, Configure, and Run the Client Sample

If this documentation helped you find a solution, please check the box indicating that this reply solves the problem.
Otherwise one of our Developer Advocates will provide additional assistance shortly.

Square’s Payments API does not automatically send emails to buyers upon successful payment. The buyerEmailAddress field in the CreatePaymentRequest is used for record-keeping purposes and does not trigger any email notifications.

To send an email upon successful payment, you would need to implement this functionality in your application. You can achieve this by setting up a notification system in your backend that listens for successful payment events and sends an email to the buyer using an email service provider like SendGrid, Mailgun, or similar.

Additionally, you can use Square’s webhooks to listen for payment events. By subscribing to the payment.updated webhook, your application can be notified when a payment status changes to COMPLETED, and you can then trigger an email to be sent to the buyer. This approach ensures that emails are sent only after the payment is confirmed as successful.

This answer was reviewed by @Bryan-Square.