From 2fb3f0756c894969b27a45d0405b4b942547ce2f Mon Sep 17 00:00:00 2001 From: Remi Jannel Date: Sun, 16 Jun 2019 10:44:07 -0700 Subject: [PATCH] Add support for CustomerBalanceTransaction APIs --- lib/resources/Customers.js | 21 ++++++++++++ test/resources/Customers.spec.js | 55 ++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+) diff --git a/lib/resources/Customers.js b/lib/resources/Customers.js index 2c23989e1d..cc73e5e929 100644 --- a/lib/resources/Customers.js +++ b/lib/resources/Customers.js @@ -64,4 +64,25 @@ 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/test/resources/Customers.spec.js b/test/resources/Customers.spec.js index 57881bb790..ccf00123cb 100644 --- a/test/resources/Customers.spec.js +++ b/test/resources/Customers.spec.js @@ -371,4 +371,59 @@ describe('Customers Resource', () => { }); }); }); + + describe('BalanceTransaction methods', () => { + describe('retrieveBalanceTransaction', () => { + it('Sends the correct request', () => { + stripe.customers.retrieveBalanceTransaction('cus_123', 'cbtxn_123'); + expect(stripe.LAST_REQUEST).to.deep.equal({ + method: 'GET', + url: '/v1/customers/cus_123/balance_transactions/cbtxn_123', + headers: {}, + data: {}, + }); + }); + }); + + describe('createBalanceTransaction', () => { + it('Sends the correct request', () => { + stripe.customers.createBalanceTransaction('cus_123', { + amount: 123, + currency: 'usd', + }); + expect(stripe.LAST_REQUEST).to.deep.equal({ + method: 'POST', + url: '/v1/customers/cus_123/balance_transactions', + headers: {}, + data: {amount: 123, currency: 'usd'}, + }); + }); + }); + + describe('updateBalanceTransaction', () => { + it('Sends the correct request', () => { + stripe.customers.updateBalanceTransaction('cus_123', 'cbtxn_123', { + description: 'description', + }); + expect(stripe.LAST_REQUEST).to.deep.equal({ + method: 'POST', + url: '/v1/customers/cus_123/balance_transactions/cbtxn_123', + headers: {}, + data: {description: 'description'}, + }); + }); + }); + + describe('listBalanceTransactions', () => { + it('Sends the correct request', () => { + stripe.customers.listBalanceTransactions('cus_123'); + expect(stripe.LAST_REQUEST).to.deep.equal({ + method: 'GET', + url: '/v1/customers/cus_123/balance_transactions', + headers: {}, + data: {}, + }); + }); + }); + }); });