-
Notifications
You must be signed in to change notification settings - Fork 799
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
Recurring Payments: Add postId to Stripe connection URL state param #13398
Recurring Payments: Add postId to Stripe connection URL state param #13398
Conversation
Caution: This PR has changes that must be merged to WordPress.com |
Thank you for the great PR description! When this PR is ready for review, please apply the Scheduled Jetpack release: October 1, 2019. |
e530615
to
fe7213f
Compare
Caution: This PR has changes that must be merged to WordPress.com |
fe7213f
to
4a016a1
Compare
Caution: This PR has changes that must be merged to WordPress.com |
sirreal, Your synced wpcom patch D32391-code has been updated. |
0f224cf
to
6ccf747
Compare
sirreal, Your synced wpcom patch D32391-code has been updated. |
sirreal, Your synced wpcom patch D32391-code has been updated. |
sirreal, Your synced wpcom patch D32391-code has been updated. |
sirreal, Your synced wpcom patch D32391-code has been updated. |
The flow took me back to |
href={ stripeConnectUrl } | ||
target={ stripeConnectTarget } | ||
rel={ stripeConnectTarget === '_blank' ? 'noopener noreferrer' : undefined } | ||
onClick={ this.props.autosaveAndNavigateToConnection } |
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.
I think we'll need to add tracking here but that's good for a follow up PR.
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.
#13394 does that 👍
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.
Actually, it only does in case we're using the Stripe Connect Nudge, but not if we're still using the in-block connect button 🙁
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.
Gave this some more testing (some of which during a call wiht @sirreal). The issue I was seeing earlier seems to be rather spurious, so it's hopefully due to something with my test site (I was thinking maybe because I'm not using a 'static' ngrok domain?)
Recent tries have all worked, both when canceling the Stripe connection flow, and when connecting (using the dev mode dummy connection).
Let's 🚢 it 👍
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.
event.preventDefault(); | ||
await dispatch( 'core/editor' ).autosave(); | ||
// Using window.top to escape from the editor iframe on WordPress.com | ||
window.top.location.href = href; |
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.
Do we need to guard here for potentially undefined window?
cc @ockham
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.
We have a redirect like this in the block nudge already. I'm not sure it's dangerous to have window
unguarded in cases like this; while we do use the block nudge for server side rendering, it's only the plain 'dumb' component rather than the withDispatch()
case, so we're not actually ever using it in a context where window
doesn't exist -- and I think we'd notice pretty much immediately if we did, since it'll totally break the build. (The same argument applies to this occurrence.)
My take would thus be YAGNI -- let's only add it once we need it, e.g. if the build fails.
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.
Ok, makes sense I guess. I am not familiar with the server side rendering stuff - just curious as you mentioned it previously. So YAGNI - if the build fails, then fix? Not sure that was the case previously tbh (I don't remember builds failing, but it was a fairly different case + may be wrong/missing something). I'm clueless on the ssr stuff. :-)
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.
It's a good question, guarding browser globals is cheap and saves pain down the road. The problem here is that none of this code block makes sense outside the browser. We can't event.preventDefault
if we can't handle the redirect. That leads to being unable to save the content before navigation, and at that point we might as well just error.
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.
What Jon said -- it's just a noop
outside the browser (we do however have an href
in the 'dumb' component as the fallback for the SSR case, so a noop
should be okay -- but we essentially do that, at least in the Upgrade Nudge case, by using the dumb rather than the smart component in SSR).
Companion to D32394-code
See p7rd6c-24Y-p2 for detailed discussion.
Changes proposed in this Pull Request:
noopener noreferrer
if the link will open in a new window (_blank
).Testing instructions:
public-api.wordpress.com
, you should be able to follow the whole flow./earn
on WordPress.comThe post id is base64 encoded in the
state
query param on the connection URL. You can grab it and inspect to verify that the post ID is correctly added.Proposed changelog entry for your changes:
None.