Ionic 4 PWA and Web Apps with Stripe Payment

Instructions on how to add Stripe payment to your Ionic 4 PWA and Web apps.


Stripe Payments app will allow you to securely charge money from a user’s credit card to your Stripe account using the Stripe API.
Our Stripe Payment Template contains ready to use services and the UI that makes it easy to use.

You will just need to add your actual Stripe API to make it work!


Video: Payment via Stripe for PWA and Web application

You can also check our Community video that shows how to organize the payment process in PWA and Web applications built with Ionic 4:

Getting Stripe Account

Before you can use the Stripe API you will need to sign up for an account: and then fill out the section Public business information on the Account Settings page. It is easy - just follow the instructions on the Register page.

Adding Products

Once you are logged into your activated account, you can start with adding the products you are going to sell. Select the Products tab and click + Add product to create your first product. In the new window, provide the needed product information, and once ready, confirm by clicking the Save product button. As many products as needed can be added one by one.
This is how the products list with three added items looks like:


Stripe API Developer Keys

Also, you can check the Developers > API key panel for your Stripe API keys.
Note, that the Publishable and Secret keys will be needed for your application later:




Please make sure that the account or business name in Stripe is successfully set up and you have added at least one product to operate with.

Create an App from the Template

Now, let's get the Ionic 4 Stripe Payments app.
This is going to be extremely simple as all you need to do is to download the template by clicking this link and then recreate the template backup under your account:

  1. Click Create new app.
  2. Click From backup and select the project backup file on your drive.
  3. Type in the app name.
  4. Click Create:

Now, when you open your app, you will see that all needed pages and services have been imported automatically and you are ready to go with the app:


The next setup is to connect the app backed with Stripe API.

Setting up StripeSessionCheckoutService

  1. In the Project view, unfold the Services folder and select StripeSessionCheckoutService.
  2. Go to its Request tab, and insert the Publishable key that can be found in the Developers > API key panel of the Stripe dashboard:

Setting up StripeKeys library:

  1. Now, go to the Server Code tab and select the StripeKeys library that has been imported with the backup:
  1. In the library code that opens in a new window, you will now need to provide the Stripe API Secret key. To find it, go back to the Developers > API key panel of the Stripe dashboard and copy Secret key.
  2. Click Save:

Testing the App

You are all set now and can test the app!

Click Test and use the test card number 4242424242424242 with any valid expiration date and CVV (read more here). Confirm the payment by clicking Pay:


You will be notified that the payment is successful and your Stripe Payments dashboard should show new charge info:


Note, that you can try using the following test cards to check different payment scenarios:

  • 4242424242424242 Succeeds and immediately processes the payment.
  • 4000000000003220 3D Secure 2 authentication must be completed for a successful payment.
  • 4000000000009995 Always fails with a decline code of insufficient_funds.


Important Note!

After the app has been tested, activate the account and don’t forget to switch from test mode to Live in your Stripe dashboard before going live (the test mode switch should be set to off).

Did this page help you?