" width="1000" style="--opacity:1">
Sam Magura
Previously, we did deep dives into processing payments with the Braintree API and sending transactional email using the Mailchimp API. In this post, we'll leverage both Braintree and Mailchimp Transaction Email to build an ecommerce prototype.
In most ecommerce applications, after you place an order, you receive an email confirmation that lists the items you purchased. We'll build a prototype that implements this flow using Braintree and Mailchimp. We'll also use the Zero secrets manager to simplify the management of the Braintree and Mailchimp API keys.
This post will focus on just the key pieces of backend code that are needed to connect the Braintree and Mailchimp APIs into a single flow. If you would like a step-by-step guide on integrating with either of these services, please refer to the earlier blog posts that I linked above.
The code samples in this post are for TypeScript / Node.js, but feel free to adapt the code to the backend language you're working in.
Zero is a modern secrets manager built with usability at its core. Reliable and secure, it saves time and effort.
As a prerequisite for this step, you should have the following values stored in a Zero project:
Then, you can retrieve these values from your Node.js application using the Zero TypeScript SDK :
To create a transaction in the Braintree Sandbox, install the braintree
npm package and use code similar to the following:
Here, fake-valid-nonce
is a special value supported by the Braintree Sandbox. Normally, the payment method nonce would come from a Braintree API call that happens on the client side.
Now that we've processed the payment, we should use Mailchimp Transactional Email to send a confirmation to the user who placed the order. The code for this is very straightforward:
For this code to work, you'll need to have created a verified sending domain through the Mailchimp Transactional Email portal.
In this walkthrough, we created a proof of concept for an ecommerce application that both processes payments (using Braintree) and sends confirmation emails (using Mailchimp). Most production applications will need to make use of multiple 3rd party services, so it's important to understand how to leverage multiple services in tandem. This post also showed how using Zero as the single source of truth for your team's secret keys simplifies application development.
Almost every production application needs to send transactional email, e.g. for password resets and notifications. This article will walk you through integrating a Next.js web app with the Mailchimp Transactional Email API.
Braintree is one of the world's leading payment platforms. This article provides an in-depth guide to getting started with Braintree, from getting your API token all the way to collecting customer payment information and charging a credit card.
Zero is a modern secrets manager built with usability at its core. Reliable and secure, it saves time and effort.