Stripe Payment Integration
Stripe is an American financial services and software as a service (SaaS) the company offers payment processing software and application programming interfaces (APIs) for e-commerce websites and mobile applications. Follow the steps of this guide to set up Stripe payments in our Service API and connect it your frontend.
Getting Stripe credentials
To get started with Stripe, you need to sign up for their services, create an account. After getting an account, you need to use API keys, stripe use two API keys the publishable key and secret key, which you need to store in your .env file:
Note: you have to generate a Crystallize secret token and secret token id to your project follow the steps to generate Crystallize access tokens and add the variables to your .env file:
In the init payment endpoint default in the NextJS eCommerce boilerplate is /src/services/payment-providers/stripe/create-payment-intent.js, this is the typical flow you want to follow:
- Create a Crystallize order for the customer and the basket contents.
- Select Stripe as the payment option in the checkout.
- Receive an URL back from Stripe for where to redirect the user to approve the payment.
User payment confirmation
Once you click Stripe as payment in the checkout you will see empty card fields to fulfill the fields with correct data you have to use the Stripe test credit cards, then click pay now you will be redirected to the order confirmation page.
By default, the payment information can be used to update the order in Crystallize under /src/services/payment-providers/stripe/confirm-order.js. Here you can choose if you would like to store extra information.
What happens now is totally up to how you run your business. We advise you to set up proper fulfilment pipelines to orchestrate the orders, which you can use to manage the order fulfilment in a structured and automated way.