The moment it happens
Save a PDF receipt to S3 for each payment and email the link
When a payment succeeds, a PDF receipt is created, stored in your S3 bucket, and the customer gets an email from your Gmail with a private download link.
- Runs
- The moment it happens
- Apps
- AWS, Gmail
- AI
- Not needed
- Access
- s3:PutObject/GetObject; Gmail send
Send this to your assistant
Create a ClickRuntime automation: when Stripe sends a successful payment to this link, generate a PDF receipt, upload it to S3, and email the customer a 7-day download link from Gmail.
First time? Adding ClickRuntime to your assistant takes about two minutes.
Why use it
Why teams use this automation
A business taking payments wants every receipt stored somewhere it controls, for accounting and for customers who ask for a copy months later. The payment provider's own receipts are fine until you need them in bulk, or for a customer who lost the email.
Generating a receipt, keeping it in S3 and emailing the customer a private link means every payment has a stored document and the customer has their copy straight away.
What you get out of it
Every receipt kept
A PDF for each payment sits in your bucket, ready for your accountant or an audit.
Customers get their copy at once
The email arrives seconds after payment, from your own address.
Private by default
Links expire after seven days, and the file stays private in S3.
Easy re-sends
When a customer asks for a copy later, it's already stored under their payment.
How it works
What happens, step by step
Stripe sends each successful payment to your automation's link.
ClickRuntime builds a simple PDF receipt with the customer, amount, date and reference.
It saves the PDF to your S3 bucket under the payment reference.
It emails the customer a 7-day download link from your Gmail address.
Before it runs live
- Connect AWS
- Connect Google through your own Google app (a one-time, 10-minute setup), so it works with your own Gmail
- 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 AWS and Gmail steps into one automation
Under the hood
The code that runs this automation
import base64, boto3
from datetime import datetime, timezone
from email.message import EmailMessage
from google.oauth2.credentials import Credentials
from googleapiclient.discovery import build
from clickruntime import on_event, credentials, http
REGION, BUCKET = "us-east-1", "northwind-files"
def aws(service):
return boto3.client(service, region_name=REGION, aws_access_key_id=credentials.secret("AWS_ACCESS_KEY_ID"),
aws_secret_access_key=credentials.secret("AWS_SECRET_ACCESS_KEY"))
def pdf(lines):
text = " ".join(f"BT /F1 12 Tf 72 {720 - 20 * i} Td ({l.replace('(', '[').replace(')', ']')}) Tj ET" for i, l in enumerate(lines))
objs = ["<</Type/Catalog/Pages 2 0 R>>", "<</Type/Pages/Kids[3 0 R]/Count 1>>", "<</Type/Page/Parent 2 0 R/MediaBox[0 0 612 792]/Contents 4 0 R/Resources<</Font<</F1 5 0 R>>>>>>",
f"<</Length {len(text)}>>stream\n{text}\nendstream", "<</Type/Font/Subtype/Type1/BaseFont/Helvetica>>"]
return ("%PDF-1.4\n" + "".join(f"{i} 0 obj{o}endobj\n" for i, o in enumerate(objs, 1)) + "trailer<</Root 1 0 R>>\n%%EOF").encode()
@on_event
def handle(event):
pi = event.json["data"]["object"]
email = pi.get("receipt_email") or pi["metadata"].get("email")
when = datetime.fromtimestamp(pi["created"], timezone.utc).date()
key = f"receipts/{when}/{pi['id']}.pdf"
s3 = aws("s3")
s3.put_object(Bucket=BUCKET, Key=key, ContentType="application/pdf", Body=pdf(["Northwind Ltd - Receipt", f"Date: {when}", f"Reference: {pi['id']}",
f"Amount: {pi['amount_received'] / 100:,.2f} {pi['currency'].upper()}", f"Customer: {email}"]))
link = s3.generate_presigned_url("get_object", Params={"Bucket": BUCKET, "Key": key}, ExpiresIn=7 * 24 * 3600)
msg = EmailMessage()
msg["To"], msg["Subject"] = email, "Your receipt from Northwind"
msg.set_content(f"Thanks for your payment of {pi['amount_received'] / 100:,.2f} {pi['currency'].upper()}.\n\nDownload your receipt (link valid 7 days):\n{link}")
build("gmail", "v1", credentials=Credentials(credentials.connection("google", "work")), cache_discovery=False).users().messages().send(userId="me", body={"raw": base64.urlsafe_b64encode(msg.as_bytes()).decode()}).execute()
return {"key": key}FAQ
Common questions
What's on the receipt?
What does the Stripe webhook need?
Can it attach the PDF instead of a link?
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
Back up attachments from chosen senders to S3
Attachments from the senders you list are saved to your S3 bucket by date and sender, and you get an email summary of what each one contains.
See how it worksPost new orders and sign-ups to Slack
When something happens in your shop, app or form, the details land in the right channel straight away.
See how it worksBook appointments only when you're free
Booking requests are accepted only for free slots within your hours, and land on your calendar with the attendee.
See how it worksKeep exploring
Set up “Save a PDF receipt to S3 for each payment and email the link” from your assistant
Copy the prompt above, or connect your assistant first. Free plan, no credit card.