Skip to main content

Stripe Payment Gateway Setup

In this section we will discuss step by step process for integrating Stripe payment gateway in Blink.

Collect Stripe Connection Keys

Stripe Keys

  • Open the backend code in VS code and go to .env file, then place your secret key in STRIPE_SECRET_KEY variable and save it.
.env
# Stripe
STRIPE_SECRET_KEY="****************************************************************"
caution

By default Stripe comes with Test mode. You can use test mode to locally test stripe payments. To accept real money payments, follow stripe business onboarding process.

Create Product on Stripe

  • From dashboard go to Product catalog.
  • Press on Create a product button.
info

We have 2 paid product for subscription. There names are

  1. Pro
  2. Premium

Monthly price for Pro subscription is $3.99 and yearly rate is $39.00.

Monthly price for Premium subscription is $7.99 and yearly rate is $79.00.

You can price as you want.

Create Product on Stripe

  • For Pro product, provide name, description, amount, and select Recurring payment. Billing period should be Monthly, Unit quantity = 1. Save the product.
  • Then collect and save the price id of monthly subscription.

Get Product Price Id

  • Then go to the same product again and add another price, This time for Yearly subscription. Again collect and save the price id of yearly subscription.
  • For Premium product, repeat the same process again.
  • Then open the backend code in VS code and go to .env file, then place your Price Ids in their respected fields.
  • Save the .env file.
.env
# Stripe Price IDs
STRIPE_SUBSCRIPTION_PREMIUM_PLAN_YEARLY_PRICE_ID="************************************"
STRIPE_SUBSCRIPTION_PREMIUM_PLAN_MONTHLY_PRICE_ID="************************************"
STRIPE_SUBSCRIPTION_PRO_PLAN_YEARLY_PRICE_ID="************************************"
STRIPE_SUBSCRIPTION_PRO_PLAN_MONTHLY_PRICE_ID="************************************"

Create Stripe Webhook

  • From Dashboard's bottom-left corner click on Developers
  • Then click on Webhooks tab and then click on Create an event destination.
  • Then Add an end point

Create Stripe Webhook

  • Your webhook Endpoint URL looks like https://www.yourdomain.com/api/stripe/server-webhook . Replace www.yourdomain.com with your domain name.
  • Then write description if you want and select Listen to Events on your account.
  • Then select all events
  • Copy endpointSecret code.
  • Click Add endpoint.
  • Now open .env file from backend code, and add the endpointSecret value to STRIPE_WEBHOOK_SECRET and save the file.
.env
# Stripe
STRIPE_SECRET_KEY="****************************************************************"
STRIPE_WEBHOOK_SECRET="************************************************"