This tutorial will help you deploy the Stripe + Firebase/GCP demo to your Firebase/GCP project.
The demo showcases an event-driven service that processes payments and receipt delivery automatically with virtually unlimited scalability, auto retry, and data analytics integration. It uses the following products and services:
It takes approximately 10 minutes to complete the tutorial.
Click Start to continue.
-
Set up Stripe. In the Stripe Dashboard, get your test API keys. Write down both the publishable key and the secret key.
-
Create a new Google Cloud Platform project.
Open the Google Cloud Console. Create a new Google Cloud Platform project.
-
Enable Cloud Firestore.
In the Cloud Console, select Firestore from the left navigation lane. Use Cloud Firestore in Native mode and us-central for this tutorial. Click Create Database.
-
Cloud Console will ask for your project ID. Choose the same one as your Google Cloud Platform project created earlier in the list.
-
Authenticate Cloud SDK:
gcloud config set project YOUR-PROJECT-IDReplace
YOUR-PROJECT-IDwith the ID of your Google Cloud Platform project.
Click Next to continue.
-
Click Add Endpoint.
Type in
https://us-central1-[YOUR-GCP-PROJECT].cloudfunctions.net/fulfillmentas the the endpoint URL. Replace[YOUR-GCP-PROJECT]with the ID of your Google Cloud Platform project. Use the lastest API version, and addpayment_intent.succeededas the event to send. Click Add Endpoint. -
In the endpoint details page, click Click to Reveal to reveal to the signing secret. Write down the secret. This is the secret for the fulfillment endpoint.
-
Return to the Webhooks page. Repeat the steps above and add another endpoint.
Type in
https://us-central1-[YOUR-GCP-PROJECT].cloudfunctions.net/cancellationas the the endpoint URL. Replace[YOUR-GCP-PROJECT]with the ID of your Google Cloud Platform project. Use the lastest API version, and addpayment_intent.payment_failedas the event to send. Click Add Endpoint.Similarly, reveal the signing secret of the new endpoint. This is the secret for the cancellation endpoint.
-
Open
gcp_quickstart.shfrom the file explorer on the left side. -
Edit the first two lines of the file. Replace
YOUR-STRIPE-API-KEY,YOUR-SENDGRID-API-KEY,YOUR-FULFILLMENT-ENDPOINT-SECRETandYOUR-CANCELLATION-ENDPOINT-SECRETwith values of your own. -
Run the following command to deploy the functions:
chmod +x gcp_quickstart.sh ./gcp_quickstart.shIt may take a few minutes to complete the operations.
Click Next to continue.
First, open app/static/stripe.js in the file explorer. Replace
YOUR-API-KEY with the value of your Stripe public API key.
Run the command below to start the example app that incorporates the payment process:
cd ~/stripe-google-demo/app
pip3 install -r requirements.txt --user
python3 main.py
If you are running this tutorial in Cloud Shell, click the Web Preview Buttion ()
on the top right of the screen, then click Preview on Port 8080 to open
the web app. Otherwise, open your browser and go to localhost:8080.
You may use the VISA card 4242 4242 4242 4242 to make the purchase. Pick any
future date as the expiration date, any 3-digit number as the CVC, and any
5-digit number as the zip code. You should see a confirmation email in your
inbox soon. The charge should also be visible in the Stripe dashboard.
Click Next to continue.
You have deployed the demo.