Skip to content
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

Simple Payments: Stop contributors from creating inaccessible buttons with a "pending" post status. #10116

Merged
merged 1 commit into from
Sep 11, 2018

Conversation

kwight
Copy link
Contributor

@kwight kwight commented Sep 7, 2018

When Contributors attempt to add a Simple Payments button, the API call (to /sites/:site/posts/new) will succeed, creating a new button post entry in the site's database. However, this post (of type jp_pay_product) will have a pending status, due to custom post type handling in the API. The button insert will fail in the Calypso UI, and site admins won't be able to interact with these zombie buttons since we explicitly list only published buttons in the UI.

Rather than have buttons of multiple possible statuses in the database, and rather than interfering with the current handling of all CPTs in the API, this PR bumps the edit_posts capability for jp_pay_product to publish_posts, making only Authors and above capable of creating Simple Payment buttons; Contributors will now get a failed permissions response, and no button post will be added to the site database.

Testing

  • Add a contributor to a Jetpack site with a business plan (so that Simple Payments are available).
  • Using the contributor, add a Simple Payments button in Calypso; notice the UI shows an error, but devtools reveals the successful creation of the post.
  • Sandbox the API and apply this patch (the dotcom patch).
  • Attempt to add a button again, and note the API response is error: "unauthorized"
  • With a user that is an author or higher, verify you can still successfully add a Simple Payment button with the patch applied.

@kwight kwight requested a review from a team as a code owner September 7, 2018 20:19
@matticbot
Copy link
Contributor

Caution: This PR has changes that must be merged to WordPress.com
Please review this diff before merging: D18068-code. (newly created revision)

@kwight kwight requested a review from a team September 7, 2018 20:20
@jetpackbot
Copy link
Collaborator

Warnings
⚠️

The PR is missing at least one [Status] label. Suggestions: [Status] In Progress, [Status] Needs Review

⚠️

"Testing instructions" are missing for this PR. Please add some

⚠️

"Proposed changelog entry" is missing for this PR. Please include any meaningful changes

This is 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

@gwwar gwwar requested a review from mdawaffe September 7, 2018 20:36
Copy link
Contributor

@gwwar gwwar left a comment

Choose a reason for hiding this comment

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

Thanks @kwight I tested this with Editor/Author/Contributor and verified that this behaves as expected!

@jeherve jeherve added [Status] Needs Review This PR is ready for review. [Status] In Progress and removed [Status] Needs Review This PR is ready for review. labels Sep 10, 2018
@jeherve
Copy link
Member

jeherve commented Sep 10, 2018

When Contributors attempt to add a Simple Payments button

How would you do this as a contributor? I was trying to reproduce the issue, but I can't seem to add buttons in the wpcom editor as a contributor:

screenshot 2018-09-10 at 11 44 46

@kwight
Copy link
Contributor Author

kwight commented Sep 10, 2018

How would you do this as a contributor? I was trying to reproduce the issue, but I can't seem to add buttons in the wpcom editor as a contributor

Hm, I'm not sure why you can't – well, you should be able to create the junk "pending" post, and then the UI will still show a failure notice to insert the shortcode into the post:

screen shot 2018-09-10 at 12 31 14 pm

I haven't seen the unknown_post_type error at all (not with dotcom sites, nor with a connected JP sandbox on a Premium plan. Simple Payments requires a Premium or Professional plan – did your test site have one?..

@matticbot
Copy link
Contributor

Caution: This PR has changes that must be merged to WordPress.com
Please review this diff before merging: D18068-code. (updated diff)

@gwwar
Copy link
Contributor

gwwar commented Sep 10, 2018

Was the site private? I think there's a second issue around permissions in that case.

Copy link
Member

@mdawaffe mdawaffe left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks!

Copy link
Member

@jeherve jeherve left a comment

Choose a reason for hiding this comment

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

Works well for me too now. The sandbox I was testing on had code stopping the Simple Payments module to load. 🤦‍♂️

Merging now!

@jeherve jeherve merged commit d9108e1 into master Sep 11, 2018
@jeherve jeherve deleted the fix/spay-contrib branch September 11, 2018 08:52
jeherve added a commit that referenced this pull request Sep 14, 2018
jeherve added a commit that referenced this pull request Sep 24, 2018
jeherve added a commit that referenced this pull request Sep 25, 2018
* Readme: add boilerplate for next release, 6.6

* Add 6.5 to the changelog.txt file

* Set boilerplate testing list for 6.6

* Readme: update stable tag to 6.5

* Add bullets to 6.5 changelog items

* Readme: add link to previous changelogs

This will help folks who want to know more about past releases,
while keeping the readme.txt short so as to not overwhelm translators and site owners only looking for information about the last release.

* Changelog: add information at the top of the changelog file.

* Changelog: add #10054

* Changelog: add #10078

* Changelog: add #10079

* Changelog: add #10064

* Changelog: add #10094

* Changelog: add #10096

* Testing list: add more information based on #10087

* Changelog: add #9847

* Changelog: add #10084

* Changelog: add #9918

* Changelog: add #7614

* Changelog: add #10116

* Changelog: add #10108

* Changelog: add #10041

* Changelog: add #10121

* Changelog: add #10134

* Changelog: add #10130

* Changelog: add #10109

* changelog: add #10137

* changelog: add #9952

* changelog: add #10120

* changelog: add #10162

* Changelog: add #10163

* Changelog: add #10092

* changelog: add #10156

* Changelog: add #10154

* changelog: add #10122

* Changelog: add #10101

* changelog: add #10105

* changelog: add #10190

* Changelog: add #10196

* changelog: add #10152

* Changelog: add #10153

* Testing list: add more details to Site Verification testing steps.

@see #10143 (comment)

* changelog: add #10194

* Changelog: add #10193
@jeherve jeherve added the [Feature] Pay with PayPal aka Simple Payments label Aug 2, 2023
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.

6 participants