{
  "schema_version": "1.0.0",
  "id": "stripe-refund-log",
  "title": "Log Stripe refunds and flag the large ones",
  "category": "finance",
  "difficulty": "beginner",
  "featured": false,
  "description": "Write every Stripe refund to a sheet with its reason, and post refunds of 200 or more to the finance channel.",
  "tags": [
    "stripe",
    "refunds",
    "google-sheets",
    "slack"
  ],
  "apps": [
    "Stripe",
    "Google Sheets",
    "Filter by Zapier",
    "Slack"
  ],
  "plan": {
    "minimum": "Professional",
    "reasons": [
      "multi-step Zap: 3 steps after the trigger",
      "Filter by Zapier"
    ]
  },
  "tasks": {
    "typical": 1,
    "max": 2
  },
  "trigger": {
    "app": "Stripe",
    "event": "New Refund",
    "kind": "instant",
    "title": "New refund",
    "why": "Fires for each refund, partial or full.",
    "config": {
      "Account": "YOUR_STRIPE_ACCOUNT"
    },
    "outputs": [
      "refund_id",
      "charge_id",
      "amount",
      "currency",
      "reason",
      "customer_email",
      "created"
    ],
    "sample": "sample-trigger.json"
  },
  "steps": [
    {
      "key": "log",
      "kind": "action",
      "app": "Google Sheets",
      "event": "Create Spreadsheet Row",
      "title": "Log the refund",
      "why": "Every refund is logged with its reason, so the monthly total has a story.",
      "fields": {
        "Drive": "My Google Drive",
        "Spreadsheet": "Finance",
        "Worksheet": "Refunds",
        "Columns": {
          "refund_id": "{{trigger.refund_id}}",
          "charge_id": "{{trigger.charge_id}}",
          "amount": "{{trigger.amount}}",
          "currency": "{{trigger.currency}}",
          "reason": "{{trigger.reason}}",
          "customer": "{{trigger.customer_email}}",
          "refunded_at": "{{trigger.created}}"
        }
      },
      "outputs": [
        "id",
        "row_number"
      ]
    },
    {
      "key": "large",
      "kind": "filter",
      "app": "Filter by Zapier",
      "event": "Only continue if...",
      "title": "Only refunds of 200 or more",
      "why": "Small refunds are logged quietly. Stripe's Zapier fields give the amount in major units here, so 199.99 is the line.",
      "conditions": [
        [
          {
            "field": "{{trigger.amount}}",
            "operator": "(Number) Greater than",
            "value": "199.99"
          }
        ]
      ],
      "usually": false
    },
    {
      "key": "flag",
      "kind": "action",
      "app": "Slack",
      "event": "Send Channel Message",
      "title": "Post it to #finance",
      "why": "Large refunds get a second pair of eyes the same day.",
      "fields": {
        "Channel": "#finance",
        "Message Text": "Refund of {{trigger.amount}} {{trigger.currency}} to {{trigger.customer_email}} (reason: {{trigger.reason}}). Charge {{trigger.charge_id}}. Logged in row {{log.row_number}}.",
        "Send as a bot?": "Yes",
        "Bot Name": "Zap alerts",
        "Include a link to this Zap?": "No"
      },
      "outputs": [
        "ts",
        "permalink"
      ]
    }
  ]
}
