Skip to content

Commit

Permalink
Add support for CustomerBalanceTransaction APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
remi-stripe committed Jun 17, 2019
1 parent e542902 commit 2fb3f07
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 0 deletions.
21 changes: 21 additions & 0 deletions lib/resources/Customers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}',
}),
});
55 changes: 55 additions & 0 deletions test/resources/Customers.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {},
});
});
});
});
});

0 comments on commit 2fb3f07

Please sign in to comment.