Skip to content

fix(stripe): skip card validation for free trials - #1676

Merged
superdav42 merged 2 commits into
mainfrom
feature/auto-20260727-110026
Jul 28, 2026
Merged

fix(stripe): skip card validation for free trials#1676
superdav42 merged 2 commits into
mainfrom
feature/auto-20260727-110026

Conversation

@superdav42

@superdav42 superdav42 commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Follow-up to fix(settings): preserve legacy false toggle values #1674 for the remaining frontend checkout path.
  • Skip Stripe Payment Element validation and setup when the checkout order says payment collection is not required.
  • Reset any mounted Stripe Elements when switching away from a payment-collecting Stripe state.

Verification

  • ./node_modules/.bin/eslint assets/js/gateways/stripe.js
  • git diff --check
  • Local browser checkout with a recurring free-trial product, allow_trial_without_payment_method stored as legacy false, and Stripe active reached the thank-you page without a card validation error.

Notes

The PR build workflow runs npm run build, so the customer nightly.link ZIP generated from this PR should include regenerated minified assets for this Stripe JS change.


aidevops.sh v3.32.188 plugin for OpenCode v1.18.5 with gpt-5.5

Summary by CodeRabbit

  • Bug Fixes
    • Improved Stripe payment handling during checkout, including correct teardown of the Payment Element.
    • Prevented requesting new payment details when payment collection isn’t required or when a previously saved method is being used.
    • Ensured Stripe payment fields are cleared appropriately when switching payment methods.
    • Improved checkout submission flow by avoiding blocked or incomplete submissions when Stripe details aren’t needed.

@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: cafd49d7-530b-4ae4-847c-45041912b1ae

📥 Commits

Reviewing files that changed from the base of the PR and between cf96291 and c7d48cd.

📒 Files selected for processing (1)
  • assets/js/gateways/stripe.js
🚧 Files skipped from review as they are similar to previous changes (1)
  • assets/js/gateways/stripe.js

📝 Walkthrough

Walkthrough

Stripe checkout now centralizes payment-collection decisions, conditionally confirms new or saved payment methods, resets Payment Element state, and unblocks submission when payment collection is disabled.

Changes

Stripe payment flow

Layer / File(s) Summary
Payment gating and element cleanup
assets/js/gateways/stripe.js
Adds centralized predicates for new and saved payment methods, refactors intent confirmation, and resets Stripe Element state when no client secret or collection is required.
Checkout hook integration
assets/js/gateways/stripe.js
Uses the shared collection predicate across submission validation and form updates, conditionally confirms saved methods, and resets elements when switching away from Stripe.

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

Sequence Diagram(s)

sequenceDiagram
  participant CheckoutForm
  participant StripeGateway
  participant StripeAPI
  CheckoutForm->>StripeGateway: submit checkout form
  StripeGateway->>StripeGateway: evaluate shouldCollectStripePayment
  alt collect new payment details
    StripeGateway->>StripeAPI: confirmStripeIntent with elements
  else use saved payment method
    StripeGateway->>StripeAPI: confirmStripeIntent without elements
  else no Stripe collection
    StripeGateway->>StripeGateway: resetStripeElements and unblock submission
  end
Loading
🚥 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 matches the main change: skipping Stripe card validation for free-trial checkouts.
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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/auto-20260727-110026

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.

@superdav42 superdav42 added origin:interactive Created by interactive user session status:in-review PR open, awaiting review/merge type:bug labels Jul 27, 2026
@github-actions

Copy link
Copy Markdown

🔨 Build Complete - Ready for Testing!

📦 Download Build Artifact (Recommended)

Download the zip build, upload to WordPress and test:

🌐 Test in WordPress Playground (Very Experimental)

Click the link below to instantly test this PR in your browser - no installation needed!
Playground support for multisite is very limitied, hopefully it will get better in the future.

🚀 Launch in Playground

Login credentials: admin / password

@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 `@assets/js/gateways/stripe.js`:
- Around line 177-179: Use shouldCollectStripePayment() consistently in the
Stripe form-update and success handlers instead of checking only
form.order.should_collect_payment. In the saved-method case, route confirmation
through its dedicated flow; when the shared predicate is false, clear submission
prevention and call resetStripeElements().
🪄 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 Plus

Run ID: 8e170abc-4a3f-436e-9769-9c698102c64c

📥 Commits

Reviewing files that changed from the base of the PR and between 1238102 and cf96291.

📒 Files selected for processing (1)
  • assets/js/gateways/stripe.js

Comment thread assets/js/gateways/stripe.js Outdated
@github-actions

Copy link
Copy Markdown

🔨 Build Complete - Ready for Testing!

📦 Download Build Artifact (Recommended)

Download the zip build, upload to WordPress and test:

🌐 Test in WordPress Playground (Very Experimental)

Click the link below to instantly test this PR in your browser - no installation needed!
Playground support for multisite is very limitied, hopefully it will get better in the future.

🚀 Launch in Playground

Login credentials: admin / password

@superdav42
superdav42 merged commit 2febb44 into main Jul 28, 2026
16 of 17 checks passed
@superdav42 superdav42 added the review-feedback-scanned Merged PR already scanned for quality feedback label Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

origin:interactive Created by interactive user session review-feedback-scanned Merged PR already scanned for quality feedback status:in-review PR open, awaiting review/merge type:bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant