-
Notifications
You must be signed in to change notification settings - Fork 751
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for Customer Balance Transaction resource and APIs
- Loading branch information
1 parent
3f7b135
commit 3f09b5f
Showing
5 changed files
with
150 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
'use strict'; | ||
|
||
var StripeResource = require('../StripeResource'); | ||
|
||
/** | ||
* CustomerBalanceTransactions is a unique resource in that, upon instantiation, | ||
* requires a customerId, and therefore each of its methods only | ||
* require the transactionId argument. | ||
* | ||
* This streamlines the API specifically for the case of accessing a customer balance tranaction | ||
* on a returned customer object. | ||
* | ||
* E.g. customerObject.transactions.retrieve(transactionId) | ||
* (As opposed to the also-supported stripe.customers.retrieveTaxId(customerId, transactionId)) | ||
*/ | ||
module.exports = StripeResource.extend({ | ||
path: 'customers/{customerId}/customer_balance_transactions', | ||
includeBasic: ['create', 'list', 'retrieve'], | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
'use strict'; | ||
|
||
var resources = require('../../lib/stripe').resources; | ||
var stripe = require('../../testUtils').getSpyableStripe(); | ||
var expect = require('chai').expect; | ||
|
||
var CUSTOMER_TEST_ID = 'cus_123'; | ||
var TRANSACTION_TEST_ID = 'cbtxn_123'; | ||
|
||
var taxId = new resources.CustomerBalanceTransactions( | ||
stripe, | ||
{customerId: CUSTOMER_TEST_ID} | ||
); | ||
|
||
// Use spy from existing resource: | ||
taxId._request = stripe.customers._request; | ||
|
||
describe('CustomerBalanceTransaction Resource', function() { | ||
describe('create', function() { | ||
it('Sends the correct request', function() { | ||
var data = { | ||
amount: 1234, | ||
currency: 'usd', | ||
}; | ||
taxId.create(data); | ||
expect(stripe.LAST_REQUEST).to.deep.equal({ | ||
method: 'POST', | ||
url: '/v1/customers/' + CUSTOMER_TEST_ID + '/customer_balance_transactions', | ||
data: data, | ||
headers: {}, | ||
}); | ||
}); | ||
}); | ||
|
||
describe('list', function() { | ||
it('Sends the correct request', function() { | ||
taxId.list(); | ||
expect(stripe.LAST_REQUEST).to.deep.equal({ | ||
method: 'GET', | ||
url: '/v1/customers/' + CUSTOMER_TEST_ID + '/customer_balance_transactions', | ||
data: {}, | ||
headers: {}, | ||
}); | ||
}); | ||
}); | ||
|
||
describe('retrieve', function() { | ||
it('Sends the correct request', function() { | ||
taxId.retrieve(TRANSACTION_TEST_ID); | ||
expect(stripe.LAST_REQUEST).to.deep.equal({ | ||
method: 'GET', | ||
url: '/v1/customers/' + CUSTOMER_TEST_ID + '/customer_balance_transactions/' + TRANSACTION_TEST_ID, | ||
data: {}, | ||
headers: {}, | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters