Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@aldeed
Copy link
Contributor

@aldeed aldeed commented Aug 5, 2019

Impact: major
Type: bugfix

Issue

Discovered a few issues with recently added refunds GraphQL queries. In general, these are blocking being able to check out and view the order on storefront, and being able to capture the payments on admin (using Stripe).

  • There are extra permission checks on refunds and refundsByPaymentIds queries. getOrderQuery util function already does permission checks.
  • imports/plugins/core/orders/server/no-meteor/resolvers/Order/payments.js is calling refundsByPaymentId with order.token for the token param, but that's the hashed token so it fails.
  • When capturing the payment, it fails and there's a server error complaining about the ID namespace not being "reaction/order". I'm guessing somewhere there's a resolver layer that's passing an already-internal ID where an opaque ID is expected.

Solution

  • Removed the extra permission checks
  • There's no reason why refundsByPaymentId should be looking up the order from DB again in cases where we already have it. Maybe payments.js should just pass the whole order, and update refundsByPaymentId to skip the permission / lookup stuff when the order is passed in.
  • Remove comments from the lines of code that convert IDs before calling captureOrderPayment from browser

Breaking changes

None

Testing

  • With Stripe payment set up, verify that you can place an anonymous order from develop branch of the example storefront, and then capture that order payment in Reaction Admin.
  • Same test but with an account order

from refund queries

Signed-off-by: Eric Dobbertin <[email protected]>
@kieckhafer
Copy link
Member

kieckhafer commented Aug 6, 2019

@aldeed Updated refundsByPaymentId to accept an order object, and skip the query of the Orders collection if it's provided.

Signed-off-by: Erik Kieckhafer <[email protected]>
Signed-off-by: Erik Kieckhafer <[email protected]>
Signed-off-by: Erik Kieckhafer <[email protected]>
@aldeed
Copy link
Contributor Author

aldeed commented Aug 6, 2019

@kieckhafer Actually I think GraphQL refundsByPaymentId should go back to what it was. Passing in an order should be an optimization for internal calls only. We wouldn't want to encourage people to pass an entire order to the server over GraphQL.

@kieckhafer
Copy link
Member

kieckhafer commented Aug 6, 2019

@aldeed reverted most of those changes, now order is an optional param that if passed, will skip that check, but all other params are still required and should function how it was.

@kieckhafer kieckhafer marked this pull request as ready for review August 6, 2019 17:51
@kieckhafer kieckhafer removed their request for review August 6, 2019 19:01
@kieckhafer kieckhafer removed their assignment Aug 6, 2019
@aldeed
Copy link
Contributor Author

aldeed commented Aug 6, 2019

@kieckhafer Everything works correctly now for both anon and account orders. I can't approve this because I created it but I'm fine with merging it.

@aldeed aldeed requested a review from kieckhafer August 6, 2019 20:06
@kieckhafer kieckhafer merged commit c685727 into develop Aug 6, 2019
@kieckhafer kieckhafer deleted the fix-aldeed-refund-gql-issues branch August 6, 2019 20:09
@kieckhafer kieckhafer mentioned this pull request Aug 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants