DEV Community

Cover image for Providing receipts for in-person transactions with Terminal
Azaanephron
Azaanephron

Posted on

Providing receipts for in-person transactions with Terminal

Recently, my colleague Charles Watkins wrote a 4-part intro series to Stripe Terminal, our in-person payment solution. Charles' articles will teach you how to set up and register a Terminal device and build an app to accept or cancel payments. Additionally, I’ve been looking into other features including how to collect tips with Terminal. In this post, I’ll explain how to provide digital receipts for in-person purchases.
Digital receipts are very convenient for both customers and merchants. They eliminate the need for paper, help keep track of your spendings and are very helpful if you need to submit expenses.

Triggering an automatic email receipt

If you’ve used Terminal before or if you read the blog series linked above, you’ll know that to process payments, you need to start by creating a PaymentIntent. By default, this does not send receipts once the payment is processed. To use this feature, you only need to add the receipt_email field in the payment intent object, with the email value your customer would enter in your UI.

{const intent = await stripe.paymentIntents.create({
    currency: "usd",
    amount: 1000,
    payment_method_types: ["card_present"],
    capture_method: "manual",
    receipt_email: "edsger@dijkstra.com"
});
Enter fullscreen mode Exit fullscreen mode

Once the payment intent is created, it needs to be processed using the processPaymentIntent method, passing the Terminal reader ID and the payment intent ID.

await stripe.terminal.readers.processPaymentIntent(
     reader.id, //the reader ID can be found by calling await stripe.terminal.readers.list()
     { payment_intent: intent.id }
);
Enter fullscreen mode Exit fullscreen mode

Finally, capturing the payment using the capture methods will automatically send an email to the address provided.

await stripe.paymentIntents.capture(intent.id);
Enter fullscreen mode Exit fullscreen mode

Creating custom receipts

Image description

The design and content can be updated via the Stripe dashboard. You can select which language to use for receipts (English, French, Portuguese, etc.) in your email receipt settings and update the logo and colors in the branding settings.

Image description
Screenshot of the Stripe dashboard showing the branding page where colors and logos can be edited.

Additionally, you can add details about your cancellation policy by using the description field when creating your payment intent.
Some things to note: a receipt will only be sent after a successful payment. A canceled or failed transaction will not generate a receipt.
Now you should be able to automatically send receipts to your customers after each successful in-person transaction!

Let us know if you’re implementing this, and stay up to date with Stripe developer updates on the following platforms:

📣 Follow @StripeDev and our team on Twitter
📺 Subscribe to our Youtube channel
💬 Join the official Discord server
📧 Sign up for the Dev Digest

About the author

Charlie's profile picture. She has long brown hair and wears glasses. She is standing in front of a white wall with purple lights.

Image description
Charlie Gerard is a Developer Advocate at Stripe, a creative technologist and Google Developer Expert. She loves researching and experimenting with technologies. When she’s not coding, she enjoys spending time outdoors, trying new beers and reading.

Top comments (0)