Przejdź na język polski zmień na polski
Contact us +48 660 043 353 biuro@wiseweb.pl
or use contact form on our website
We are wiseweb - a great IT company.

We are a Software House, specializing in PHP, Java and React.js.

Stripe Integration in PHP – tutorial how to do e-commerce using Stripe

Stripe is a popular payment processor. One of the reasons why is so popular is the great API so allow start-ups to grow faster and be more financial-fluent.

If you need more information about the Stripe service, just check out the official website at https://stripe.com.

In this tutorial, we show you how you can integrate Stripe using PHP and Symfony framework.
Stripe is a popular payment processor. One of the reasons why is so popular is the great API so allow start-ups to grow faster and be more financial-fluent.

If you need more information about the Stripe service, just check out the official website at https://stripe.com.

In this tutorial, we show you how you can integrate Stripe using PHP and Symfony framework.
We recommend to try it in practice (code!) so you can get some Stripe skills immediately!

Approach:
- Use Stripe as much as we can, so we use the Stripe’s backend and its database with metadata,
- Create 2 categories (vegetables, fruits) and 4 products (cucumber, apple, lettuce, leek),
- Create 1 product service (Catering) so a user can order the catering service and will be charged automatically once a month,

We will skip the process of registration in Stripe as you can do it yourself – it’s simple!
Define products in Stripe
As already mentioned, we need to create 4 products and 1 service.
Let’s start to investigate, how products can be defined in Stripe backend.

After you log-in to your Stripe account, you can start defining your products.
Simply navigate to Orders -> Products and press the "New" button.

Stripe integration - product new

I've created 1 fruit and 3 vegetables.
This is how it should look like after you're done.

Stripe integration - list of products

We also need to store more data for a product, such as category and price, so we can purchase a product. For each product add a metadata key called: "category" and SKU. Below a sample product with "category" as Metadata and SKU added:

Stripe integration - sample product

And the list of all the products with SKUs added:

Stripe integration - list of products
Subscriptions in Stripe
Now, it's time to add a service so we can order a catering. Stripe will automatically charge a customer in a specified period of time. For testing purposes, I'll create a catering service, billed monthly.
It's pretty straightforward and very similar to creating standard products. Go to Billing -> Products and press the "New" button. Let's call it Catering and then click "Create product".

Stripe integration - subscriptions

Then we need to create a plan (possible to add more than one, but for testing purposes, we'll create only one) so a customer can subscribe to a plan. Notice the ID field = "catering". This is the plan identifier as we'll refer to it when subscribing a customer.

Stripe integration - list of subscriptions

If you are interested how to integrate Symfony with Stripe Api, check our next article at: https://www.wiseweb.pl/en/blog-symfony-integration-with-stripe-using-api/.
What we offer
Thank you for your visit.
If you have any question, do not hestitate to contact us