From 5739fc3ae8c54f3e26858fbaee51896e15cb2142 Mon Sep 17 00:00:00 2001 From: Jivanysh Sohoni Date: Sun, 17 Apr 2022 12:00:33 +0530 Subject: [PATCH 1/2] add ability to cancel a payment intent --- lib/services/payment-intent.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/services/payment-intent.js b/lib/services/payment-intent.js index 2c87833..89a02de 100644 --- a/lib/services/payment-intent.js +++ b/lib/services/payment-intent.js @@ -25,6 +25,11 @@ module.exports = class Service extends Base { if (capture) { return this.stripe.paymentIntents.capture(id, stripe); } + + if (cancel) { + return this.stripe.paymentIntents.cancel(id, stripe); + } + return this._update(id, rest, params); } From 4262e01c15d6f9c68c61dfca407309261d0d8f70 Mon Sep 17 00:00:00 2001 From: Jivanysh Sohoni Date: Thu, 21 Apr 2022 00:22:00 +0530 Subject: [PATCH 2/2] fix cancel not destructured above and remove returns after if blocks --- lib/services/payment-intent.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/services/payment-intent.js b/lib/services/payment-intent.js index 89a02de..3524d50 100644 --- a/lib/services/payment-intent.js +++ b/lib/services/payment-intent.js @@ -21,15 +21,13 @@ module.exports = class Service extends Base { _patch (id, data, params) { const { stripe } = this.filterParams(params); - const { capture, ...rest } = data; + 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); }