Skip to content

Add Razorpay gateway support in payment gateway#137

Merged
damianlegawiec merged 1 commit intospree:mainfrom
umeshravani:patch-1
Apr 28, 2026
Merged

Add Razorpay gateway support in payment gateway#137
damianlegawiec merged 1 commit intospree:mainfrom
umeshravani:patch-1

Conversation

@umeshravani
Copy link
Copy Markdown
Contributor

@umeshravani umeshravani commented Apr 28, 2026

Summary by CodeRabbit

  • Bug Fixes
    • Improved Razorpay payment gateway recognition: The system now properly identifies and processes Razorpay as a supported payment method, resolving a previous issue where it was treated as an unknown gateway type. This ensures more reliable transaction handling for users selecting Razorpay as their payment option.

@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Apr 28, 2026

@umeshravani is attempting to deploy a commit to the Spree Commerce Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 28, 2026

Walkthrough

A new gateway identifier mapping was added to the payment gateway registry, enabling the resolveGatewayId function to recognize "Spree::Gateway::RazorpayGateway" and return "razorpay" instead of the fallback "unknown" value.

Changes

Cohort / File(s) Summary
Gateway Identifier Mapping
src/lib/utils/payment-gateway.ts
Added mapping for Razorpay gateway type identifier in the gateway-to-SDK registry, allowing proper resolution of Razorpay payment method types.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Poem

🐰 A mapping so fine, one line with care,
Razorpay recognized, no "unknown" affair,
The gateway now knows which way to go,
From Spree to SDK, a swift little flow!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding Razorpay gateway support to the payment gateway identifier registry.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/lib/utils/payment-gateway.ts (1)

18-31: Use satisfies for the gateway map object literal.

The GATEWAY_TYPE_MAP contains only non-"unknown" gateway values; switching to satisfies Record<string, Exclude<GatewayId, "unknown">> enforces this stricter typing while allowing literal type inference. This aligns with the TypeScript guideline to use satisfies for object literals and provides better type safety.

♻️ Proposed refactor
-const GATEWAY_TYPE_MAP: Record<string, GatewayId> = {
+const GATEWAY_TYPE_MAP = {
   // Stripe (spree_stripe gem)
   "SpreeStripe::Gateway": "stripe",
   "Spree::Gateway::StripeGateway": "stripe",
   // Adyen (spree_adyen gem)
   "SpreeAdyen::Gateway": "adyen",
   "Spree::Gateway::AdyenGateway": "adyen",
   // PayPal (spree_paypal_checkout gem)
   "SpreePaypalCheckout::Gateway": "paypal",
   "Spree::Gateway::PayPalExpress": "paypal",
   // Razorpay (spree_razorpay_checkout gem)
   "SpreeRazorpayCheckout::Gateway": "razorpay",
   "Spree::Gateway::RazorpayGateway": "razorpay",
-};
+} satisfies Record<string, Exclude<GatewayId, "unknown">>;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/lib/utils/payment-gateway.ts` around lines 18 - 31, The GATEWAY_TYPE_MAP
object is currently typed as Record<string, GatewayId> but should be constrained
to exclude "unknown"; change its annotation to use TypeScript's satisfies
operator with Record<string, Exclude<GatewayId, "unknown">> so the literal keys
infer narrow gateway values while still ensuring no "unknown" can be assigned —
update the GATEWAY_TYPE_MAP declaration (symbol: GATEWAY_TYPE_MAP) to use
"satisfies Record<string, Exclude<GatewayId, 'unknown'>>" and leave the object
literal as-is to preserve inference.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/lib/utils/payment-gateway.ts`:
- Around line 18-31: The GATEWAY_TYPE_MAP object is currently typed as
Record<string, GatewayId> but should be constrained to exclude "unknown"; change
its annotation to use TypeScript's satisfies operator with Record<string,
Exclude<GatewayId, "unknown">> so the literal keys infer narrow gateway values
while still ensuring no "unknown" can be assigned — update the GATEWAY_TYPE_MAP
declaration (symbol: GATEWAY_TYPE_MAP) to use "satisfies Record<string,
Exclude<GatewayId, 'unknown'>>" and leave the object literal as-is to preserve
inference.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 0876eb58-b3f8-416d-b58b-00ebb57f4f69

📥 Commits

Reviewing files that changed from the base of the PR and between 9d7718d and 1276dd0.

📒 Files selected for processing (1)
  • src/lib/utils/payment-gateway.ts

@damianlegawiec damianlegawiec merged commit e116961 into spree:main Apr 28, 2026
4 of 5 checks passed
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