Skip to content

The moment it happens

Deliver a Drive file when someone buys on Stripe

Each buyer gets access to the right Google Drive file seconds after paying, with an email from Drive containing the link.

Runs
The moment it happens
Apps
Google Drive, Stripe
AI
Not needed
Access
Stripe read; Drive file share

Send this to your assistant

Create a ClickRuntime automation: when a Stripe checkout completes, share the Drive file for the product they bought with the buyer's email and send them the link.

Paste it into your assistant. It tells you what it will send or change before it runs live.

First time? Adding ClickRuntime to your assistant takes about two minutes.

Why use it

Why teams use this automation

An illustrator sells printable templates and a short ebook through Stripe payment links. Every evening they check new orders and share the right file with each buyer by hand. Buyers who pay in the morning wait all day, and a few write in asking where their download is.

Sharing the file automatically the moment payment succeeds means every buyer gets their product straight away, at any hour. The seller stops spending evenings on delivery, and the 'where is my file' emails stop.

What you get out of it

  • Buyers get their file immediately

    Access is granted within seconds of payment. A fast delivery is the first impression of the product, and it reduces refund requests from impatient buyers.

  • Files are shared with the buyer only

    Each buyer is added to the file by email instead of receiving a public link. Links forwarded to friends do not open for people who did not pay.

  • The right file for each product

    Each Stripe price points to its own Drive file, so a buyer of the ebook never receives the templates by mistake. Adding a product means adding one line.

  • No evening delivery routine

    Sales made overnight or on holiday are delivered the same way as any other. The seller's time goes into making products rather than sending them.

How it works

What happens, step by step

  1. When a buyer completes a Stripe checkout, Stripe notifies ClickRuntime straight away.

  2. ClickRuntime checks the notification really came from Stripe and reads which products were bought.

  3. It looks up the Drive file you linked to each product and shares it with the buyer's email address.

  4. Google Drive emails the buyer the link to their file, and you get a short note that it was delivered.

Before it runs live

  • Connect Google Drive
  • Connect Stripe
  • Paste your automation's link into the other app's webhook settings

What you get

RunsThe moment it happens
Deliver a Drive file when someone buys on Stripejust nowSucceeded
Email · From Google DriveNorthwind Studio shared "Wedding planner templates.pdf" with you: Thanks for your purchase! Here is your download.

Build your own

Need it to work differently?

This template is a starting point. Copy the prompt and change it, or describe a different automation from scratch, with your own conditions, more apps or an AI step. Your assistant writes it, tests it and runs it on ClickRuntime.
  • 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 Drive and Stripe steps into one automation

Under the hood

The code that runs this automation

This is the Python script that runs each time the automation starts. Your AI assistant writes it for you when you send the prompt, and you allow each step in your assistant. To change how the automation works, describe the change to your assistant and it updates the script for you. For every function it can use, see the script reference.
deliver_a_drive_file_after_a_stripe_purchase.pyexample
import stripe
from clickruntime import on_event, credentials, verify, notify
from google.oauth2.credentials import Credentials
from googleapiclient.discovery import build

FILES = {"price_ebook": "1AbCdEbookFileId", "price_templates": "1XyZTemplatesFileId"}

@on_event
def handle(event):
    if not verify.stripe(event.body, event.header("Stripe-Signature"), credentials.secret("STRIPE_WEBHOOK_SECRET")):
        return {"ignored": "bad signature"}
    if event.json["type"] != "checkout.session.completed":
        return {"ignored": event.json["type"]}
    session = event.json["data"]["object"]
    email = session["customer_details"]["email"]
    stripe.api_key = credentials.secret("STRIPE_API_KEY")
    drive = build("drive", "v3", credentials=Credentials(credentials.connection("google", "work")), cache_discovery=False)
    shared = []
    for item in stripe.checkout.Session.list_line_items(session["id"]).data:
        file_id = FILES.get(item.price.id)
        if file_id:
            drive.permissions().create(fileId=file_id, sendNotificationEmail=True,
                                       emailMessage="Thanks for your purchase! Here is your download.",
                                       body={"type": "user", "role": "reader", "emailAddress": email}).execute()
            shared.append(item.description)
    notify.email_me(f"Delivered to {email}", ", ".join(shared) or "No matching file for this checkout")
    return {"shared": shared}

FAQ

Common questions

Does the buyer need a Google account?
Opening a shared Drive file works best with a Google account using the same email. If many buyers do not have one, the file can be shared with anyone who has the link instead, and the link is sent by email.
What happens if one checkout includes several products?
Every product in the checkout that has a matching file is shared, and the buyer gets one email per file.
Can I take access away after a refund?
Not automatically in this version. You can remove the buyer from the file in Drive, or ask to add a step that does this when Stripe reports a refund.
What permissions does it need?
Stripe read; Drive file share. Nothing else in your accounts is used.
Does it need AI?
No. It runs without AI, so it doesn't use your plan's AI allowance.
How many runs does it use?
One run for each event the app sends.
Can I change how it works?
Yes. Describe the change to your AI assistant, for example a different schedule, channel or filter. It updates the automation, tests it and tells you what changed.

Set up “Deliver a Drive file when someone buys on Stripe” from your assistant

Copy the prompt above, or connect your assistant first. Free plan, no credit card.