Skip to content

The moment it happens

Log Shopify refunds to Google Sheets

Each Shopify refund is added to a Refunds tab with the order number, refunded items, amount and note as soon as it is issued.

Runs
The moment it happens
Apps
Google Sheets, Shopify
AI
Not needed
Access
read_orders; Google Sheets read+write

Send this to your assistant

Create a ClickRuntime automation: when a refund is issued in Shopify, add a row to the Refunds tab of my sheet with the date, order number, refunded items and quantities, amount refunded, whether items were restocked and the refund note.

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

Refunds hit the margin directly, but in Shopify they are spread across individual orders. Answering "how much did we refund last month, and for which products?" means opening orders one at a time or building a report.

This automation writes every refund to a sheet the moment it is issued, with the order number, the items and quantities, the amount, whether stock went back, and the staff note.

Store owners, customer service leads and bookkeepers use the tab to spot problem products and to book refunds correctly.

What you get out of it

  • Problem products show up

    Count refunds by item to see which products come back most.

  • Monthly refund totals

    Sum the amount column per month for the books.

  • Restock decisions recorded

    See which refunds returned items to stock and which were write-offs.

  • Staff notes kept

    The refund note explains why money went back, without opening the order.

  • Verified source

    Only webhooks signed by your store are accepted.

How it works

What happens, step by step

  1. You add a ClickRuntime trigger link as a Shopify webhook for refunds.

  2. When a refund is issued, Shopify sends it and ClickRuntime checks it really came from your store.

  3. ClickRuntime reads the refunded items, amount, restock choice and note, and looks up the order number.

  4. A row is added to your Refunds tab.

Before it runs live

  • Connect your Google Sheets account and pick the spreadsheets it may use
  • Connect Shopify
  • Paste your automation's link into the other app's webhook settings

What you get

RunsThe moment it happens
Log Shopify refunds to Google Sheetsjust nowSucceeded
Google Sheets · Store › Refunds2026-11-10 | #1842 | Linen apron × 1, Oak board × 2 | 89.00 EUR | restocked | Customer received damaged board

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 Sheets and Shopify 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.
log_shopify_refunds_to_google_sheets.pyexample
from google.oauth2.credentials import Credentials
from googleapiclient.discovery import build
import base64, hashlib, hmac
from clickruntime import on_event, credentials, http, state

STORE = "your-store.myshopify.com"
SHEET_ID = "your-spreadsheet-id"

def gql(query, variables=None):
    resp = http.post(f"https://{STORE}/admin/api/2025-07/graphql.json", json={"query": query, "variables": variables or {}},
                     headers={"X-Shopify-Access-Token": credentials.connection("shopify", "store")})
    resp.raise_for_status()
    return resp.json()["data"]

@on_event
def handle(event):
    digest = base64.b64encode(hmac.new(credentials.secret("SHOPIFY_WEBHOOK_SECRET").encode(), event.body, hashlib.sha256).digest()).decode()
    if not hmac.compare_digest(digest, event.header("X-Shopify-Hmac-Sha256") or ""):
        return {"ignored": "bad signature"}
    r = event.json
    if state.get(f"refund:{r['id']}"):
        return {"duplicate": True}
    order = gql("query($id: ID!) { order(id: $id) { name } }", {"id": f"gid://shopify/Order/{r['order_id']}"})["order"]
    items = ", ".join(f"{li['line_item']['title']} × {li['quantity']}" for li in r.get("refund_line_items", []))
    paid = [t for t in r.get("transactions", []) if t.get("kind") == "refund" and t.get("status") == "success"]
    amount = sum(float(t["amount"]) for t in paid)
    currency = paid[0]["currency"] if paid else ""
    restocked = "restocked" if any(li.get("restock_type") in ("return", "cancel") for li in r.get("refund_line_items", [])) else "not restocked"
    row = [r["created_at"][:10], order["name"], items or "(amount only)", amount, currency, restocked, r.get("note") or ""]
    build("sheets", "v4", credentials=Credentials(credentials.connection("google", "work")), cache_discovery=False) \
        .spreadsheets().values().append(spreadsheetId=SHEET_ID, range="Refunds!A:G", valueInputOption="USER_ENTERED",
                                        body={"values": [row]}).execute()
    state.set(f"refund:{r['id']}", True)
    return {"logged": order["name"]}

FAQ

Common questions

How do I connect the Shopify webhook?
Your assistant can register the refunds/create webhook through your custom app, pointing at the ClickRuntime trigger link, and store the app's signing secret in the ClickRuntime dashboard.
What about refunds of shipping only?
They have no refunded items, so the items column says amount only while the amount is still recorded.
Can it also note the refund reason?
Shopify stores the reason in the refund note. Ask staff to fill the note in, or add a dropdown column in the sheet for reasons you track.
What permissions does it need?
read_orders; Google Sheets read+write. 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 “Log Shopify refunds to Google Sheets” from your assistant

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