Repository: stripe/stripe-node
Pull request #653 (2019-06-28 00:02:29)

Reorder customer methods for codegen
r? @ob-stripe 
cc @remi-stripe 
cc @stripe/api-libraries 

Should be a noop for users, just a reshuffle to match codegen.


Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index acd161c7..b616ef10 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,8 @@
 # CHANGELOG
 
+## 7.4.0 - 2019-06-27
+* [#652](https://github.com/stripe/stripe-node/pull/652) Add support for the `SetupIntent` resource and APIs
+
 ## 7.3.0 - 2019-06-24
 * [#649](https://github.com/stripe/stripe-node/pull/649) Enable request latency telemetry by default
 
diff --git a/VERSION b/VERSION
index 15020207..ba7f754d 100644
--- a/VERSION
+++ b/VERSION
@@ -1,1 +1,1 @@
-7.3.0
+7.4.0
diff --git a/lib/resources.js b/lib/resources.js
index c491e28b..890f5f68 100644
--- a/lib/resources.js
+++ b/lib/resources.js
@@ -37,6 +37,7 @@ module.exports = {
   Recipients: require('./resources/Recipients'),
   Refunds: require('./resources/Refunds'),
   Reviews: require('./resources/Reviews'),
+  SetupIntents: require('./resources/SetupIntents'),
   Skus: require('./resources/SKUs'),
   Sources: require('./resources/Sources'),
   Subscriptions: require('./resources/Subscriptions'),
diff --git a/lib/resources/Customers.js b/lib/resources/Customers.js
index cc73e5e9..e4537002 100644
--- a/lib/resources/Customers.js
+++ b/lib/resources/Customers.js
@@ -28,6 +28,27 @@ module.exports = StripeResource.extend({
     path: '/{customer}/sources/{sourceId}/verify',
   }),
 
+  createBalanceTransaction: stripeMethod({
+    method: 'POST',
+    path: '/{customer}/balance_transactions',
+  }),
+
+  listBalanceTransactions: stripeMethod({
+    method: 'GET',
+    path: '/{customer}/balance_transactions',
+    methodType: 'list',
+  }),
+
+  retrieveBalanceTransaction: stripeMethod({
+    method: 'GET',
+    path: '/{customer}/balance_transactions/{transaction}',
+  }),
+
+  updateBalanceTransaction: stripeMethod({
+    method: 'POST',
+    path: '/{customer}/balance_transactions/{transaction}',
+  }),
+
   createSource: stripeMethod({
     method: 'POST',
     path: '/{customer}/sources',
@@ -64,25 +85,4 @@ module.exports = StripeResource.extend({
     method: 'GET',
     path: '/{customer}/tax_ids/{id}',
   }),
-
-  createBalanceTransaction: stripeMethod({
-    method: 'POST',
-    path: '/{customer}/balance_transactions',
-  }),
-
-  listBalanceTransactions: stripeMethod({
-    method: 'GET',
-    path: '/{customer}/balance_transactions',
-    methodType: 'list',
-  }),
-
-  retrieveBalanceTransaction: stripeMethod({
-    method: 'GET',
-    path: '/{customer}/balance_transactions/{id}',
-  }),
-
-  updateBalanceTransaction: stripeMethod({
-    method: 'POST',
-    path: '/{customer}/balance_transactions/{id}',
-  }),
 });
diff --git a/lib/resources/SetupIntents.js b/lib/resources/SetupIntents.js
new file mode 100644
index 00000000..9255cda1
--- /dev/null
+++ b/lib/resources/SetupIntents.js
@@ -0,0 +1,20 @@
+'use strict';
+
+const StripeResource = require('../StripeResource');
+const stripeMethod = StripeResource.method;
+
+module.exports = StripeResource.extend({
+  path: 'setup_intents',
+
+  includeBasic: ['create', 'list', 'retrieve', 'update'],
+
+  cancel: stripeMethod({
+    method: 'POST',
+    path: '/{intent}/cancel',
+  }),
+
+  confirm: stripeMethod({
+    method: 'POST',
+    path: '/{intent}/confirm',
+  }),
+});
diff --git a/package.json b/package.json
index 89bef5eb..35f492ab 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "stripe",
-  "version": "7.3.0",
+  "version": "7.4.0",
   "description": "Stripe API wrapper",
   "keywords": [
     "stripe",


Test patch:
diff --git a/test/resources/SetupIntents.spec.js b/test/resources/SetupIntents.spec.js
new file mode 100644
index 00000000..d4d23a2c
--- /dev/null
+++ b/test/resources/SetupIntents.spec.js
@@ -0,0 +1,85 @@
+'use strict';
+
+const stripe = require('../../testUtils').getSpyableStripe();
+const expect = require('chai').expect;
+
+const SETUP_INTENT_TEST_ID = 'seti_123';
+
+describe('Setup Intents Resource', () => {
+  describe('create', () => {
+    it('Sends the correct request', () => {
+      const params = {
+        payment_method_types: ['card'],
+      };
+      stripe.setupIntents.create(params);
+      expect(stripe.LAST_REQUEST).to.deep.equal({
+        method: 'POST',
+        url: '/v1/setup_intents',
+        headers: {},
+        data: params,
+      });
+    });
+  });
+
+  describe('list', () => {
+    it('Sends the correct request', () => {
+      stripe.setupIntents.list();
+      expect(stripe.LAST_REQUEST).to.deep.equal({
+        method: 'GET',
+        url: '/v1/setup_intents',
+        headers: {},
+        data: {},
+      });
+    });
+  });
+
+  describe('retrieve', () => {
+    it('Sends the correct request', () => {
+      stripe.setupIntents.retrieve(SETUP_INTENT_TEST_ID);
+      expect(stripe.LAST_REQUEST).to.deep.equal({
+        method: 'GET',
+        url: `/v1/setup_intents/${SETUP_INTENT_TEST_ID}`,
+        headers: {},
+        data: {},
+      });
+    });
+  });
+
+  describe('update', () => {
+    it('Sends the correct request', () => {
+      stripe.setupIntents.update(SETUP_INTENT_TEST_ID, {
+        metadata: {key: 'value'},
+      });
+      expect(stripe.LAST_REQUEST).to.deep.equal({
+        method: 'POST',
+        url: `/v1/setup_intents/${SETUP_INTENT_TEST_ID}`,
+        headers: {},
+        data: {metadata: {key: 'value'}},
+      });
+    });
+  });
+
+  describe('cancel', () => {
+    it('Sends the correct request', () => {
+      stripe.setupIntents.cancel(SETUP_INTENT_TEST_ID);
+      expect(stripe.LAST_REQUEST).to.deep.equal({
+        method: 'POST',
+        url: `/v1/setup_intents/${SETUP_INTENT_TEST_ID}/cancel`,
+        headers: {},
+        data: {},
+      });
+    });
+  });
+
+  describe('confirm', () => {
+    it('Sends the correct request', () => {
+      stripe.setupIntents.confirm(SETUP_INTENT_TEST_ID);
+      expect(stripe.LAST_REQUEST).to.deep.equal({
+        method: 'POST',
+        url: `/v1/setup_intents/${SETUP_INTENT_TEST_ID}/confirm`,
+        headers: {},
+        data: {},
+      });
+    });
+  });
+});