The moment it happens
Log Stripe sales in a sheet and send buyers their product
Every payment becomes a row in your sales sheet, and the buyer gets the download link you keep in that sheet.
- Runs
- The moment it happens
- Apps
- Google Sheets, Stripe
- AI
- Not needed
- Access
- Stripe read; sheet editor
Send this to your assistant
Create a ClickRuntime automation: when a Stripe checkout succeeds, add a row to my sales sheet, look up the product's download link in the Products tab and email it to the buyer.
First time? Adding ClickRuntime to your assistant takes about two minutes.
Why use it
Why teams use this automation
A small digital shop sells e-books and presets through Stripe. The owner keeps a Google Sheet of sales for her accountant and a tab with each product's download link, and both get updated by hand: copy each payment into the sheet, look up the link, email the buyer. When sales spike after a newsletter, she spends the evening catching up.
This automation does both from the moment the payment clears. The sale is added to the sheet with the date, buyer, product and amount, the matching link is looked up in the Products tab and the buyer is emailed straight away. The sheet stays complete for the accountant, and changing a link is as simple as editing a cell.
What you get out of it
A complete sales record
Every payment lands in the sheet with its date, buyer, product, amount and currency.
Links managed in the sheet
Download links live in a Products tab, so updating one is a cell edit rather than a settings change.
Buyers served instantly
The product email goes out seconds after payment, at any hour.
Ready for your accountant
The sales tab is already in a format you can share or export at month end.
No double rows
A resent Stripe event is recognised, so each sale is logged and emailed once.
How it works
What happens, step by step
When a checkout is paid, Stripe tells ClickRuntime straight away, and the message is checked to be genuinely from Stripe.
It skips payments already handled, so a resent message never adds a second row.
A row with the date, buyer, product and amount is added to your sales tab.
The product's download link is looked up in your Products tab and emailed to the buyer.
Before it runs live
- Connect your Google Sheets account and pick the spreadsheets it may use
- Connect Stripe
- Paste your automation's link into the other app's webhook settings
What you get
Build your own
Need it to work differently?
Your own rules
Conditions, thresholds, filters and exceptions, written the way you'd explain them to a colleague.
Any number of apps
One automation can read from one app and update several others. Over 248 apps are ready, and anything with an API works too.
AI where it helps
Summaries, classification, extraction and drafts use ClickRuntime's built-in AI, with no extra key.
On a schedule or on each event
Runs as often as every 5 minutes, or the moment an app sends an event, and keeps track of what it already handled.
Changes you can ask for
- Act only on the items that match your own rules, and skip the rest
- Add an AI step, for example to summarize, sort or draft a reply
- Add another app, for example also send it to Slack
- Combine it with other Google Sheets and Stripe steps into one automation
Under the hood
The code that runs this automation
import base64
from email.message import EmailMessage
from google.oauth2.credentials import Credentials
from googleapiclient.discovery import build
import stripe
from clickruntime import on_event, credentials, verify, state
SHEET_ID = "your-sheet-id"
@on_event
def handle(event):
if not verify.stripe(event.body, event.header("Stripe-Signature"), credentials.secret("STRIPE_WEBHOOK_SECRET")):
return {"ignored": "bad signature"}
s = event.json["data"]["object"]
if state.get(f"done:{s['id']}"):
return {"duplicate": True}
stripe.api_key = credentials.secret("STRIPE_API_KEY")
item = stripe.checkout.Session.list_line_items(s["id"], limit=1).data[0]
email, google = s["customer_details"]["email"], Credentials(credentials.connection("google", "work"))
sheets = build("sheets", "v4", credentials=google, cache_discovery=False).spreadsheets()
sheets.values().append(spreadsheetId=SHEET_ID, range="Sales!A:F", valueInputOption="USER_ENTERED", body={"values": [[
event.received_at[:10], email, item.description, s["amount_total"] / 100, s["currency"].upper(), s["id"]]]}).execute()
products = sheets.values().get(spreadsheetId=SHEET_ID, range="Products!A:B").execute().get("values", [])
link = next((r[1] for r in products if len(r) > 1 and r[0] == item.price.product), None)
msg = EmailMessage(); msg["To"], msg["Subject"] = email, f"Your {item.description}"
msg.set_content(f"Thanks for your purchase. Download it here: {link or 'we will send it to you shortly'}")
build("gmail", "v1", credentials=google, cache_discovery=False).users().messages().send(
userId="me", body={"raw": base64.urlsafe_b64encode(msg.as_bytes()).decode()}).execute()
state.set(f"done:{s['id']}", True)
return {"logged": s["id"]}FAQ
Common questions
How should the Products tab be laid out?
Which columns are added to the sales tab?
Which address does the buyer email come from?
What permissions does it need?
Does it need AI?
How many runs does it use?
Can I change how it works?
Related
You might also like
Log every Stripe cancellation and its reason in a sheet
Each cancelled subscription is added to your churn sheet with the customer, plan, revenue lost and the reason they gave.
See how it worksLog failed Stripe payments to Google Sheets
Every failed Stripe payment is added to a Failed payments tab with the customer's email, amount, decline reason and a link to the payment.
See how it worksLog Stripe payments to Google Sheets
Every successful Stripe payment is added as a new row in a Google Sheet within seconds.
See how it worksKeep exploring
Set up “Log Stripe sales in a sheet and send buyers their product” from your assistant
Copy the prompt above, or connect your assistant first. Free plan, no credit card.