Skip to content
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

Cancel Purchase: show marketplace subscriptions dialog. #65596

Merged
merged 12 commits into from
Oct 3, 2022

Conversation

cpapazoglou
Copy link
Contributor

@cpapazoglou cpapazoglou commented Jul 14, 2022

Proposed Changes

  • Displays the following Dialog in both Cancellation flow and Cancellation and refund flow

CleanShot 2022-09-30 at 17 40 24@2x

  • The Dialog is displayed when the user tries to either Remove or Cancel a Plan, and it has active Marketplace subscriptions. For example, the user has WooCommerce Bookings and a Businesss plan and tries to remove or cancel the Business plan.
  • The following is a table with three different scenarios when removing/cancelling a purchase

Note That some recent changes have changed the wordings and removed the and Refund words, comment here

Removal Flow Cancellation Flow Cancellation and Refund Flow
`CleanShot`` 2022-09-26 at 09 47 37@2x CleanShot 2022-09-26 at 09 40 49@2x CleanShot 2022-09-26 at 09 38 04@2x
  • This PR will only affect the Cancellation flow (the last two columns above), and the existing Removal flow (first column) has not been modified
  • The changes suggested are:
    • Update the logic in the cancellation flow to display the modal when cancelling a plan
    • Iterate over all the subscriptions and either cancel or cancel and refund them when required
    • Adds two new async methods that will be used in the previous log instead of using callbacks

Testing Instructions

Scenario 1: Cancel and Refund:

  • Go to https://wordpress.com/
  • Switch to a Simple site
  • Purchase a Business plan with a credit card (you can use the Sandbox store if you don't want to enter an actual credit card: PCYsg-IA-p2#sandbox)
  • Go to Plugins
  • Purchase a paid plugin with a credit card
  • Go to Upgrades > Purchases
  • Cancel and Refund the Business plan
  • Make sure a Dialog is displayed asking for confirmation. The Dialog should refer to the Cancel flow instead of Remove in the wordings.
  • Click on Continue
  • Make sure that both the plan and the subscriptions have been cancelled and refunded.

Scenario 2: Cancel:

  • Go to https://wordpress.com/
  • Switch to a Business site that was purchased with a credit card more than 14 days ago
  • Go to Plugins
  • Purchase a paid plugin with a credit card
  • Make sure the plugin has auto-renew activated -> Auto-renew is ON
  • Go to Upgrades > Purchases
  • Cancel the Business plan
  • Make sure a Dialog is displayed asking for confirmation. The Dialog should refer to the Cancel flow instead of Remove in the wordings.
  • Click on Continue
  • Make sure that the plan is cancelled and the subscription auto-renew is OFF

Scenario 3: Removal flow (this is to check there is no regression in existing functionality):

Pre-merge Checklist

Complete applicable items on this checklist before merging into trunk. Inapplicable items can be left unchecked.

Both the PR author and reviewer are responsible for ensuring the checklist is completed.

Fixes #65235

@cpapazoglou cpapazoglou self-assigned this Jul 14, 2022
@github-actions
Copy link

github-actions bot commented Jul 14, 2022

@cpapazoglou
Copy link
Contributor Author

This is still WIP, I am having a problem getting the ProductList.

@matticbot
Copy link
Contributor

matticbot commented Jul 14, 2022

Here is how your PR affects size of JS and CSS bundles shipped to the user's browser:

Sections (~1063 bytes added 📈 [gzipped])

name                    parsed_size           gzip_size
site-purchases              +3875 B  (+0.3%)     +904 B  (+0.2%)
purchases                   +3875 B  (+0.2%)     +904 B  (+0.2%)
domains                      +668 B  (+0.0%)     +161 B  (+0.0%)
settings                     +149 B  (+0.0%)      +45 B  (+0.0%)
jetpack-cloud-settings       +149 B  (+0.0%)      +57 B  (+0.0%)
email                        +149 B  (+0.0%)      +57 B  (+0.0%)

Sections contain code specific for a given set of routes. Is downloaded and parsed only when a particular route is navigated to.

Async-loaded Components (~380 bytes removed 📉 [gzipped])

name                                                    parsed_size            gzip_size
async-load-calypso-blocks-product-plan-overlap-notices      -1219 B  (-23.1%)     -380 B  (-20.0%)

React components that are loaded lazily, when a certain part of UI is displayed for the first time.

Legend

What is parsed and gzip size?

Parsed Size: Uncompressed size of the JS and CSS files. This much code needs to be parsed and stored in memory.
Gzip Size: Compressed size of the JS and CSS files. This much data needs to be downloaded over network.

Generated by performance advisor bot at iscalypsofastyet.com.

@epeicher
Copy link
Contributor

Applying this branch displays the Modal as expected
CleanShot 2022-09-21 at 18 56 25@2x
but the subscriptions are not removed.

I am going to investigate

@cpapazoglou
Copy link
Contributor Author

The intention is that marketplace subscriptions are note removed when canceling a purchase. They should remain functional until subscription expires and plan gets removed. I haven't updated the copy at all though here.

@epeicher
Copy link
Contributor

When following the Cancellation flow instead of the Removal flow (reference here), the following modal will be displayed:
CleanShot 2022-09-23 at 15 51 54@2x

@epeicher
Copy link
Contributor

Question asked in the linked task to confirm the approach before proceeding

@epeicher
Copy link
Contributor

I have uploaded some changes to handle Marketplace subscription removal and cancels. I have refactored a bit the cancel-purchase/button.jsx component to use async-await as it simplifies the code when using a collection of asynchronous tasks.

The following video has been recorded with a test done cancelling a plan that is more than 14 days old and it was paid using credit card

umCeYHmzkEJQSPP0kqUB3bxbyiBV0unOUjFmxrV2.mp4

@epeicher
Copy link
Contributor

The following video has been recorded showing the flow when the system allows Cancel and Refund:

VbeJwFGZNxCfVMqWxBa8T6G09WvQKurHFuMm60Mi.mp4

In this scenario both the Plan and the Plugins are refunded

@epeicher epeicher marked this pull request as ready for review September 26, 2022 08:08
@epeicher epeicher requested a review from a team as a code owner September 26, 2022 08:08
@matticbot matticbot added the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Sep 26, 2022
@epeicher epeicher assigned epeicher and cpapazoglou and unassigned cpapazoglou Sep 26, 2022
@cpapazoglou
Copy link
Contributor Author

The modal though still has the wrong content, it should look like this
image

When the user is allowed to Cancel and Refund (example video here):
The site plan is immediately cancelled and refunded
The plugin is immediately cancelled and refunded

The plugin should not get refunded if the refund period has passed.
Example:

  • I renew an annual plan now
  • My plugin annual subscription expires in 5 days

If I Cancel my plan:

  • plan should get refunded and removed
  • plugin should be removed - no refund for the plugin

@epeicher
Copy link
Contributor

Heads up, after the following changes https://github.com/Automattic/wp-calypso/pull/68088/files the logic of Cancel and Cancel and Refund is the same but the wording has changed.

The previous behaviour is kept using defaults when no text is passed as props
@epeicher
Copy link
Contributor

@cpapazoglou thanks for the wording suggestions. I have changed them but maybe we should update it again to cover additional scenarios.

Regarding the logic implemented, I think it is correct but the description was not accurate. Let me summarise it:

Removal flow:

This has not changed as part of this PR. When the user removes a plan, everything seems to be removed. This could be handled in a follow-up task if it is not correct.

Cancellation flow

  • User cancels a plan. Regardless of the plan being refundable or not:
  • For each subscription:
    • If the purchase is cancellabe, it will be cancelled. This means auto-renew of the plugin will change to OFF
    • If the purchase is cancellable and refundable, it will be cancelled and refunded. This means the plugin is removed immediately.

Please see this video with a scenario with:

  • A site plan that can be cancelled and refunded
  • A plugin that can be cancelled and refunded
  • A plugin that cannot be refunded

With the above logic, that means that some subscriptions could be refunded and removed immediately and some others will be just cancelled. Should we adapt the wording of the Dialog to the following more generic?

The subscriptions will be cancelled.

CleanShot 2022-09-28 at 13 27 27@2x

@cpapazoglou
Copy link
Contributor Author

User cancels a plan. Regardless of the plan being refundable or not:
For each subscription:
If the purchase is cancellabe, it will be cancelled. This means auto-renew of the plugin will change to OFF
If the purchase is cancellable and refundable, it will be cancelled and refunded. This means the plugin is removed immediately.

The plugin subscriptions should depend to the plan being refundable or not, since when the plan is refundable and gets refunded it will get removed, site will get downgraded, plugins will be unusable. In this case (copying exactly what you have suggested which is correct) :

For each subscription:

  • If the purchase is cancellabe, it will be cancelled. This means auto-renew of the plugin will change to OFF
  • If the purchase is cancellable and refundable, it will be cancelled and refunded. This means the plugin is removed immediately.

But if the plan is not refundable, it won't get removed - it might even expire after 364 days. In this case, plugins should not get refunded - removed. For each subscription we should disable auto-renew and make sure the user is aware.

Should we adapt the wording of the Dialog to the following more generic?

Yes, feel free to adapt as needed.

@epeicher
Copy link
Contributor

The plugin subscriptions should depend to the plan being refundable or not,

Ok, that makes sense. Thanks for your input! I am going to update the logic to:

Cancellation flow

User cancels a plan which is refundable:

  • For each subscription:
    • If the purchase is cancellable, it will be cancelled. This means auto-renew of the plugin will change to OFF
    • If the purchase is cancellable and refundable, it will be cancelled and refunded. This means the plugin is removed

User cancels a plan which is not refundable:

  • For each subscription:
    • If the purchase is cancellable, it will be cancelled. This means auto-renew of the plugin will change to OFF
    • If the purchase is cancellable and refundable, it will not be refunded, just cancelled. This means auto-renew of the plugin will change to OFF

Otherwise, only cancel the plugin but do not refund
@epeicher
Copy link
Contributor

epeicher commented Sep 30, 2022

The logic has been updated to reflect the latest comments. The Dialog wording has been kept generic:

CleanShot 2022-09-30 at 17 40 24@2x

@cpapazoglou
Copy link
Contributor Author

Thanks for wrangling this @epeicher!

epeicher and others added 2 commits September 30, 2022 17:29
Co-authored-by: Harris Papazoglou <hrrsppzgl@gmail.com>
Co-authored-by: Harris Papazoglou <hrrsppzgl@gmail.com>
@epeicher epeicher merged commit 219836f into trunk Oct 3, 2022
@epeicher epeicher deleted the fix/remove_marketplace_plugins_when_plan_cancels branch October 3, 2022 07:04
@github-actions github-actions bot removed the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Oct 3, 2022
@a8ci18n
Copy link

a8ci18n commented Oct 3, 2022

This Pull Request is now available for translation here: https://translate.wordpress.com/deliverables/7561230

Thank you @cpapazoglou for including a screenshot in the description! This is really helpful for our translators.

@a8ci18n
Copy link

a8ci18n commented Oct 17, 2022

Translation for this Pull Request has now been finished.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Marketplace plugins remain active after cancelling a plan
5 participants