Skip to main content

Payment Gateway

A payment gateway is a merchant service that authorizes card or bank payments for an app. In Hallo Doctor, the payment gateway is used when a user places an order for a doctor’s timeslot.

This guide explains how to set up Stripe payments and the required Stripe webhook.

Prerequisites

  • A Stripe account: https://stripe.com/
  • Firebase Cloud Functions already set up and deployed from /Halo_Doctor_Cloud_Function_Firebase

1) Get your Stripe API keys

  1. Open the Stripe Dashboard (Test mode): https://dashboard.stripe.com/test/dashboard
  2. Copy the Publishable key (pk_test_...) and the Secret key (sk_test_...).

Flutter Doctor

Add Publishable key to the Flutter client

Paste your Stripe publishable key into the Flutter project .env file in /Hallo_Doctor_Client_Firebase:

/.env
# Stripe
STRIPE_PUBLISHABLE_KEY=pk_test_your_publishable_key_here

Add Secret key to Firebase Cloud Functions

info

if your Hallo Doctor version is greater than or equal to 1.1.1 you just need to copy Stripe secret key to .env file at STRIPE_SECRET_KEY=put_your_stripe_key_here and skip the next step in this page

If your Hallo Doctor version is >= 1.1.1

  • back to Firebase Cloud function folder /Halo_Doctor_Cloud_Function_Firebase
  • open it with CMD
  • run the command below, but change the key to your Stripe Secret Key
/Halo_Doctor_Cloud_Function_Firebase/.env
# Stripe
STRIPE_SECRET_KEY=sk_test_your_secret_key_here
  • now we can deploy it using this command
firebase deploy

<<<<<<< HEAD

If your Hallo Doctor version is <= 1.0.19

Set the functions config value (replace with your secret key):

firebase functions:config:set stripe.token="sk_test_your_secret_key_here"

Deploy:

firebase deploy

2) Create a Stripe webhook endpoint

After your Cloud Functions are deployed, configure a Stripe webhook so Stripe can notify your Firebase server when a payment succeeds (so the app can update the order status to success).

Get your webhook URL from Firebase

  1. Open Firebase Console → your project → Functions
  2. Copy the URL shown for the stripeWebhook function.

Flutter Doctor

Add the endpoint in Stripe Dashboard

  1. Open Stripe Dashboard: https://dashboard.stripe.com/
  2. Go to DevelopersWebhooks
  3. Click Add endpoint
  4. Paste the stripeWebhook URL into Endpoint URL

Flutter Doctor

  1. Click Select events

Flutter Doctor

  1. Search and enable payment_intent.succeeded
  2. Click Add eventsAdd endpoint

Flutter Doctor

Copy the webhook signing secret

Open the webhook you just created and copy the Signing secret (whsec_...).

Flutter Doctor

3) Add Stripe webhook secret to Firebase Cloud Functions

If your Hallo Doctor version is >= 1.1.1

Add your webhook secret to the Cloud Functions .env:

/Halo_Doctor_Cloud_Function_Firebase/.env
# Stripe
STRIPE_WEBHOOK_SECRET=whsec_your_webhook_signing_secret_here

Deploy:

firebase deploy

If your Hallo Doctor version is <= 1.0.19

Set the functions config value (replace with your webhook secret):

firebase functions:config:set stripe.webhook_secret="whsec_your_webhook_signing_secret_here"
  • now we can deploy it using this command
firebase deploy

Notes on using a different payment gateway

If you want to use a different payment gateway provider, the main integration point is:

  • lib/app/service/payment_service.dart

You’ll also need a matching server-side implementation in /Halo_Doctor_Cloud_Function_Firebase to create/verify payments and to receive webhook notifications.