Donations Block: Security settings (min/max amount enforcement)#48492
Donations Block: Security settings (min/max amount enforcement)#48492angelablake wants to merge 6 commits intoupdate/donations-frequency-amount-defaultsfrom
Conversation
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 🔴 Action required: Please include detailed testing steps, explaining how to test your change, like so: 🔴 Action required: We would recommend that you add a section to the PR description to specify whether this PR includes any changes to data or privacy, like so: Follow this PR Review Process:
If you have questions about anything, reach out in #jetpack-developers for guidance! Jetpack plugin: No scheduled milestone found for this plugin. If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. |
Inspector: new collapsed Security panel with Minimum and Maximum amount fields (opt-in, no defaults). Stripe's floor for the active currency is the lower bound on the minimum field. Inline validation shows an error if maximum is set below minimum. Enforcement: PHP stamps pre-translated data-min-error / data-max-error strings and numeric data-min-amount / data-max-amount on the wrapper. view.js checks on preset tile click, custom amount input, and when a configured default amount is applied. Out-of-range keeps the donate button disabled and shows a red message above the separator; clears automatically on tab switch or when amount comes back in range. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…curity copy Show a donor-facing message when a custom amount is valid but below Stripe's minimum for the currency (e.g. entering $0.01 with no admin minimum set). PHP stamps data-stripe-min-error on the wrapper; view.js shows it in the else branch only when parsedAmount is a positive number. Also shortens the Security panel description in the inspector. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
JS: add checkAmountRange as a named export in utils.js; view.js delegates to it. New test/utils.test.js covers all range cases (below min, above max, at boundaries, no limits set) plus the existing firstShownInterval helper. PHP: extract inline security attr logic from render_block into build_security_data_attrs(). New tests in Donations_Test.php cover min/max attribute presence, formatted currency values, and that the Stripe floor message is currency-aware (USD vs GBP). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- aria-disabled + tabindex=-1 on donate buttons; early click guard stops memberships.js from opening Stripe modal for keyboard/AT users - role=alert set dynamically in showRangeError (not in static HTML) to prevent false AT announcements on page load - @SInCE $$next-version$$ added to build_security_data_attrs() - Stripe floor string uses _x() with context to avoid shared msgid with admin-min string - .donations__range-error uses gb.$alert-red token and margin-block-end for RTL correctness - PHP tests: both-limits and inverted-limits cases added Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…tripe floor - applyDefaultAmount() takes isUserInitiated flag; range error is only displayed when the donor explicitly selects an amount or switches tabs, not on the initial render - Security panel shows inline help on the maximum field when the admin sets a value below the payment processor's minimum for the chosen currency Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
CURRENCIES['GBP']['symbol'] is '£', not UTF-8 '£', so format_price returns the HTML entity in raw PHP. The browser decodes it when reading dataset.* so donors see the symbol correctly; the test must check the raw value. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
08fda75 to
02c8f8a
Compare
Summary
data-min-error/data-max-error) and numeric bounds on the wrapper — no frontend i18n wiring neededview.jsenforces the range on preset tile click, custom amount input, and when a configured default amount is applied on load or tab switch; out-of-range keeps the donate button disabled and shows a red message above the separator; clears automatically when the amount comes back in rangeTest plan
🤖 Generated with Claude Code