Skip to content

fix: improve error handling for Paddle checkout and enhance loading logic#3714

Merged
Baalmart merged 5 commits into
stagingfrom
feedback-dashboard
Jul 3, 2026
Merged

fix: improve error handling for Paddle checkout and enhance loading logic#3714
Baalmart merged 5 commits into
stagingfrom
feedback-dashboard

Conversation

@OchiengPaul442

@OchiengPaul442 OchiengPaul442 commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Summary of Changes (What does this PR do?)

  • Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

Status of maturity (all need to be checked before merging):

  • I've tested this locally
  • I consider this code done

Screenshots (optional)

Summary by CodeRabbit

  • Bug Fixes
    • Improved checkout reliability by waiting for the payment overlay to finish loading before opening it.
    • Added a clearer error message when the payment provider isn’t ready, prompting users to refresh the page instead of failing immediately.

@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@OchiengPaul442, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 58 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 54f8d372-256b-43c6-90cf-6a04fbda00fb

📥 Commits

Reviewing files that changed from the base of the PR and between 307488d and 116ea55.

📒 Files selected for processing (2)
  • src/platform/src/modules/data-download/DataExportPage.tsx
  • src/platform/src/modules/location-insights/more-insights.tsx
📝 Walkthrough

Walkthrough

The handleCheckoutConfirm function in SubscriptionSection now polls for both window.Paddle.Checkout.open and window.Paddle.Initialize over a bounded 10-second window (250ms intervals) instead of performing a single immediate readiness check. If Paddle remains unavailable, it throws a new error instructing users to refresh; otherwise it proceeds to open the checkout overlay.

Changes

Paddle Checkout Readiness Wait

Layer / File(s) Summary
Bounded polling before checkout open
src/platform/src/modules/billing/components/SubscriptionSection.tsx
Replaces the immediate Paddle availability check with a polling loop (10s max, 250ms interval) verifying window.Paddle.Checkout.open and window.Paddle.Initialize, throwing a refresh-guidance error on timeout, then calling Checkout.open with the transaction ID.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Possibly related PRs

  • airqo-platform/AirQo-frontend#3527: Both PRs touch the Paddle checkout/initialization flow, with this PR waiting for window.Paddle.Initialize before calling Checkout.open, while the related PR adjusts how Environment.set is applied before paddle.Initialize.

Suggested reviewers

  • Baalmart

A loop that waits, both patient and wise,
for Paddle to blink open its eyes.
Ten seconds of polling, no need to fret,
then checkout overlays without regret. 🛒⏳

🚥 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 reflects the Paddle checkout error handling and loading/readiness changes in the PR.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feedback-dashboard

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (1)
  • JIRA integration encountered authorization issues. Please disconnect and reconnect the integration in the CodeRabbit UI.

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: 1

🤖 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 `@src/platform/src/modules/billing/components/SubscriptionSection.tsx`:
- Around line 544-557: The timeout check in SubscriptionSection should match the
polling condition exactly, since the loop waits for both
window.Paddle.Checkout.open and window.Paddle.Initialize. Update the guard after
the wait so it throws when either Checkout.open is missing or Initialize is
still not a function, using the same readiness criteria as the polling logic to
prevent opening checkout in a partially loaded state.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e23f1df6-bead-4861-b173-999dec96078a

📥 Commits

Reviewing files that changed from the base of the PR and between 6d77a48 and 204cec8.

📒 Files selected for processing (2)
  • src/platform/src/modules/billing/components/SubscriptionSection.tsx
  • src/platform/src/shared/providers/paddle-provider.tsx

Comment thread src/platform/src/modules/billing/components/SubscriptionSection.tsx Outdated
@github-actions

Copy link
Copy Markdown
Contributor

New azure analytics_platform changes available for preview here

@github-actions

Copy link
Copy Markdown
Contributor

New azure analytics_platform changes available for preview here

Copilot AI 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.

Pull request overview

This PR improves the reliability of Paddle checkout initialization by adjusting when the Paddle script initializes and by adding a client-side wait/poll before attempting to open the Paddle checkout overlay.

Changes:

  • Updates Paddle script loading/initialization behavior in the global PaddleProvider.
  • Adds a bounded poll (up to 10s) to wait for Paddle’s checkout overlay API to become available before calling Checkout.open.
  • Improves the user-facing error message when Paddle fails to load.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/platform/src/shared/providers/paddle-provider.tsx Adjusts script onLoad initialization behavior and changes when the provider renders the Paddle script.
src/platform/src/modules/billing/components/SubscriptionSection.tsx Adds polling/wait logic before opening the Paddle checkout overlay and provides a clearer failure message.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +64 to +68
<Script
id={PADDLE_SCRIPT_ID}
src={PADDLE_SCRIPT_SRC}
strategy="afterInteractive"
onLoad={initializePaddle}
onLoad={paymentClientToken ? initializePaddle : undefined}
Comment thread src/platform/src/modules/billing/components/SubscriptionSection.tsx
@github-actions

Copy link
Copy Markdown
Contributor

New azure analytics_platform changes available for preview here

@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

New azure analytics_platform changes available for preview here

1 similar comment
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

New azure analytics_platform changes available for preview here

@Baalmart
Baalmart merged commit 631464c into staging Jul 3, 2026
39 of 41 checks passed
@Baalmart
Baalmart deleted the feedback-dashboard branch July 3, 2026 20:24
@Baalmart Baalmart mentioned this pull request Jul 3, 2026
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants