Skip to content

fix(paycraft): Razorpay INR-currency resilience + correct quarterly period - #111

Merged
therajanmaurya merged 1 commit into
developmentfrom
fix/razorpay-inr-currency
Jun 23, 2026
Merged

fix(paycraft): Razorpay INR-currency resilience + correct quarterly period#111
therajanmaurya merged 1 commit into
developmentfrom
fix/razorpay-inr-currency

Conversation

@therajanmaurya

@therajanmaurya therajanmaurya commented Jun 23, 2026

Copy link
Copy Markdown
Collaborator

Resolves the 4/4 Razorpay sync failures surfaced after the error-surfacing fix:

  • Invalid argument for period passed (Pro Quarterly): Razorpay's Plan period enum is only daily|weekly|monthly|yearly — no quarterly. quarter now maps to monthly × 3 (semiannual already monthly × 6).
  • Currency provided is not supported (USD): Razorpay is INR-first. syncProductToRazorpay now skips unsupported currencies per-item and continues (so INR plans sync while USD is skipped), and returns a clear 'add an INR price / enable International' message when every currency is skipped. Non-currency errors still propagate.

Model: Stripe = USD (global), Razorpay = INR (India). Stripe path unchanged. tsc --noEmit clean.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Improved handling when payment provider encounters unsupported currencies; sync now gracefully skips these currencies instead of failing completely.
    • Added validation and enhanced error messaging when no currencies successfully sync during product synchronization.

…eriod

Two fixes for the failing 'Sync products to providers' on Razorpay:

1. Period: Razorpay's Plan period enum is daily|weekly|monthly|yearly — there is
   no 'quarterly'. quarter now maps to monthly x3 (semiannual already monthly x6).
   Fixes 'Invalid argument for period passed' on Pro Quarterly.

2. Currency: Razorpay rejects currencies the account isn't enabled for (USD on an
   INR-only account → 'Currency provided is not supported'). syncProductToRazorpay
   now skips unsupported currencies per-item and continues, so INR plans still
   sync while USD is skipped; any non-currency error still propagates. When every
   currency is skipped, razorpaySyncProduct returns a clear 'add an INR price (or
   enable International)' message instead of a silent fail.

Stripe (USD, global) is unchanged. tsc --noEmit clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@therajanmaurya
therajanmaurya merged commit 03ffaff into development Jun 23, 2026
1 of 3 checks passed
@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 Building Building Preview, Comment Jun 23, 2026 4:25pm

@therajanmaurya
therajanmaurya deleted the fix/razorpay-inr-currency branch June 23, 2026 16:25
@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: bbc5901d-e5c4-42b2-a847-26dacd520a8e

📥 Commits

Reviewing files that changed from the base of the PR and between d8f013e and 04388f2.

📒 Files selected for processing (2)
  • dashboard/lib/razorpay-product-sync.ts
  • dashboard/lib/stripe-route-helper.ts

📝 Walkthrough

Walkthrough

RazorpaySyncResult gains a skippedCurrencies field. razorpayPlanCadence drops the "quarterly" Razorpay period, expressing quarterly and semiannual intervals as monthly with multipliers. syncProductToRazorpay catches unsupported-currency errors per currency and records them, rethrowing all others. razorpaySyncProduct in the route helper returns ok: false when nothing was created but currencies were skipped.

Changes

Razorpay Unsupported Currency Handling

Layer / File(s) Summary
SyncResult contract and cadence mapping
dashboard/lib/razorpay-product-sync.ts
RazorpaySyncResult adds skippedCurrencies: string[]; razorpayPlanCadence removes "quarterly" from its return type and maps quarterly/semiannual to monthly with multipliers of 3 and 6 respectively.
Per-currency error handling in syncProductToRazorpay
dashboard/lib/razorpay-product-sync.ts
Adds isUnsupportedCurrencyError predicate; wraps per-currency creation in try/catch to accumulate skipped currency codes and rethrow unrelated errors; success return includes skippedCurrencies.
Nothing-landed gate in razorpaySyncProduct
dashboard/lib/stripe-route-helper.ts
Post-RPC check counts created plan IDs and payment links; returns ok: false with a targeted guidance message when the count is zero and skippedCurrencies is non-empty, replacing the unconditional ok: true.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • MobileByteLabs/PayCraft#107: Directly modifies the same razorpayPlanCadence mapping for quarterly/semiannual intervals and syncProductToRazorpay plan creation logic in the same file.

Poem

🐇 A currency bounced? No panic today,
I skip it with grace and continue my way.
skippedCurrencies logged, the quarterly's gone,
Monthly with multipliers — the billing rolls on!
When nothing lands, I say so and explain,
No silent ok: true — I hop through the pain. 🌟

✨ 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-inr-currency

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.

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