I will write how to open Stripe’s customer portal.
Users will be able to:
・I want to end (cancel)
・I want to restart
・I want to check the payment history
You will need the following:
・Stripe’s “API Key”
・Zapier’s “Webhooks by Zapier” (Starter Plan or higher required)
・Google Spread Sheet
・Adalo ProPlan
Preparation 1
・Create a Google Spread Sheet
Prepare a table that can retrieve “id” of Users collection from email address.
ex)email,user_id
Preparation 2
・Create a Zap
Add a record ID to the Adalo Users collection when adding a user
Record ID is required when UpDate collection from Zapier,
Adalo does not tell you the record ID at this time, so you need to use Zapier.
With Zapier,
・Get “id” and “email address” with “New Record in Adalo”,
・Save the “id” and “email address” in Google Spread Sheet with “Create Spreadsheet Row in Google Sheets”.
-Save the value of “id” in the “id” property of the Users collection with “Update Record in Adalo”.
(1Zap)
Save Stripe’s “Customer ID” in Adalo’s Users collection at subscription start
With Zapier,
・Acquire Stripe’s “New Customer” event at “New Customer in Stripe”,
-Acquire the “id” of the Users collection from the email address in “Lookup Spreadsheet Row in Google Sheets”.
(By the way, how to update Date/Time property)
・ “Formatter by Zapier” “Date/Time”, get “end period” from Stripe’s “New Customer” event,
Changed format to “YYYY-MM-DDTHH:mm:ssZ”
Changed “+hhmm” at the end of “Formatter by Zapier” and “Text” to “.000Z”
Ex) “2020-07-21T18:46:06+0900” → “2020-07-21T18:46:06.000Z”
· Save the “StripeCustomerID” and “EndPeriod” of the Users collection with “Update Record in Adalo”
(2Zap)
When a subscriber presses the “Open Stripe Customer Portal” button on Adalo,
The following 1 to 3 should be executed.
Transit to the screen that lists “StripeSession URL collection”.
At Zapier,
・Create Webhook by Zapier “Catch Hook” and acquire “Webhook URL”
With Adalo,
・Create Custom Action “Stripe Session”
Type:Create
API Base URL: Zapier’s “Webhook URL”
・Method:POST
Inputs:Email(String), Stripe Customer ID(String)
Body{
“Email”:“Email”,
“Customer”:“Stripe Customer ID”
}
With Zapier,
・Call the Stripe API with Webhook by Zapier “POST”
URL: https://api.stripe.com/v1/billing_portal/sessions
・Payload Type:Form
・Data
Customer:“customer”(:“Stripe Customer ID”)
Return_url:"https://{your service’s URL} (Anything good)
· Headers
Authorization
Bearer
“Stripe’s API Key”
If the test is OK, you can get the URL.
· Save email address, customer ID and URL in StripeSessionURL collection with “Create Record in Adalo”
(3Zap)
With Adalo,
· “StripeSession URL Collection”
Filter: Login user’s email is the same as Name (= email address)
Sorting: Created Date-Newest to Oldest
Maximum number of items: 1
・Display CreateDate and Session URL in the list
・Click to jump to Session URL
Stripe’s customer portal opens in an external browser.
(I rely on Google Translate. I’m sorry if it’s hard to understand.)