{"action":"created","comment":{"url":"https://api.github.com/repos/Automattic/wp-calypso/pulls/comments/68634890","id":68634890,"diff_hunk":"@@ -66,6 +68,28 @@ export function getSitePlanSlug( siteID ) {\n \treturn get( site, 'plan.product_slug' );\n }\n \n+function canUpgradeToPlan( planKey, site ) {\n+\tconst offer = site.jetpack ? JETPACK : WPCOM;\n+\treturn get( plansList, [ planKey, 'availableIn' ], () => false )( offer );\n+}\n+\n+export function getUpgradePlanSlugFromPath( path, siteID ) {\n+\tconst site = siteID ? sitesList.getSite( siteID ) : sitesList.getSelectedSite();\n+\treturn find( Object.keys( plansList ), planKey => (\n+\t\t( planKey === path || getPlanPath( planKey ) === path ) &&\n+\t\tcanUpgradeToPlan( planKey, site )\n+\t) );\n+}\n+\n+export function getPlanPath( plan ) {\n+\treturn get( plansList, [ plan, 'getPathSlug' ], () => undefined )();\n+}\n+\n+export const getCartItem = ( productSlug, isFreeTrial = false ) => ( {","path":"client/lib/plans/index.js","position":32,"original_position":32,"commit_id":"e392899037dbf84da03920919898f59b670104dc","original_commit_id":"9ca81ed8348820bcce0adb99e313946bee663a02","user":{"login":"gwwar","id":1270189,"avatar_url":"https://avatars.githubusercontent.com/u/1270189?v=3","gravatar_id":"","url":"https://api.github.com/users/gwwar","html_url":"https://github.com/gwwar","followers_url":"https://api.github.com/users/gwwar/followers","following_url":"https://api.github.com/users/gwwar/following{/other_user}","gists_url":"https://api.github.com/users/gwwar/gists{/gist_id}","starred_url":"https://api.github.com/users/gwwar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gwwar/subscriptions","organizations_url":"https://api.github.com/users/gwwar/orgs","repos_url":"https://api.github.com/users/gwwar/repos","events_url":"https://api.github.com/users/gwwar/events{/privacy}","received_events_url":"https://api.github.com/users/gwwar/received_events","type":"User","site_admin":false},"body":"We can keep this function, but I would still put this logic closer to the checkout action since its unlikely to be reused and it doesn't rely on any of the constants in this file.","created_at":"2016-06-27T18:55:09Z","updated_at":"2016-06-27T18:55:09Z","html_url":"https://github.com/Automattic/wp-calypso/pull/6207#discussion_r68634890","pull_request_url":"https://api.github.com/repos/Automattic/wp-calypso/pulls/6207","_links":{"self":{"href":"https://api.github.com/repos/Automattic/wp-calypso/pulls/comments/68634890"},"html":{"href":"https://github.com/Automattic/wp-calypso/pull/6207#discussion_r68634890"},"pull_request":{"href":"https://api.github.com/repos/Automattic/wp-calypso/pulls/6207"}}},"pull_request":{"url":"https://api.github.com/repos/Automattic/wp-calypso/pulls/6207","id":74760616,"html_url":"https://github.com/Automattic/wp-calypso/pull/6207","diff_url":"https://github.com/Automattic/wp-calypso/pull/6207.diff","patch_url":"https://github.com/Automattic/wp-calypso/pull/6207.patch","issue_url":"https://api.github.com/repos/Automattic/wp-calypso/issues/6207","number":6207,"state":"open","locked":false,"title":"Upgrades: New plans upgrade action","user":{"login":"artpi","id":3775068,"avatar_url":"https://avatars.githubusercontent.com/u/3775068?v=3","gravatar_id":"","url":"https://api.github.com/users/artpi","html_url":"https://github.com/artpi","followers_url":"https://api.github.com/users/artpi/followers","following_url":"https://api.github.com/users/artpi/following{/other_user}","gists_url":"https://api.github.com/users/artpi/gists{/gist_id}","starred_url":"https://api.github.com/users/artpi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/artpi/subscriptions","organizations_url":"https://api.github.com/users/artpi/orgs","repos_url":"https://api.github.com/users/artpi/repos","events_url":"https://api.github.com/users/artpi/events{/privacy}","received_events_url":"https://api.github.com/users/artpi/received_events","type":"User","site_admin":false},"body":"This introduces upgrade action to @lamosty #6119\r\n\r\n- Attempts to almost remove `/lib/plans-list`\r\n- Simplifies a bunch\r\n- Adds a reliable route\r\n- Removes a bug that route `/checkout/jetpack-site/business` allowed to purchase business for jetpack\r\n- Adds resilient routes for checkout that handle both PlanSlugs and Plan Path ids.\r\n\r\n## Testing\r\n\r\n- Run Calypso with `ENABLE_FEATURES=manage/plan-features make run`\r\n- Go to http://calypso.localhost:3000/plans/features/$site\r\n- Click upgrade button under any plan\r\n- Verify that you go to checkout\r\n\r\nMake sure following routes work properly\r\n\r\n- /checkout/site.wpcom/premium\r\n- /checkout/site.wpcom/personal\r\n- /checkout/site.wpcom/business\r\n- /checkout/site.jetpack/premium\r\n- /checkout/site.jetpack/professional\r\n\r\n- make sure that any other route does **not** work.\r\n- make sure all the existing checkout flows still work\r\n- make sure checkouts in nux work\r\n- make sure buing themes work\r\n\r\nCC @gwwar @lamosty @rralian \r\n\r\nTest live: https://calypso.live/?branch=update/plans-actions-refactor","created_at":"2016-06-22T10:35:18Z","updated_at":"2016-06-27T18:55:09Z","closed_at":null,"merged_at":null,"merge_commit_sha":"32b59af6476390eafc729d8e197adf5d86d3a304","assignee":{"login":"artpi","id":3775068,"avatar_url":"https://avatars.githubusercontent.com/u/3775068?v=3","gravatar_id":"","url":"https://api.github.com/users/artpi","html_url":"https://github.com/artpi","followers_url":"https://api.github.com/users/artpi/followers","following_url":"https://api.github.com/users/artpi/following{/other_user}","gists_url":"https://api.github.com/users/artpi/gists{/gist_id}","starred_url":"https://api.github.com/users/artpi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/artpi/subscriptions","organizations_url":"https://api.github.com/users/artpi/orgs","repos_url":"https://api.github.com/users/artpi/repos","events_url":"https://api.github.com/users/artpi/events{/privacy}","received_events_url":"https://api.github.com/users/artpi/received_events","type":"User","site_admin":false},"assignees":[{"login":"artpi","id":3775068,"avatar_url":"https://avatars.githubusercontent.com/u/3775068?v=3","gravatar_id":"","url":"https://api.github.com/users/artpi","html_url":"https://github.com/artpi","followers_url":"https://api.github.com/users/artpi/followers","following_url":"https://api.github.com/users/artpi/following{/other_user}","gists_url":"https://api.github.com/users/artpi/gists{/gist_id}","starred_url":"https://api.github.com/users/artpi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/artpi/subscriptions","organizations_url":"https://api.github.com/users/artpi/orgs","repos_url":"https://api.github.com/users/artpi/repos","events_url":"https://api.github.com/users/artpi/events{/privacy}","received_events_url":"https://api.github.com/users/artpi/received_events","type":"User","site_admin":false}],"milestone":{"url":"https://api.github.com/repos/Automattic/wp-calypso/milestones/89","html_url":"https://github.com/Automattic/wp-calypso/milestones/Plans:%20Maintenance","labels_url":"https://api.github.com/repos/Automattic/wp-calypso/milestones/89/labels","id":1768456,"number":89,"title":"Plans: Maintenance","description":"","creator":{"login":"fabianapsimoes","id":1248436,"avatar_url":"https://avatars.githubusercontent.com/u/1248436?v=3","gravatar_id":"","url":"https://api.github.com/users/fabianapsimoes","html_url":"https://github.com/fabianapsimoes","followers_url":"https://api.github.com/users/fabianapsimoes/followers","following_url":"https://api.github.com/users/fabianapsimoes/following{/other_user}","gists_url":"https://api.github.com/users/fabianapsimoes/gists{/gist_id}","starred_url":"https://api.github.com/users/fabianapsimoes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fabianapsimoes/subscriptions","organizations_url":"https://api.github.com/users/fabianapsimoes/orgs","repos_url":"https://api.github.com/users/fabianapsimoes/repos","events_url":"https://api.github.com/users/fabianapsimoes/events{/privacy}","received_events_url":"https://api.github.com/users/fabianapsimoes/received_events","type":"User","site_admin":false},"open_issues":33,"closed_issues":51,"state":"open","created_at":"2016-05-16T10:50:24Z","updated_at":"2016-06-27T17:02:27Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/Automattic/wp-calypso/pulls/6207/commits","review_comments_url":"https://api.github.com/repos/Automattic/wp-calypso/pulls/6207/comments","review_comment_url":"https://api.github.com/repos/Automattic/wp-calypso/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Automattic/wp-calypso/issues/6207/comments","statuses_url":"https://api.github.com/repos/Automattic/wp-calypso/statuses/e392899037dbf84da03920919898f59b670104dc","head":{"label":"Automattic:update/plans-actions-refactor","ref":"update/plans-actions-refactor","sha":"e392899037dbf84da03920919898f59b670104dc","user":{"login":"Automattic","id":887802,"avatar_url":"https://avatars.githubusercontent.com/u/887802?v=3","gravatar_id":"","url":"https://api.github.com/users/Automattic","html_url":"https://github.com/Automattic","followers_url":"https://api.github.com/users/Automattic/followers","following_url":"https://api.github.com/users/Automattic/following{/other_user}","gists_url":"https://api.github.com/users/Automattic/gists{/gist_id}","starred_url":"https://api.github.com/users/Automattic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Automattic/subscriptions","organizations_url":"https://api.github.com/users/Automattic/orgs","repos_url":"https://api.github.com/users/Automattic/repos","events_url":"https://api.github.com/users/Automattic/events{/privacy}","received_events_url":"https://api.github.com/users/Automattic/received_events","type":"Organization","site_admin":false},"repo":{"id":45936895,"name":"wp-calypso","full_name":"Automattic/wp-calypso","owner":{"login":"Automattic","id":887802,"avatar_url":"https://avatars.githubusercontent.com/u/887802?v=3","gravatar_id":"","url":"https://api.github.com/users/Automattic","html_url":"https://github.com/Automattic","followers_url":"https://api.github.com/users/Automattic/followers","following_url":"https://api.github.com/users/Automattic/following{/other_user}","gists_url":"https://api.github.com/users/Automattic/gists{/gist_id}","starred_url":"https://api.github.com/users/Automattic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Automattic/subscriptions","organizations_url":"https://api.github.com/users/Automattic/orgs","repos_url":"https://api.github.com/users/Automattic/repos","events_url":"https://api.github.com/users/Automattic/events{/privacy}","received_events_url":"https://api.github.com/users/Automattic/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Automattic/wp-calypso","description":"The new JavaScript- and API-powered WordPress.com","fork":false,"url":"https://api.github.com/repos/Automattic/wp-calypso","forks_url":"https://api.github.com/repos/Automattic/wp-calypso/forks","keys_url":"https://api.github.com/repos/Automattic/wp-calypso/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Automattic/wp-calypso/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Automattic/wp-calypso/teams","hooks_url":"https://api.github.com/repos/Automattic/wp-calypso/hooks","issue_events_url":"https://api.github.com/repos/Automattic/wp-calypso/issues/events{/number}","events_url":"https://api.github.com/repos/Automattic/wp-calypso/events","assignees_url":"https://api.github.com/repos/Automattic/wp-calypso/assignees{/user}","branches_url":"https://api.github.com/repos/Automattic/wp-calypso/branches{/branch}","tags_url":"https://api.github.com/repos/Automattic/wp-calypso/tags","blobs_url":"https://api.github.com/repos/Automattic/wp-calypso/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Automattic/wp-calypso/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Automattic/wp-calypso/git/refs{/sha}","trees_url":"https://api.github.com/repos/Automattic/wp-calypso/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Automattic/wp-calypso/statuses/{sha}","languages_url":"https://api.github.com/repos/Automattic/wp-calypso/languages","stargazers_url":"https://api.github.com/repos/Automattic/wp-calypso/stargazers","contributors_url":"https://api.github.com/repos/Automattic/wp-calypso/contributors","subscribers_url":"https://api.github.com/repos/Automattic/wp-calypso/subscribers","subscription_url":"https://api.github.com/repos/Automattic/wp-calypso/subscription","commits_url":"https://api.github.com/repos/Automattic/wp-calypso/commits{/sha}","git_commits_url":"https://api.github.com/repos/Automattic/wp-calypso/git/commits{/sha}","comments_url":"https://api.github.com/repos/Automattic/wp-calypso/comments{/number}","issue_comment_url":"https://api.github.com/repos/Automattic/wp-calypso/issues/comments{/number}","contents_url":"https://api.github.com/repos/Automattic/wp-calypso/contents/{+path}","compare_url":"https://api.github.com/repos/Automattic/wp-calypso/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Automattic/wp-calypso/merges","archive_url":"https://api.github.com/repos/Automattic/wp-calypso/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Automattic/wp-calypso/downloads","issues_url":"https://api.github.com/repos/Automattic/wp-calypso/issues{/number}","pulls_url":"https://api.github.com/repos/Automattic/wp-calypso/pulls{/number}","milestones_url":"https://api.github.com/repos/Automattic/wp-calypso/milestones{/number}","notifications_url":"https://api.github.com/repos/Automattic/wp-calypso/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Automattic/wp-calypso/labels{/name}","releases_url":"https://api.github.com/repos/Automattic/wp-calypso/releases{/id}","deployments_url":"https://api.github.com/repos/Automattic/wp-calypso/deployments","created_at":"2015-11-10T20:00:16Z","updated_at":"2016-06-27T09:00:56Z","pushed_at":"2016-06-27T18:54:29Z","git_url":"git://github.com/Automattic/wp-calypso.git","ssh_url":"git@github.com:Automattic/wp-calypso.git","clone_url":"https://github.com/Automattic/wp-calypso.git","svn_url":"https://github.com/Automattic/wp-calypso","homepage":"https://developer.wordpress.com/calypso/","size":79866,"stargazers_count":7503,"watchers_count":7503,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":928,"mirror_url":null,"open_issues_count":1307,"forks":928,"open_issues":1307,"watchers":7503,"default_branch":"master"}},"base":{"label":"Automattic:master","ref":"master","sha":"30c0eedba1a57749e3b9d67e9b0ae6750efa2aa9","user":{"login":"Automattic","id":887802,"avatar_url":"https://avatars.githubusercontent.com/u/887802?v=3","gravatar_id":"","url":"https://api.github.com/users/Automattic","html_url":"https://github.com/Automattic","followers_url":"https://api.github.com/users/Automattic/followers","following_url":"https://api.github.com/users/Automattic/following{/other_user}","gists_url":"https://api.github.com/users/Automattic/gists{/gist_id}","starred_url":"https://api.github.com/users/Automattic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Automattic/subscriptions","organizations_url":"https://api.github.com/users/Automattic/orgs","repos_url":"https://api.github.com/users/Automattic/repos","events_url":"https://api.github.com/users/Automattic/events{/privacy}","received_events_url":"https://api.github.com/users/Automattic/received_events","type":"Organization","site_admin":false},"repo":{"id":45936895,"name":"wp-calypso","full_name":"Automattic/wp-calypso","owner":{"login":"Automattic","id":887802,"avatar_url":"https://avatars.githubusercontent.com/u/887802?v=3","gravatar_id":"","url":"https://api.github.com/users/Automattic","html_url":"https://github.com/Automattic","followers_url":"https://api.github.com/users/Automattic/followers","following_url":"https://api.github.com/users/Automattic/following{/other_user}","gists_url":"https://api.github.com/users/Automattic/gists{/gist_id}","starred_url":"https://api.github.com/users/Automattic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Automattic/subscriptions","organizations_url":"https://api.github.com/users/Automattic/orgs","repos_url":"https://api.github.com/users/Automattic/repos","events_url":"https://api.github.com/users/Automattic/events{/privacy}","received_events_url":"https://api.github.com/users/Automattic/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Automattic/wp-calypso","description":"The new JavaScript- and API-powered WordPress.com","fork":false,"url":"https://api.github.com/repos/Automattic/wp-calypso","forks_url":"https://api.github.com/repos/Automattic/wp-calypso/forks","keys_url":"https://api.github.com/repos/Automattic/wp-calypso/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Automattic/wp-calypso/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Automattic/wp-calypso/teams","hooks_url":"https://api.github.com/repos/Automattic/wp-calypso/hooks","issue_events_url":"https://api.github.com/repos/Automattic/wp-calypso/issues/events{/number}","events_url":"https://api.github.com/repos/Automattic/wp-calypso/events","assignees_url":"https://api.github.com/repos/Automattic/wp-calypso/assignees{/user}","branches_url":"https://api.github.com/repos/Automattic/wp-calypso/branches{/branch}","tags_url":"https://api.github.com/repos/Automattic/wp-calypso/tags","blobs_url":"https://api.github.com/repos/Automattic/wp-calypso/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Automattic/wp-calypso/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Automattic/wp-calypso/git/refs{/sha}","trees_url":"https://api.github.com/repos/Automattic/wp-calypso/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Automattic/wp-calypso/statuses/{sha}","languages_url":"https://api.github.com/repos/Automattic/wp-calypso/languages","stargazers_url":"https://api.github.com/repos/Automattic/wp-calypso/stargazers","contributors_url":"https://api.github.com/repos/Automattic/wp-calypso/contributors","subscribers_url":"https://api.github.com/repos/Automattic/wp-calypso/subscribers","subscription_url":"https://api.github.com/repos/Automattic/wp-calypso/subscription","commits_url":"https://api.github.com/repos/Automattic/wp-calypso/commits{/sha}","git_commits_url":"https://api.github.com/repos/Automattic/wp-calypso/git/commits{/sha}","comments_url":"https://api.github.com/repos/Automattic/wp-calypso/comments{/number}","issue_comment_url":"https://api.github.com/repos/Automattic/wp-calypso/issues/comments{/number}","contents_url":"https://api.github.com/repos/Automattic/wp-calypso/contents/{+path}","compare_url":"https://api.github.com/repos/Automattic/wp-calypso/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Automattic/wp-calypso/merges","archive_url":"https://api.github.com/repos/Automattic/wp-calypso/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Automattic/wp-calypso/downloads","issues_url":"https://api.github.com/repos/Automattic/wp-calypso/issues{/number}","pulls_url":"https://api.github.com/repos/Automattic/wp-calypso/pulls{/number}","milestones_url":"https://api.github.com/repos/Automattic/wp-calypso/milestones{/number}","notifications_url":"https://api.github.com/repos/Automattic/wp-calypso/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Automattic/wp-calypso/labels{/name}","releases_url":"https://api.github.com/repos/Automattic/wp-calypso/releases{/id}","deployments_url":"https://api.github.com/repos/Automattic/wp-calypso/deployments","created_at":"2015-11-10T20:00:16Z","updated_at":"2016-06-27T09:00:56Z","pushed_at":"2016-06-27T18:54:29Z","git_url":"git://github.com/Automattic/wp-calypso.git","ssh_url":"git@github.com:Automattic/wp-calypso.git","clone_url":"https://github.com/Automattic/wp-calypso.git","svn_url":"https://github.com/Automattic/wp-calypso","homepage":"https://developer.wordpress.com/calypso/","size":79866,"stargazers_count":7503,"watchers_count":7503,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":928,"mirror_url":null,"open_issues_count":1307,"forks":928,"open_issues":1307,"watchers":7503,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Automattic/wp-calypso/pulls/6207"},"html":{"href":"https://github.com/Automattic/wp-calypso/pull/6207"},"issue":{"href":"https://api.github.com/repos/Automattic/wp-calypso/issues/6207"},"comments":{"href":"https://api.github.com/repos/Automattic/wp-calypso/issues/6207/comments"},"review_comments":{"href":"https://api.github.com/repos/Automattic/wp-calypso/pulls/6207/comments"},"review_comment":{"href":"https://api.github.com/repos/Automattic/wp-calypso/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Automattic/wp-calypso/pulls/6207/commits"},"statuses":{"href":"https://api.github.com/repos/Automattic/wp-calypso/statuses/e392899037dbf84da03920919898f59b670104dc"}}}}
{"actor":{"display_login":"gwwar"}}