Skip to content

add ability to cancel a payment intent#116

Open
OMFG5716 wants to merge 2 commits into
feathersjs-ecosystem:masterfrom
OMFG5716:feature/cancel-payment-intent
Open

add ability to cancel a payment intent#116
OMFG5716 wants to merge 2 commits into
feathersjs-ecosystem:masterfrom
OMFG5716:feature/cancel-payment-intent

Conversation

@OMFG5716

Copy link
Copy Markdown

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
Copy Markdown
Collaborator

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

@DaddyWarbucks

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

2 participants