Skip to content

[fix] add webhook for verifyPayment failure#431

Merged
apsinghdev merged 2 commits into
mainfrom
fix/missing-usr
Jul 7, 2026
Merged

[fix] add webhook for verifyPayment failure#431
apsinghdev merged 2 commits into
mainfrom
fix/missing-usr

Conversation

@apsinghdev

@apsinghdev apsinghdev commented Jul 7, 2026

Copy link
Copy Markdown
Owner

fixes: #430

Summary by CodeRabbit

  • New Features

    • Added a “Pro Community” entry to the premium dashboard sidebar.
    • Introduced a dedicated Pro Community page where paid users can join and see connection status.
  • Bug Fixes

    • Improved payment fulfillment reliability by centralizing subscription activation.
    • Updated the payment verification message to clarify temporary ~2 minute delays.
  • Refactor

    • Streamlined payment processing and order verification, including sanitized order notes and clearer validation.
  • UX Updates

    • Removed the Discord community section from the Account page.

@vercel

vercel Bot commented Jul 7, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
opensox-website Ready Ready Preview, Comment Jul 7, 2026 11:22am

@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Payment fulfillment is centralized behind paymentService.fulfillPayment and used by webhook and verify-payment flows. The web app also removes the Discord community section from the Account page and adds a dedicated Pro Community page with sidebar navigation.

Changes

Payment Fulfillment Consolidation

Layer / File(s) Summary
fulfillPayment service method
apps/api/src/services/payment.service.ts
Adds structured payment/subscription result types, DEFAULT_PREMIUM_EMAIL_NAME, idempotent return values, and fulfillPayment with optional premium confirmation email sending.
Webhook and router integration with fulfillPayment
apps/api/src/index.ts, apps/api/src/routers/payment.ts
Webhook and verifyPayment now call paymentService.fulfillPayment; the router also adds note-sanitization constants and request schemas.
Payment verification alert message update
apps/web/src/components/payment/PaymentFlow.tsx
Adds a temporary verification-delay branch and changes the Razorpay verification-failure alert text.

Pro Community Page Migration

Layer / File(s) Summary
Discord UI removed from Account page
apps/web/src/app/(main)/dashboard/account/page.tsx
Removes Discord join state, effects, API calls, and rendered UI from the Account page.
New Pro Community page implementation
apps/web/src/app/(main)/dashboard/pro/community/page.tsx
Adds a new client page with status checks, join flow, loading states, and paid/non-paid UI branches.
Sidebar navigation entry
apps/web/src/components/dashboard/Sidebar.tsx
Adds UserGroupIcon and a new premium route for /dashboard/pro/community.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

  • apsinghdev/opensox#382: Also changes apps/web/src/components/payment/PaymentFlow.tsx and payment verification error handling.
  • apsinghdev/opensox#404: Related to the Discord endpoints consumed by the new Pro Community page.
  • apsinghdev/opensox#414: Related to apps/api/src/services/payment.service.ts subscription creation logic used by fulfillPayment.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The Discord account/community page split and sidebar route additions are unrelated to fixing payment record and email delivery. Move the Discord UI/navigation changes to a separate PR unless they are required for the payment-failure fix.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is relevant to the payment verification fix, though it undersells the broader fulfillment refactor.
Linked Issues check ✅ Passed The PR now records the payment, creates the subscription, and sends the confirmation email after successful payment, matching issue #430.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ 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/missing-usr

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

apps/web/src/app/(main)/dashboard/pro/community/page.tsx

Oops! Something went wrong! :(

ESLint: 8.57.1

TypeError: Converting circular structure to JSON
--> starting at object with constructor 'Object'
| property 'configs' -> object with constructor 'Object'
| property 'flat' -> object with constructor 'Object'
| ...
| property 'plugins' -> object with constructor 'Object'
--- property 'react' closes the circle
Referenced from: /apps/web/.eslintrc.json
at JSON.stringify ()
at /node_modules/.pnpm/@eslint+eslintrc@2.1.4/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2156:45
at Array.map ()
at ConfigValidator.formatErrors (/node_modules/.pnpm/@eslint+eslintrc@2.1.4/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2147:23)
at ConfigValidator.validateConfigSchema (/node_modules/.pnpm/@eslint+eslintrc@2.1.4/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2177:84)
at ConfigArrayFactory._normalizeConfigData (/node_modules/.pnpm/@eslint+eslintrc@2.1.4/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3019:19)
at ConfigArrayFactory._loadConfigData (/node_modules/.pnpm/@eslint+eslintrc@2.1.4/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2984:21)
at ConfigArrayFactory._loadExtendedShareableConfig (/node_modules/.pnpm/@eslint+eslintrc@2.1.4/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3285:21)
at ConfigArrayFactory._loadExtends (/node_modules/.pnpm/@eslint+eslintrc@2.1.4/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3156:25)
at ConfigArrayFactory._normalizeObjectConfigDataBody (/node_modules/.pnpm/@eslint+eslintrc@2.1.4/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3095:25)

apps/web/src/components/payment/PaymentFlow.tsx

Oops! Something went wrong! :(

ESLint: 8.57.1

TypeError: Converting circular structure to JSON
--> starting at object with constructor 'Object'
| property 'configs' -> object with constructor 'Object'
| property 'flat' -> object with constructor 'Object'
| ...
| property 'plugins' -> object with constructor 'Object'
--- property 'react' closes the circle
Referenced from: /apps/web/.eslintrc.json
at JSON.stringify ()
at /node_modules/.pnpm/@eslint+eslintrc@2.1.4/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2156:45
at Array.map ()
at ConfigValidator.formatErrors (/node_modules/.pnpm/@eslint+eslintrc@2.1.4/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2147:23)
at ConfigValidator.validateConfigSchema (/node_modules/.pnpm/@eslint+eslintrc@2.1.4/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2177:84)
at ConfigArrayFactory._normalizeConfigData (/node_modules/.pnpm/@eslint+eslintrc@2.1.4/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3019:19)
at ConfigArrayFactory._loadConfigData (/node_modules/.pnpm/@eslint+eslintrc@2.1.4/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2984:21)
at ConfigArrayFactory._loadExtendedShareableConfig (/node_modules/.pnpm/@eslint+eslintrc@2.1.4/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3285:21)
at ConfigArrayFactory._loadExtends (/node_modules/.pnpm/@eslint+eslintrc@2.1.4/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3156:25)
at ConfigArrayFactory._normalizeObjectConfigDataBody (/node_modules/.pnpm/@eslint+eslintrc@2.1.4/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3095:25)


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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🧹 Nitpick comments (1)
apps/api/src/services/payment.service.ts (1)

396-400: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚖️ Poor tradeoff

Avoid any in the return type; prefer Prisma-generated types.

payment and subscription are typed as any, which erases type safety on the payment path. Prefer the Prisma Payment/Subscription model types (or a narrowed shape). This matches the existing any pattern in createPaymentRecord/createSubscription, so tightening those together would be ideal.

As per coding guidelines: "Avoid any type; use unknown for truly dynamic data and narrow with type guards".

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/api/src/services/payment.service.ts` around lines 396 - 400, The
fulfillPayment return type currently uses any for payment and subscription,
which removes type safety; update the fulfillPayment signature to use
Prisma-generated Payment and Subscription types or a narrowed explicit shape
instead. Locate the fulfillPayment method in PaymentService and tighten its
return type, then align createPaymentRecord and createSubscription as needed so
the values they return are typed consistently without any.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/api/src/services/payment.service.ts`:
- Around line 419-423: The premium email send result is being ignored in payment
handling, so a false return from sendPremiumSubscriptionEmail is still treated
as success. Update the payment flow in payment.service.ts to use the
Promise<boolean> returned by emailService.sendPremiumSubscriptionEmail and
assign emailSent based on that boolean rather than hard-setting it to true. Keep
the logic in the same subscription-email block so soft failures are reflected
correctly in the final emailSent state.
- Around line 403-458: The confirmation email in fulfillPayment is being sent
whenever sendConfirmationEmail is true, even when createPaymentRecord and
createSubscription return existing rows for the same Razorpay payment. Update
those helpers to surface whether a payment/subscription was newly created or
already existed, then gate the sendPremiumSubscriptionEmail call in
paymentService so it only runs on the first successful fulfillment; use the
existing symbols createPaymentRecord, createSubscription, fulfillPayment, and
sendPremiumSubscriptionEmail to wire the first-time-only check.

In `@apps/web/src/app/`(main)/dashboard/pro/community/page.tsx:
- Around line 9-23: The ProCommunityPage component is reading useSearchParams()
at the top level without a Suspense ancestor, which can trigger a
static-rendering bailout. Move the search-param-dependent state initialization
into a child component that uses useSearchParams, and wrap that child in a
<Suspense> boundary from ProCommunityPage so the dashboard page can render
safely.

In `@apps/web/src/components/payment/PaymentFlow.tsx`:
- Around line 123-125: The alert in PaymentFlow is shown for both transient
delays and hard failures, which can mislead users. Update the catch path around
the payment verification flow in PaymentFlow.tsx so the “access will be
activated within 2 mins” message is only shown when the failure is a confirmed
temporary delay, and use a different handling path for genuine errors. Use the
existing payment verification logic and error handling in PaymentFlow to branch
on the failure type before calling alert.

---

Nitpick comments:
In `@apps/api/src/services/payment.service.ts`:
- Around line 396-400: The fulfillPayment return type currently uses any for
payment and subscription, which removes type safety; update the fulfillPayment
signature to use Prisma-generated Payment and Subscription types or a narrowed
explicit shape instead. Locate the fulfillPayment method in PaymentService and
tighten its return type, then align createPaymentRecord and createSubscription
as needed so the values they return are typed consistently without any.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 978b4b21-4cfa-408b-932f-c752dde950f5

📥 Commits

Reviewing files that changed from the base of the PR and between d7c00f9 and 5bbe651.

📒 Files selected for processing (7)
  • apps/api/src/index.ts
  • apps/api/src/routers/payment.ts
  • apps/api/src/services/payment.service.ts
  • apps/web/src/app/(main)/dashboard/account/page.tsx
  • apps/web/src/app/(main)/dashboard/pro/community/page.tsx
  • apps/web/src/components/dashboard/Sidebar.tsx
  • apps/web/src/components/payment/PaymentFlow.tsx

Comment thread apps/api/src/services/payment.service.ts Outdated
Comment thread apps/api/src/services/payment.service.ts Outdated
Comment thread apps/web/src/app/(main)/dashboard/pro/community/page.tsx
Comment thread apps/web/src/components/payment/PaymentFlow.tsx Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
apps/api/src/services/payment.service.ts (1)

102-110: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Replace any with concrete Prisma types.

payment and subscription here (and the fulfillPayment return type at Lines 419-420) are any, so callers lose type safety on the returned records. Since these wrap Prisma model rows, use the generated Payment/Subscription types from @prisma/client.

♻️ Proposed change
+import type { Payment, Subscription } from "`@prisma/client`";
+
 interface PaymentRecordResult {
-  payment: any;
+  payment: Payment;
   wasCreated: boolean;
 }

 interface SubscriptionResult {
-  subscription: any;
+  subscription: Subscription;
   wasCreated: boolean;
 }

As per coding guidelines: "Avoid any type; use unknown for truly dynamic data and narrow with type guards."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/api/src/services/payment.service.ts` around lines 102 - 110, The
`PaymentRecordResult` and `SubscriptionResult` interfaces currently use `any`,
which removes type safety from `payment` and `subscription` values returned by
`payment.service.ts`. Update these result types, and the `fulfillPayment` return
type that also exposes these records, to use the concrete Prisma model types
imported from `@prisma/client` (for example `Payment` and `Subscription`) so
callers get proper compile-time typing.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@apps/api/src/services/payment.service.ts`:
- Around line 102-110: The `PaymentRecordResult` and `SubscriptionResult`
interfaces currently use `any`, which removes type safety from `payment` and
`subscription` values returned by `payment.service.ts`. Update these result
types, and the `fulfillPayment` return type that also exposes these records, to
use the concrete Prisma model types imported from `@prisma/client` (for example
`Payment` and `Subscription`) so callers get proper compile-time typing.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 08cc553b-22b9-4637-aa30-f6393ac12d94

📥 Commits

Reviewing files that changed from the base of the PR and between 5bbe651 and 4ce321a.

📒 Files selected for processing (3)
  • apps/api/src/services/payment.service.ts
  • apps/web/src/app/(main)/dashboard/pro/community/page.tsx
  • apps/web/src/components/payment/PaymentFlow.tsx
🚧 Files skipped from review as they are similar to previous changes (2)
  • apps/web/src/components/payment/PaymentFlow.tsx
  • apps/web/src/app/(main)/dashboard/pro/community/page.tsx

@apsinghdev
apsinghdev merged commit c5d8593 into main Jul 7, 2026
3 checks passed
@apsinghdev
apsinghdev deleted the fix/missing-usr branch July 7, 2026 11:34
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.

[bug] pro user pays but not getting added to the db

1 participant