Skip to content

fix(paycraft): correct Razorpay plan billing cadence for quarter/semiannual - #107

Merged
therajanmaurya merged 2 commits into
developmentfrom
fix/razorpay-plan-cadence
Jun 23, 2026
Merged

fix(paycraft): correct Razorpay plan billing cadence for quarter/semiannual#107
therajanmaurya merged 2 commits into
developmentfrom
fix/razorpay-plan-cadence

Conversation

@therajanmaurya

@therajanmaurya therajanmaurya commented Jun 23, 2026

Copy link
Copy Markdown
Collaborator

Problem

syncProductToRazorpay mapped every non-month interval to a yearly Razorpay plan with a hardcoded multiplier of 1. Pro Quarterly and Pro Semiannual products would be created as yearly-billing plans — a revenue mismatch (customer pays the quarterly/semiannual price but is billed once a year). Razorpay plans are immutable after creation, so this had to be fixed before any provider sync.

Fix

Added razorpayPlanCadence() mapping every PayCraft billing interval to the correct Razorpay period + multiplier:

interval Razorpay plan
month monthly × 1
quarter quarterly × 1
semiannual monthly × 6 (no native half-yearly period)
year yearly × 1

Unknown intervals now throw (surfaced as a failed sync) instead of silently minting a wrong-cadence plan. Stripe path was already correct. tsc --noEmit clean.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added support for quarterly and semiannual billing intervals for subscription plans.
  • Bug Fixes

    • Fixed incorrect subscription billing calculations for non-standard payment intervals.
    • Improved error handling for unrecognized billing intervals instead of defaulting to annual billing.

@vercel

vercel Bot commented Jun 23, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
pay-craft Ready Ready Preview, Comment Jun 23, 2026 2:52pm

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jun 23, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
❌ Deployment failed
View logs
paycraft-docs 5281103 Jun 23 2026, 02:54 PM

…annual

syncProductToRazorpay mapped every non-month interval to a yearly plan
with multiplier 1, so Pro Quarterly and Pro Semiannual were created as
yearly-billing Razorpay plans — a revenue mismatch. Added razorpayPlanCadence()
mapping each interval to the correct Razorpay period + multiplier (month→monthly×1,
quarter→quarterly×1, semiannual→monthly×6, year→yearly×1); unknown intervals now
throw instead of silently minting a wrong-cadence plan. tsc --noEmit clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 23, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: bb8d2e13-1fa8-4461-a345-d294306218d5

📥 Commits

Reviewing files that changed from the base of the PR and between b2e959e and 5281103.

📒 Files selected for processing (1)
  • dashboard/lib/razorpay-product-sync.ts

📝 Walkthrough

Walkthrough

Adds a BillingInterval union type and a razorpayPlanCadence helper to dashboard/lib/razorpay-product-sync.ts. The helper maps PayCraft intervals (month, quarter, semiannual, year) to Razorpay period and numeric interval multipliers, and throws on unrecognized input. syncProductToRazorpay is updated to use this helper and accept the broader interval type.

Changes

Razorpay Billing Interval Mapping

Layer / File(s) Summary
BillingInterval type and razorpayPlanCadence helper
dashboard/lib/razorpay-product-sync.ts
Exports a BillingInterval union ("month" | "quarter" | "semiannual" | "year") and adds razorpayPlanCadence, which returns { period, interval } for each supported cadence (semiannual maps to monthly × 6) and throws for unrecognized inputs.
Integration into syncProductToRazorpay
dashboard/lib/razorpay-product-sync.ts
Widens the interval parameter type to BillingInterval | string | null and replaces the prior coarse month/year fallback with razorpayPlanCadence(interval) to set period and interval on client.plans.create.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐇 Hoppity-hop through the billing land,
Monthly, quarterly—now perfectly planned!
Semiannual gets its six-month due,
No more guessing what cadence to do.
The rabbit checks intervals, throws on the rest,
PayCraft and Razorpay, synced at their best! 🥕

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/razorpay-plan-cadence

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@therajanmaurya
therajanmaurya marked this pull request as ready for review June 23, 2026 14:57
@therajanmaurya
therajanmaurya merged commit 63e87d2 into development Jun 23, 2026
8 of 11 checks passed
@therajanmaurya
therajanmaurya deleted the fix/razorpay-plan-cadence branch June 23, 2026 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants