Skip to content

Recurring Payments: Use UpgradeNudge - #13233

Closed
ockham wants to merge 10 commits into
masterfrom
update/recurring-payments-use-upgrade-nudge
Closed

ockham wants to merge 10 commits into
masterfrom
update/recurring-payments-use-upgrade-nudge

Conversation

@ockham

@ockham ockham commented Aug 14, 2019 •

Copy link
Copy Markdown
Contributor

Changes proposed in this Pull Request:

Add an UpgradeNudge to the Recurring Payments block to replace UI that's currently part of the block itself.

Step 1 for the the Recurring Payments block project. Next steps will include adding a nudge for connecting to Stripe, and improvements to the overall flow.

Caveat

We're planning to remove the upgrade nudge from Jetpack for the next release (see #13203 and #13228). However, this would mean that per this PR, the Recurring Payments block would be hidden altogether for users on a Free Plan. Our options (AFAICS):

  1. Add back the in-block instructions, and some logic to determine whether to display those, or the Nudge. (Have the individual block check for whatever Upgrade nudge: Add filter to control block-editor upgrade nudges #13228 does.)
  2. Finish work on D31489-code, and enable the Nudge for the next JP release.

Screenshots

Before

image

After

image

Is this a new feature or does it add/remove features to an existing part of Jetpack?

Nah.

Testing instructions:

  • Switch to this branch locally, build Jetpack (yarn build), and start Docker (yarn docker:up)
  • Make sure you're connected to WP.com, and on a free plan
  • Start a new post, and insert the 'Recurring Payments' block
  • Click the nudge's "Upgrade" CTA button
  • Pay for the premium plan
  • Verify that you're redirected back to where you came from (the wp-admin block editor) (without any intermediate redirects on WP.com)

Proposed changelog entry for your changes:

Add an UpgradeNudge to the Recurring Payments block to replace UI that's currently part of the block itself.

@ockham ockham added [Status] In Progress Plans [Focus] Blocks Issues related to the block editor, aka Gutenberg, and its extensions developed in Jetpack [Block] Payment Button aka Recurring Payments labels Aug 14, 2019
@ockham
ockham requested a review from a team August 14, 2019 23:30
@ockham ockham self-assigned this Aug 14, 2019
@jetpackbot

jetpackbot commented Aug 14, 2019 •

Copy link
Copy Markdown
Collaborator
Warnings
⚠️

pre-commit hook was skipped for one or more commits

This is an automated check which relies on PULL_REQUEST_TEMPLATE. We encourage you to follow that template as it helps Jetpack maintainers do their job. If you think 'Testing instructions' or 'Proposed changelog entry' are not needed for your PR - please explain why you think so. Thanks for cooperation 🤖

Generated by 🚫 dangerJS against cc8bb1d

@ockham ockham added [Status] Needs Review This PR is ready for review. and removed [Status] In Progress labels Aug 15, 2019
@ockham
ockham requested a review from a team August 15, 2019 00:34
@brbrr brbrr added this to the 7.7 milestone Aug 15, 2019
@simison

simison commented Aug 15, 2019

Copy link
Copy Markdown
Member

Recurring Payments block would be hidden altogether for users on a Free Plan.

Oh, I thought this is already visible in the block picker even on the free plan? I might be wrong, would be good to double-check tho.

@brbrr brbrr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works well in my tests, although Recurring Payments require any paid plan. Any reason we ask for Premium instead of Personal here?

@ockham

ockham commented Aug 15, 2019

Copy link
Copy Markdown
Contributor Author

Recurring Payments block would be hidden altogether for users on a Free Plan.

Oh, I thought this is already visible in the block picker even on the free plan? I might be wrong, would be good to double-check tho.

That's the issue: The logic that adds the Upgrade Nudge only kicks in if the block is reported as unavailable because of a missing plan.

@ockham

ockham commented Aug 15, 2019

Copy link
Copy Markdown
Contributor Author

It works well in my tests, although Recurring Payments require any paid plan. Any reason we ask for Premium instead of Personal here?

Good point -- my bad 😅 I'll fix.

@brbrr brbrr added [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. [Status] Ready to Merge Go ahead, you can push that green button! and removed [Status] Needs Review This PR is ready for review. [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. labels Aug 15, 2019
brbrr
brbrr previously approved these changes Aug 15, 2019

@brbrr brbrr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@simison

simison commented Aug 15, 2019

Copy link
Copy Markdown
Member

Works, I see this as expected:

image

When I press "connect to stripe" (instead of upgrade banner), I get to stripe flow which lands me at:

https://wordpress.com/earn/payments/MY_SITE?stripe_connect_success=gutenberg

Screenshot 2019-08-15 at 16 40 43

Note no success banner or CTA button here. If we ship this iteration, I think we need to prepare a temporary solution for Calypso side first:

  • show upgrade banner in this view
  • instead of missing "connect to stripe" button, show "buy a plan" CTA

... or just orchestrate more PRs and changes ready before deploying.

After connecting to stripe, I was able to modify the block:

Screenshot 2019-08-15 at 16 43 12

As per conversation at p7rd6c-22L-p2#comment-2748 , let's do more testing around that to ensure nothing breaks before shipping this.

simison
simison previously approved these changes Aug 15, 2019

@simison simison left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a stop-gap for development, I'd be fine shipping this to Jetpack now and making sure we address issues before shipping to .com or before 7.7 code freeze is upon us.

Code looks good.

@chriskmnds chriskmnds left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor comments from own curiosity.

/**
* Register the Recurring Payments Gutenberg block
*/
public function register_gutenberg_block() {

@chriskmnds chriskmnds Aug 15, 2019 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name (register_gutenberg_block) feels a little generic vs the enclosed logic that only deals with a particular block (recurring-payments). I presume this is likely going to evolve into a more general block registration handler (?).

That said, is the underlying logic here a little specific for a general memberships class (or what appears to be)? I prefer to decouple things like these early on if that's the case. Fear being, it can get cluttered with specific block type references sooner than later, and harder to refactor later (or nobody bothers to do so). I do see the class is only a few months old though, so it probably makes sense for v1. 🤔

Just curious on perspective - and the little I understand so far. :-)

p.s. I guess there is the option of moving "block registration" to a trait as an intermediate solution.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name (register_gutenberg_block) feels a little generic vs the enclosed logic that only deals with a particular block (recurring-payments).

Hmm, I was thinking of this method to mean "register this Jetpack module's Gutenberg block". I didn't really want to do a method named register_xyz_gutenberg_block inside of a class named XYZ, that seemed to redundant. (Okay, in this case, it would probably be Jetpack_Memberships::register_recurring_payments_gutenberg_block() rather than Jetpack_Memberships::register_memberships_gutenberg_block(), but I'd argue that memberships and recurring_payments are mostly used synonymously in this file (and that the fact that two names exist for the same thing is mostly circumstantial).

I presume this is likely going to evolve into a more general block registration handler (?).

I didn't intend to evolve it into somehting more general, TBH. The logic driving whether a block should be registered, or whether it should be set as unavailable, and for what reason, is something fairly specific to each individual block.

That said, is the underlying logic here a little specific for a general memberships class (or what appears to be)? I prefer to decouple things like these early on if that's the case. Fear being, it can get cluttered with specific block type references sooner than later, and harder to refactor later (or nobody bothers to do so). I do see the class is only a few months old though, so it probably makes sense for v1.

Just curious on perspective - and the little I understand so far. :-)

p.s. I guess there is the option of moving "block registration" to a trait as an intermediate solution.

I agree in principle; but as stated above, I'm not sure we can make things a lot more homogenous here. We have fairly indidivual Jetpack modules (a somewhat legacy concept) each of which does things quite differently, and we often have to find the best place to register the corresponding block (or set their (un)availability).

I've so far considered the jetpack_register_block() and Jetpack_Gutenberg::set_extension_unavailable our interface; modules can essentially use them at whatever point into their lifecycle (as long as it's soon enough for the consumer -- mostly the REST API -- to get accurate information). I guess for the purpose of the required plan check, we could require each module to provide information about the minimum plan it nees, and evaluate that information and register/set availability based on that.

But this is complicated by the heterogenity of modules themselves. Note that not all modules come with a block; and not all blocks are tied to a module. Furthermore, a lot of modules exist both on JP and WP.com, but are implemented differently in both places.

And finally, there are other criteria besides required plan that can determine whether or not to show a block as available.

(That turned out a bit verbose 😅 I hope I didn't squash that -- commendable! -- idea of better consistency. If I'm beside the point, or if you had any other idea on how to do this, please let me know!)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, this was an excellent overview writeup of the problem space to explain the why's of the current setup. :-)

Would some of it deserve a place in the docs?

@chriskmnds chriskmnds Aug 16, 2019 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verbose is good. Thanks for the extra clarifications! :-)

I think the "modules" folder is a bit of a scary place for one to be (glad to see you mentioning "legacy" above)!

I can see this is following along how simple-payments is registering blocks. What I find missing I think is a contract binding these on common characteristics, or some abstraction of the things they do in common (which they apparently do - registering blocks for one). I believe you implied that in your answer above.

if you had any other idea on how to do this, please let me know!

I don't, concretely, but I can throw some likely obvious ideas.

Modules seems to be an all-encompassing folder here - so I guess I would start with that - add some structure to the things we know (in this case, "modules that register blocks"). I think I would approach this along these lines:

Centralise the common logic elsewhere - provide a "yet another module" to handle block registration. I think I'd be happy if a module that registers a block defines some options for that block and only registers an action that takes care of the rest e.g.

  1. define block options in the respective module (to be worked out in form, obviously):
class Simple_Payments {
    ...
    const OPTIONS = array( name => "simple-payments", ... );
  1. pass a callback to the action hooks:
class Simple_Payments {
    ...
    private function register_init_hooks() {
        add_action( 'jetpack_register_gutenberg_extension', Fancy_Module_Name::init( self::OPTIONS ) );
    }
  1. with Fancy_Module_Name handling block registration. Simple, and presumably of the form:
class Fancy_Module_Name {
    static function init( $options ) {
        return function() use ( $options ) {
            // do stuff to register block with passed options/config
        };
    }
}

Alternatively, I guess the more OO way - a parent class that these modules can extend from, contract block registration functions via an interface, a trait that these modules can mix in, etc. Just stating the obvious perhaps - but something along these lines! (assuming my naive understanding of any underlying complexities)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and my understanding is indeed fairly naive right now! I can hardly even tell how tightly-coupled the terms "membership" and "recurring-payments" are for one.

@simison

simison commented Aug 16, 2019

Copy link
Copy Markdown
Member

Note no success banner or CTA button here. If we ship this iteration, I think we need to prepare a temporary solution for Calypso side first:

Turn out this was a bug, opened an issue to track: Automattic/wp-calypso#35455

@jeherve jeherve left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found this a bit confusing; I didn't expect to be able to go through the whole connection flow before the upgrade. It does feel a lot more aggressive this way in my opinion, as folks go through a lot of trouble to set this up, only to be told they can't use it (yet). imo it may be better to not display the button to connect to Stripe until you upgrade.

Was this discussed somewhere already?

@ockham

ockham commented Aug 20, 2019

Copy link
Copy Markdown
Contributor Author

I found this a bit confusing; I didn't expect to be able to go through the whole connection flow before the upgrade. It does feel a lot more aggressive this way in my opinion, as folks go through a lot of trouble to set this up, only to be told they can't use it (yet). imo it may be better to not display the button to connect to Stripe until you upgrade.

Was this discussed somewhere already?

@jeherve Yeah, sorry for the confusion. Our plan is to also move the Stripe connection prompt into a Nudge (akin to the Upgrade Nudge), which will only appear if the site has been upgraded to the required plan. (We're planning to this in a follow-up PR.) We want the block itself to ideally always contain the UI that it'll have if all requirements (paid plan and Stripe connection) are met, so the user can play with it prior to actually upgrading.

Here's a mockup (from p7rd6c-22L-p2#comment-2738):

screenshot-2019-08-14-15 16 18

(There might be technical obstacles limiting how much we can actually reflect the 'fully functional' block behvior before all requirements are met -- see that same P2 thread, p7rd6c-22L-p2 -- but in that case, we can still e.g. display a pruned-down preview.)

@ockham ockham added [Status] Blocked / Hold and removed [Status] Ready to Merge Go ahead, you can push that green button! labels Aug 20, 2019
@ockham

ockham commented Aug 20, 2019

Copy link
Copy Markdown
Contributor Author

Setting status to Blocked/Hold, since we should figure out a strategy how to deploy this to WP.com first without disrupting everybody's flows.

@jeherve jeherve removed this from the 7.7 milestone Aug 21, 2019
@ockham
ockham force-pushed the update/recurring-payments-use-upgrade-nudge branch 2 times, most recently from cc8bb1d to 161bad0 Compare September 2, 2019 20:27
@ockham

ockham commented Sep 2, 2019

Copy link
Copy Markdown
Contributor Author

Closing in favor of #13394

@ockham ockham closed this Sep 2, 2019
@kraftbj
kraftbj deleted the update/recurring-payments-use-upgrade-nudge branch April 17, 2025 13:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Block] Payment Button aka Recurring Payments [Focus] Blocks Issues related to the block editor, aka Gutenberg, and its extensions developed in Jetpack Plans [Status] Blocked / Hold Touches WP.com Files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants