Earn blocks: "Sales disabled" notice after reconnecting to Stripe
When a user disconnects their Stripe account in wordpress.com/earn/payments, all plans are invalidated by setting a 'account_disconnected' => true flag in all of them (see A8C\Billingdaddy\Api\Connected_Accounts::disconnect_connected_account in the WP.com codebase).
That ensures that any existing Earn block (Payments, Premium Content, Donations) don't go through the checkout process if a user tries to submit a payment. Instead we display a "Sales disabled" notice:
However, if that user decides to reconnect their Stripe account, the account_disconnected flag is not removed from the plans, so all Earn blocks previously published continue displaying the "Sales disabled" notice.
This can be worked around for the Payments and Premium Content blocks, since a user can delete the old plan and create a new one that won't have the account_disconnected flag. But for the Donations block this is rather problematic, since a user cannot manage donation-type plans, so Donations blocks published after the reconnection won't work either.
cc @artpi in case he has any advice
Ok, this is weird. I cannot longer reproduce this, so I guess I was a problem on my sandbox (maybe I wasn't sandboxing everything correctly).
Reopening this since @blackjackkent started experiencing it too. To be honest, all the code I investigated seems correct, so I think the issue is only happening when there is some sandbox misconfiguration and likely is not going to affect final users.
But if we want to avoid this, one way is by completely removing the plan IDs from the Donations block attributes. Given that plans are automatically set/created without the user noticing it, we can actually do that as part or the dynamic block rendering.
That would mean that plan IDs won't be fetched as part of the block edit logic, instead we can fetch them during execution time as part of the dynamic block rendering (render callbacks are executed when visiting a post that contains the block).
Since that logic runs in the server, we should be able to check the account_disconnected flag and if for any reason the flag exists but the Stripe connection is set, we can recreate the plans with the new Stripe account, making sure that the returned plans will work in the payment dialog.
I just had a customer report this in 25987821-hc
I encountered this same error message with the Premium Content block in 25938511-hc
They mentioned it was the first time they were connecting, however previously used the same Stripe account with Medium.
Got another in 26008195-hc
Another - 26008195-hc
Observed in a case where user first registered on WooCommerce Payments (that apparently creates a Stripe Express account), and then used the same credentials for Premium content block.
3519340-zd
@mmtr Is it possible to fix this for individual customers while we're waiting for the bug itself to be fixed? I don't understand the bit about deleting the old plan. What sort of plan? How does the user do this? I asked in #payments: p1607361090429500-slack-C02BEP610
@mmtr Is it possible to fix this for individual customers while we're waiting for the bug itself to be fixed? I don't understand the bit about deleting the old plan. What sort of plan? How does the user do this? I asked in #payments: p1607361090429500-slack-C02BEP610
They have to create a new payment plan in wordpress.com/earn/payments-plans/:site(Tools > Earn > Manage payments > Collect payments > Manage plans > Payment plans): https://wordpress.com/support/wordpress-editor/blocks/payments/#managing-payment-plans
Once the plan has been created, they have to switch any existing Payments / Premium content block to the new plan by editing the posts containing such blocks: https://wordpress.com/support/wordpress-editor/blocks/payments/#payment-block-settings
Another one - 26398923-hc The user created a new plan and added it again to the payment block. But they are still seeing the same issue.
3593671-zen
Another report in 26335896-hc, suggested deleting plan and re-adding as a workaround.
Another report in 23452958-hc, the new plan workaround did not work for them.
Another report in 3698959-zd, with the Donation block
Another report for the Payments Block: 18504186-zen
Another report: 27662821-hc
Re-created the plan didn't do the trick. I'm going to do the workaround @yashitamittal11 provided on their follow-up: Creating a new Stripe account.
Another report for Payments block in 27711962-hc
Another report for Payments block in 17465695-hc I'll ask them to make a new payment option.
Another report for Payments block in 28150296-hc