Managing payments in your app: Check out the checkout

Jen Person
Aug 5 · 3 min read

Let’s walk through the next steps in the checkout process!

Image for post
Image for post
It’s time to check out! Source

Are you new to this series? Check out the first blog for an introduction and a table of contents!

Knowing that my crochet patterns are sure to be a hit, I’m eager to get going with the next step of building my shop! So far, I have a function that adds the inventory data to Cloud Firestore and a function that creates items in Stripe.

Stripe Checkout

As discussed in the last blog, Checkout creates a secure, Stripe-hosted payment page that lets you collect payments quickly. Checkout requires server-side and client-side components. On the server side, you create a Checkout Session. This returns a Session ID, which you pass back to the client to complete checkout.

Checkout Sessions

A Checkout Session represents the details of your customer’s intent to purchase. You create a Session when your customer wants to pay for something. After redirecting your customer to a Checkout Session, Stripe presents a payment form where your customer can complete their purchase.

Stripe Checkout requires both server and client components

Image for post
Image for post

Server for security

The Stripe Checkout client-server handshake is necessary to protect the validity of your data. For example, if pricing information were passed directly from the client, then there would be the potential for that price to be modified by the user. Rest assured I will not sell my sock patterns for less! I painstakingly created these patterns and if I don’t value my time, nobody else will! Whenever possible and appropriate, ensure that the client cannot modify data, especially if it’s data related to getting paid.

Use a server to ensure that the client cannot modify key data

Cloud Run

Image for post
Image for post

According to something written by a marketer with much better writing talent than I, Cloud Run enables you to write code your way by deploying any container that listens for requests or events. You can build applications in your favorite language, with your favorite dependencies and tools, and deploy them in seconds. And it abstracts away all infrastructure management by automatically scaling up and down from zero almost instantaneously — depending on traffic. Cloud Run only charges you for the exact resources you use.

Now you might be wondering why I’m using Cloud Run for this and not Cloud Functions, considering the first iteration of this project used Cloud Functions. Cloud Functions can also be a great tool to use here. Personally, I want to explore the flexibility that Cloud Run provides. If Node.js isn’t your jam, you can write this same functionality in the language of your choice and deploy it to Cloud Run the same way. And in the event you decide you want to take your app elsewhere, simply build your container and deploy it to the service of your choice.

Man running on a path surrounded by trees and fall leaves
Man running on a path surrounded by trees and fall leaves
Run happy with Cloud Run! Source

Ready?

Now that you have an overview of Stripe Checkout and Cloud Run, you’re ready to build this part of the project! Here are some next steps to take:

Google Cloud - Community

Google Cloud community articles and blogs

Jen Person

Written by

Developer Relations Engineer for Google Cloud. Pun connoisseur.

Google Cloud - Community

A collection of technical articles and blogs published or curated by Google Cloud Developer Advocates. The views expressed are those of the authors and don't necessarily reflect those of Google.

Jen Person

Written by

Developer Relations Engineer for Google Cloud. Pun connoisseur.

Google Cloud - Community

A collection of technical articles and blogs published or curated by Google Cloud Developer Advocates. The views expressed are those of the authors and don't necessarily reflect those of Google.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch

Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore

Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store