Automattic / jetpack

Security, performance, marketing, and design tools — Jetpack is made by WordPress experts to make WP sites safer and faster, and help you grow your traffic.
https://jetpack.com/
Other
1.58k stars 799 forks source link

My Jetpack: Siteless checkout breaks plugin activation flows that rely on post checkout URLs from product data #38896

Open nateweller opened 4 weeks ago

nateweller commented 4 weeks ago

Impacted plugin

Protect

Quick summary

When activating Jetpack Protect via My Jetpack, the use of connectAfterCheckout: true in useProductCheckoutWorkflow() causes the provided redirectUrl to be ignored by the Calypso.

Steps to reproduce

  1. Start with a fresh disconnected Jetpack install, running this branch if not merged yet: https://github.com/Automattic/jetpack/pull/38704
  2. Navigate to My Jetpack and click the "Activate" button on the Protect card.
  3. Purchase the paid plan and run through the checkout process.

A clear and concise description of what you expected to happen.

User should be redirected to the Jetpack Protect dashboard after purchasing the plan.

What actually happened

User is shown a thank you message, and presented with a button linking to the Scan section of Jetpack Cloud.

Impact

Some (< 50%)

Available workarounds?

No but the platform is still usable

If the above answer is "Yes...", outline the workaround.

No response

Platform (Simple and/or Atomic)

No response

Logs or notes

bizanimesh commented 4 weeks ago

👋 Hey @nateweller - I was triaging and trying to reproduce this issue. After purchasing, I'm getting redirected to the Protect dashboard. I used the same branch, as it was not merged when I was testing. Am I missing any steps? You may check here:

https://github.com/user-attachments/assets/d5cf0db1-f6b9-4126-ad55-3ac78f5ce8dd

vykes-mac commented 3 weeks ago

@bizanimesh I was able to reproduce this way:

https://github.com/user-attachments/assets/8b8c2c56-bee6-4684-b7a6-fc41d781f23a

@nateweller Can you confirm this is the issue you're referring to?

nateweller commented 3 weeks ago

@vykes-mac I believe that is the same issue I'm referring to! Apologies for the delay in response. This seems to only happen when the site is in a disconnected state prior to starting the checkout process. I'm just checking now to see if there is a difference in behaviour between a disconnected site, and a site-only connected site.

nateweller commented 3 weeks ago

To confirm, the issue is present if you attempt to purchase a plan via /wp-admin/admin.php?page=my-jetpack#/add-protect with either a disconnected or site-only connected state.

If the user already has a site connection, the redirect works as expected :+1:

vykes-mac commented 3 weeks ago

It seems showing the authorization modal after the checkout breaks the redirection.

vykes-mac commented 3 weeks ago

I updated the siteless checkout logic in Calypso to redirect to the jetpack protect page however the license is not activated as seen here.

Image

The license is auto activated in the Thank you page.

Image

What would be the best option here? to redirect and allow user to manually activate the license or to modify the Thank You page so that the Go to dashboard page goes back to the provided redirect_to uri? Or was going to Jetpack Cloud deliberate in the first place?

@nateweller @bizanimesh @Automattic/jetpack-martech

nateweller commented 2 weeks ago

What would be the best option here? to redirect and allow user to manually activate the license or to modify the Thank You page so that the Go to dashboard page goes back to the provided redirect_to uri? Or was going to Jetpack Cloud deliberate in the first place?

At least for this particular case, the user entered the checkout flow (1) from their site, with (2) a single specific plan to purchase. Due to that, ideally I think we would auto-activate their license key and then redirect them back to their site automatically (i.e. to the provided redirect_to parameter).

I know that technically we are buying a license key before connecting the site, and then need to activate the license (currently in the thank you page). However, also IMO, we shouldn't need to show the user anything about the license key process at all.

The "link to cloud" approach is existing from before we had a standalone plugin (Protect) for the Scan plan, which is why it just links to Cloud - that used to be the only place to access features for that plan.