Razorpay + Stripe vs. Forecast Variance: Daily P&L Snapshot with Claude Narrative to Slack via Pipedream

Pull live revenue from Razorpay and Stripe, check it against your forecast, and get a Claude-written P&L brief in Slack every morning before standup — automatically.

The flow
Razorpay logo
Source
Razorpay
Stripe logo
Process
Stripe
Pipedream logo
Process
Pipedream
Claude logo
Process
Claude
Slack logo
Destination
Slack

The stack in the order it runs — data flows from the source through to where it lands.

Why this stack

Most early-stage teams have Stripe in one tab, Razorpay in another, and a forecast in a Google Sheet nobody touches. By the time someone notices a 20% shortfall, it's Friday. You need one number, delivered before the team starts the day.

Pipedream is the right orchestration layer. It handles multi-step serverless flows with native Razorpay and Stripe SDK support, lets you write real JavaScript for the variance math, and has a free tier that's sufficient for daily runs. Make or Zapier would require more workarounds for dual-gateway aggregation and the Claude summarization step.

Claude (via Anthropic API) does exactly one job here: it takes a JSON blob of numbers and writes a two-sentence narrative a non-finance founder can read in Slack without opening a spreadsheet. Do not use it for the math. Do the math in Node first, then pass the result to Claude.

One honest tradeoff: Pipedream workflows are code-first. If you're not comfortable reading JavaScript, use Make instead and replace the Claude step with a static Slack message template — you lose the narrative, but the numbers still land. Also, do not use this playbook if your Razorpay settlements have multi-day lag (common on Indian payment routes for UPI) and you're comparing against accrual-based forecasts. You will get false variance alerts. Fix the settlement timing mismatch first.

The stack (5)

  1. Razorpay logo

    Payments + payouts built for India.

    Webhooks and the reports API make revenue an automatable signal, not a dashboard you check.

  2. Stripe logo

    Global payments with first-class APIs.

    Events + Sigma let you wire billing into any ops report or alert.

  3. Pipedream logo

    Code-level workflows with hosted triggers.

    Drop into Node/Python mid-flow when no-code hits a wall.

  4. Claude logo

    Long-context reasoning model from Anthropic — my daily driver for nuanced writing and orchestration.

    Better tone-matching and longer working memory than GPT for the tasks I care about most: guest messages, drafts, code review.

  5. Slack logo

    Team chat where most ops alerts and reports land.

    The default place a small team already lives — pipe reports here instead of email nobody opens.

How it runs

  1. 1

    Set up Pipedream scheduled trigger

    Create a new Pipedream workflow. Set the trigger to Schedule → Cron expression `0 8 * * *` (8 AM daily — adjust the timezone in Pipedream's trigger settings). This is the heartbeat for everything downstream. Name the workflow `daily-pl-snapshot` so it's findable.

  2. 2

    Fetch yesterday's Stripe charges

    Add a Node.js code step. Use the Stripe SDK: `const stripe = require('stripe')(process.env.STRIPE_SECRET_KEY)`. Call `stripe.charges.list({ created: { gte: startOfYesterday, lte: endOfYesterday }, limit: 100 })`. Paginate with `auto_paging_each` if you process more than 100 transactions per day. Sum `amount` fields — Stripe returns pence/cents, so divide by 100. Store the result as `stripeGrossUSD`.

  3. 3

    Fetch yesterday's Razorpay payments

    Add a second Node.js step. Use axios to call `GET https://api.razorpay.com/v1/payments?from=<unix_start>&to=<unix_end>&count=100` with Basic Auth (Key ID + Key Secret from env vars). Filter for `status === 'captured'` only — do not count `authorized` payments as revenue. Sum `amount` (Razorpay returns paise — divide by 100 for INR). Convert INR to USD using a hardcoded daily rate you update weekly, or call an FX API like exchangerate.host. Store as `razorpayGrossUSD`.

  4. 4

    Pull forecast target from Google Sheets

    Add a Google Sheets step using Pipedream's native action. Read a single cell from your forecast sheet — a tab called `Forecast` with column A as date and column B as daily target USD. Use the Sheets API `spreadsheets.values.get` on range `Forecast!B:B` and match today's date. If you don't have a forecast sheet yet, create one now with 30 rows of daily targets. This is the forcing function to have a real forecast. Store as `forecastTargetUSD`.

  5. 5

    Calculate variance and build the JSON payload

    In a Node.js step, compute: `totalActual = stripeGrossUSD + razorpayGrossUSD`, `variance = totalActual - forecastTargetUSD`, `variancePct = (variance / forecastTargetUSD * 100).toFixed(1)`. Build a structured object with all six numbers. Flag `isAlert = Math.abs(variancePct) > 15` — this threshold drives the Slack message color (red vs green). 15% is a reasonable starting point; adjust after two weeks of baseline data.

  6. 6

    Generate Claude narrative

    Add an HTTP step calling `POST https://api.anthropic.com/v1/messages` with your Anthropic API key. Pass the JSON payload in the user message with a system prompt: `You are a terse CFO assistant. Write exactly 2 sentences summarizing the day's revenue performance vs forecast. Use the numbers provided. No fluff, no caveats.` Use `claude-3-5-haiku` — it's fast and cheap for this use case (~$0.001 per call). Extract `content[0].text` as `claudeNarrative`.

  7. 7

    Post to Slack with conditional formatting

    Add a Slack step using the `chat.postMessage` API. Set `channel` to `#daily-ops`. Build a Block Kit message: a header block with the date, a section with `Total: $X | Stripe: $X | Razorpay: $X | Forecast: $X | Variance: X%`, and a context block with `claudeNarrative`. Set the attachment `color` field to `#36a64f` (green) if `variancePct` is within ±15%, or `#ff0000` (red) if outside. Scannable from the channel list in 2 seconds.

  8. 8

    Log the run to Google Sheets for trend tracking

    Add a final Google Sheets append step. Write a row to a `RunLog` tab: date, stripeGrossUSD, razorpayGrossUSD, totalActual, forecastTargetUSD, variancePct, claudeNarrative. After 30 days you have enough data to auto-generate a weekly trend chart in Looker Studio without any additional plumbing. Do not skip this step — it's what turns a one-time alert into a business record.

Want me to build this for you instead?

Product Audit and CTO Mode run out of this same thinking. If you’re reading this thinking “I want this, but in my product” — let’s talk.

See services

More like this