Stripe Angular Integration with Node.js, Express & TypeScript

In this tutorial, you will learn about Stripe Angular integration. Basically, we will integrate the Stripe payment gateway inside a project that is built using Angular 13, Node.js, Express, and TypeScript.

I have provided the complete source code of the Stripe Angular integration example in this article.

Stripe Angular Integration Example Source Code

We start this project by creating a new Angular app inside the folder named “client”.

Shell
Shell
Shell

Now open app.module.ts file and copy/paste the following code to import the httpclient module.

app.module.ts

TypeScript

Its time to design an HTML template for our Stripe Angular integration example app. So, open the app.component.html file and copy/paste the following code into it.

app.component.html

HTML

Here’s a screenshot of how the template looks.

Angular Stripe Checkout Example
Angular Stripe Checkout Example

Now open the app.component.ts file and copy/paste the following code into it.

app.component.ts

Important Note: On line # 24, replace ###yourkey### text with your actual Stripe API key.

TypeScript

Now we are ready to carry out the payment. So, lets make a new service using the below command which will actually make the POST request to the backend.

Shell
TypeScript

Here we are making the POST request to the backend which does not exist yet. So, let’s create the backend for our Stripe Angular integration app using Node.js and Express.

First of all, make a new directory to hold our backend files. For the sake of this tutorial, I name it “server”.

Shell
Shell

Initialize the project.

Shell

Now we will install the required packages from npm.

Shell
Shell
Shell

index.js

Important Note:

  • On line # 6, replace ###stripe_secret_key### with your actual Stripe secret key. You will get it from the Stripe dashboard.
  • On line # 17, replace ###your_email### with your real email.
JavaScript

Project Screenshots

Stripe Angular payment
Stripe Angular payment

Here, you can use the following Stripe demo cards for testing.

NumberBrandCVCDate
4242424242424242VisaAny 3 digitsAny future date
5555555555554444MastercardAny 3 digitsAny future date
Angular Stripe payment successful
Angular Stripe payment successful

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.