-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Disable WooPay for suspended and rejected accounts - Take 2 #8942
Disable WooPay for suspended and rejected accounts - Take 2 #8942
Conversation
Test the buildOption 1. Jetpack Beta
Option 2. Jurassic Ninja - available for logged-in A12s🚀 Launch a JN site with this branch 🚀 ℹ️ Install this Tampermonkey script to get more options. Build info:
Note: the build is updated when a new commit is pushed to this PR. |
Size Change: 0 B Total Size: 1.25 MB ℹ️ View Unchanged
|
Also removes active webhooks if the account is suspended or rejected
account is restriced
Fixes a fatal error when clearing the account data cache. In this PR we call `WC_Payments::get_account_service()->is_account_rejected()` to know if the account is rejected. This method will get the data from Stripe and the `WC_Payments_Account->get_cached_account_data()` will be called. Then the action `woocommerce_payments_account_refreshed` will be fired. The `Compatibility_Service` class is registering a hook for that action. https://github.com/Automattic/woocommerce-payments/blob/trunk/includes/class-compatibility-service.php#L41 Then `Compatibility_Service->get_compatibility_data()` is called. Which calls the `get_permalink()` function. This function internally calls to `_get_page_link` which uses `$wp_rewrite` global but at the time it’s not defined resulting in a PHP fatal error. This commit fixes it. Note that the request to the server is not done on every page refresh, only after clearing the account cache contents.
…er_review` We are already checking if the account is rejected or under review in the `WC_Payments_Features::is_woopay_eligible()` method.
Fixes a fatal PHP error that happens when the account cache is expired. Check #8942 for more details.
f8c9c4b
to
270d47c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fix tests well, but I was able to reproduce the error only when moving self::maybe_register_woopay_hooks()
and self::maybe_display_express_checkout_buttons()
out of setup_theme
, but not the last 2 methods.
Also, please check my comment about WooPay_Order_Status_Sync::remove_webhook();
before merging.
Closes https://github.com/Automattic/woopay/issues/2641
Original PR (#8857) introduced some fatal PHP errors that others also saw it (p1717672645619179-slack-CGGCLBN58).
I decided to revert the PR in #8912 to find and fix the error.
Changes in this PR are the same as #8857 except for the last commit which contains the fix to the fatal errors.
Given that the changes were already reviewed in #8857 I'll focus on explaining the fix.
woocommerce_payments_account_refreshed
is fired (ref)Compatibility_Service
class already registered a callback for that hook. (ref)update_compatibility_data()
method call,get_permalink()
will be called. (ref)get_permalink()
callsget_page_link()
which calls_get_page_link()
which uses the$wp_rewrite
global variable (ref).plugins_loaded
action there's no$wp_rewrite
global defined. Sinceplugins_loaded
is fired before$wp_rewrite
is defined. That explains the error:setup_theme
.Testing instructions
setup_theme
hook each individual line and refreshing the page after 10 seconds. You should see a different fatal error for each line.self::maybe_register_woopay_hooks();
self::maybe_display_express_checkout_buttons();
self::maybe_init_woopay_direct_checkout();
self::maybe_enqueue_woopay_common_config_script( WC_Payments_Features::is_woopay_direct_checkout_enabled() );
<-- hereWC_Payments_Features::is_woopay_direct_checkout_enabled()
is what triggers the error.npm run changelog
to add a changelog file, choosepatch
to leave it empty if the change is not significant. You can add multiple changelog files in one PR by running this command a few times.Post merge