Skip to content

Conversation

@DanReyLop
Copy link
Contributor

@DanReyLop DanReyLop commented Jul 5, 2019

Fixes #111

Quick & dirty try branch, let's not merge it by accident :)

Setup:

  • Deactivate Jetpack in your site (don't uninstall it, I think that clears the tokens).
  • Go to your wp-content/plugins folder and delete the jetpack folder. You can also just move it to someplace else.
  • Clone the Jetpack repo on a completely different path in your machine (or move the jetpack folder there), update it to the try/connection-package-fix branch.
  • Update WCPay to this branch.
  • Edit line 39 on composer.json so it points to the path where you cloned jetpack.
  • Run composer install, it will say that it created a bunch of symlinks to the jetpack/packages/[...] folders.
  • Run npm run watch.
  • Go to the Payments section on WP-Admin, you should see a list of transactions correctly fetched all the way from WPCOM :)

See Automattic/jetpack@ca4cdd5 for the changes I had to make in jetpack just to make it work. I based that commit off the Automattic/jetpack#12699 PR.

This just works if there's already a Jetpack token in the database, so it will only work if you had the full fat Jetpack plugin correctly connected and you deactivated it as said in the instructions.

Sometimes, the Connection package would just work if jetpack the plugin was deactivated but still in wp-content/plugins, because the code would still be there. That's why I recommend you completely remove it, to eliminate false positives.

Communication from WPCOM to the site doesn't work, so forget about managing your WCPay site from Calypso.

Edit: I based this branch off add/link-to-order-in-transaction because right now there's no place in master to test that a connection works as easily as this: just go to the transactions list, see if it loads a bunch of data, you're done. Now the list transactions code is in master, so I rebased this branch.

cc/ @zinigor @marcinbot @v18 @allendav @RadoslavGeorgiev

@DanReyLop DanReyLop self-assigned this Jul 5, 2019
composer.json Outdated
"repositories": [
{
"type": "path",
"url": "/Users/daniel/Projects/jetpack/packages/*"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Obviously this won't be needed when automattic/jetpack-* packages are published. There's a way to tell composer to resolve a package from a GitHub repo, but it doesn't work with monorepos like jetpack/jetpack.

'headers' => $headers,
'blog_id' => Jetpack_Options::get_option( 'id' ),
'user_id' => JETPACK_MASTER_USER,
'user_id' => true, // Automattic\Jetpack\Constants::get_constant( 'JETPACK_MASTER_USER' ),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@zinigor How is the jetpack-constants package supposed to be used? I would expect that the package itself would define the JETPACK_MASTER_USER constant (and other constants), but it doesn't (yet).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nevermind, I see that the Connection\Manager class has the JETPACK_MASTER_USER constant.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@DanReyLop DanReyLop changed the base branch from add/link-to-order-in-transactions to master July 5, 2019 22:30
@allendav
Copy link
Contributor

@DanReyLop wrote:

so it will only work if you had the full fat Jetpack plugin correctly connected and you deactivated it as said in the instructions.

Is this still true? Does @zinigor know?

cc @marcinbot - let's clarify what sort of URL or ajax call we'd like for connecting / disconnecting

@DanReyLop
Copy link
Contributor Author

Is this still true?

Honestly I haven't tried, but by looking at the jetpack-connection code, I don't see how it could work. There's a Manager::register() function to call, but there's no UI, and nothing that may redirect the user to wp.com.

# Conflicts:
#	includes/wc-payment-api/class-wc-payments-api-client.php
@zinigor
Copy link
Contributor

zinigor commented Aug 19, 2019

Sorry, I was AFK, couldn't reply earlier. Yes, this is still true AFAIK: currently the connection package expects the plugin that uses it to do most of the legwork. Plus there's no corresponding connection flow in WordPress.com yet.

@marcinbot
Copy link
Contributor

Yes, this is still true AFAIK: currently the connection package expects the plugin that uses it to do most of the legwork

@zinigor Could you clarify what is the expected legwork? Is there maybe a P2 that summarizes it? Which parts of Jetpack would we have to implement ourselves?

We'd like to have a flow similar if not the same as Jetpack (subject to woo design). If Connect was able to provide this, we'd be happy for now.

@zinigor
Copy link
Contributor

zinigor commented Aug 27, 2019

@marcinbot the main thing the plugin currently needs to do is:

  • bundle the dependency,
  • add all the required hooks,
  • and manually call the register method.

This all you can see in the last three commits to the client-example repo: https://github.com/Automattic/client-example/commits/master

Following these steps will make sure that your site has a blog token and a client ID, everything else is still not ready - user authentication part where the user logs in to WordPress.com and accepts the ToS is the biggest chunk of what still needs to be done.

@DanReyLop DanReyLop closed this Mar 23, 2020
@frosso frosso deleted the try/jetpack-dna branch January 16, 2024 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Epic: Incorporate Jetpack DNA Connection package

6 participants