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

Skip to content

Conversation

@kieckhafer
Copy link
Member

@kieckhafer kieckhafer commented Jul 23, 2019

Part of #5158
Impact: minor
Type: feature

A new createRefund mutation allows you to create a refund for a particular payment on an order. This was previously a meteor only method. The meteor method will be removed with #5158.

Breaking changes

None

Testing

  1. Place an order
  2. Use the following mutation to create a refund on said order
  3. Try to refund more than the charge was, and see that only the remaining amout was refunded
createRefund(
  amount: {AMOUNT}!,
  orderId: {ORDER-ID}!,
  paymentId: {PAYMENT-ID}!,
  reason: {Reason}) {
    order {
      {FIELDS-TO-RETREIVE}
    }
  }

amount, orderId, and paymentId are required. reason is optional. It's set up as a String to be used with multiple payment providers, however for Stripe, which is our only provider at the moment, they only accept 3 values for reason: duplicate, fraudulent, or requested_by_customer, so be sure to use one of those values if testing with Stripe. This limit will be built into the Operator UI if Stripe is the payment method. From their docs:

String indicating the reason for the refund. If set, possible values are duplicate, fraudulent, and requested_by_customer. If you believe the charge to be fraudulent, specifying fraudulent as the reason will add the associated card and email to your block lists, and will also help us improve our fraud detection algorithms.

I've added tests here to test the permission / requirements of variables, but did not add tests to check a result, as the payment method has it's own tests for this element: https://github.com/reactioncommerce/reaction/blob/feat-kieckhafer-listRefundsGQLQuery/imports/plugins/included/payments-stripe/server/no-meteor/util/stripeListRefunds.test.js#L10

Signed-off-by: Erik Kieckhafer <[email protected]>
(cherry picked from commit ecd3492)
@kieckhafer kieckhafer changed the base branch from master to develop July 23, 2019 21:32
@kieckhafer kieckhafer changed the title Feat kieckhafer create refund gql mutation feat: add createRefund mutation Jul 23, 2019
@kieckhafer kieckhafer requested a review from aldeed July 23, 2019 21:36
@kieckhafer kieckhafer changed the title feat: add createRefund mutation feat: add createRefund GraphQL mutation Jul 23, 2019
@kieckhafer kieckhafer requested a review from focusaurus July 24, 2019 17:24
Copy link
Contributor

@focusaurus focusaurus left a comment

Choose a reason for hiding this comment

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

Looks good overall. Probably worthwhile to defend against negative amount, but that's my only change request.

@kieckhafer
Copy link
Member Author

kieckhafer commented Jul 25, 2019

@focusaurus I've added a min check at 0.01, not 0. I can't think of a scenario where there would be a refund of 0. If you think it should be 0 instead, I can change it to that.

Also added a test for this.

Ready for another look.

@kieckhafer kieckhafer requested a review from focusaurus July 25, 2019 04:23
Copy link
Contributor

@focusaurus focusaurus left a comment

Choose a reason for hiding this comment

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

Sorry for the noise, I re-reviewed pair with Eric D to learn his Jedi review techniques.

@kieckhafer
Copy link
Member Author

@focusaurus all comments addressed, ready for another look

@kieckhafer kieckhafer requested a review from focusaurus July 25, 2019 17:45
Signed-off-by: Erik Kieckhafer <[email protected]>
@kieckhafer kieckhafer merged commit cefd195 into develop Jul 26, 2019
@kieckhafer kieckhafer deleted the feat-kieckhafer-createRefundGQLMutation branch July 26, 2019 20:30
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