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

add ability to cancel a payment intent #116

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

OMFG5716
Copy link

Added additional condition in the patch method of the PaymentIntent service. It checks for a key "cancel" that is passed to the data arg.

Now, one can cancel a payment intent by doing so:

feathers.service('stripe/payment-intent').patch(id, { cancel: true });

@DaddyWarbucks
Copy link
Collaborator

Thanks for the PR! This looks good and I will try to get this deployed later today.

@DaddyWarbucks
Copy link
Collaborator

Sorry @OMFG5716 , on second look cancel is undefined.

You need to define the cancel var. This should be done like

const { capture, cancel, ...rest } = data;

on line

const { capture, ...rest } = data;

Also, please remove the returns between the if blocks for consistency.

It should look like

_patch (id, data, params) {
  const { stripe } = this.filterParams(params);
  const { capture, cancel, ...rest } = data;
  if (capture) {
    return this.stripe.paymentIntents.capture(id, stripe);
  }
  if (cancel) {
    return this.stripe.paymentIntents.cancel(id, stripe);
  }
  return this._update(id, rest, params);
}

@OMFG5716
Copy link
Author

Ok Gotcha, I think apart from canceling I've missed one more status update for a PaymentIntent. I'll try and add that too and make sure that's destructured like above. I'll push shortly.

@OMFG5716
Copy link
Author

Above fixes pushed! I meant, just like canceling, adding the ability to confirm a PaymentIntent, but I'll open a different PR for that I guess.

@DaddyWarbucks
Copy link
Collaborator

Thanks! Yea, another PR would be best because this repo automatically generates a CHANGELOG from PR's so that way it will be reflected there.
I will wait for the second PR before merging and publishing to NPM.

Thanks again!

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.

None yet

2 participants