forked from stripe/stripe-node
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Issuing API calls, create a 'StripeNamespace' to accommmodate the…
… structure
- Loading branch information
1 parent
079dbd6
commit d0d3f87
Showing
13 changed files
with
495 additions
and
17 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,22 @@ | ||
'use strict'; | ||
|
||
// ResourceNamespace allows you to create nested resources, i.e. `stripe.issuing.cards`. | ||
// It also works recursively, so you could do i.e. `stripe.billing.invoicing.pay`. | ||
|
||
function ResourceNamespace(stripe, resources) { | ||
for (var name in resources) { | ||
var camelCaseName = name[0].toLowerCase() + name.substring(1); | ||
|
||
var resource = new resources[name](stripe); | ||
|
||
this[camelCaseName] = resource; | ||
} | ||
} | ||
|
||
module.exports = function(namespace, resources) { | ||
return function (stripe) { | ||
return new ResourceNamespace(stripe, resources); | ||
}; | ||
}; | ||
|
||
module.exports.ResourceNamespace = ResourceNamespace; |
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,22 @@ | ||
'use strict'; | ||
|
||
var StripeResource = require('../../StripeResource'); | ||
var stripeMethod = StripeResource.method; | ||
|
||
module.exports = StripeResource.extend({ | ||
path: 'issuing/authorizations', | ||
|
||
includeBasic: ['list', 'retrieve', 'update', 'setMetadata', 'getMetadata'], | ||
|
||
approve: stripeMethod({ | ||
method: 'POST', | ||
path: '/{id}/approve', | ||
urlParams: ['id'], | ||
}), | ||
|
||
decline: stripeMethod({ | ||
method: 'POST', | ||
path: '/{id}/decline', | ||
urlParams: ['id'], | ||
}), | ||
}); |
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,8 @@ | ||
'use strict'; | ||
|
||
var StripeResource = require('../../StripeResource'); | ||
|
||
module.exports = StripeResource.extend({ | ||
path: 'issuing/cardholders', | ||
includeBasic: ['create', 'list', 'retrieve', 'update', 'setMetadata', 'getMetadata'], | ||
}); |
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,16 @@ | ||
'use strict'; | ||
|
||
var StripeResource = require('../../StripeResource'); | ||
var stripeMethod = StripeResource.method; | ||
|
||
module.exports = StripeResource.extend({ | ||
path: 'issuing/cards', | ||
|
||
includeBasic: ['create', 'list', 'retrieve', 'update', 'setMetadata', 'getMetadata'], | ||
|
||
retrieveDetails: stripeMethod({ | ||
method: 'GET', | ||
path: '/{id}/details', | ||
urlParams: ['id'], | ||
}), | ||
}); |
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,8 @@ | ||
'use strict'; | ||
|
||
var StripeResource = require('../../StripeResource'); | ||
|
||
module.exports = StripeResource.extend({ | ||
path: 'issuing/disputes', | ||
includeBasic: ['create', 'list', 'retrieve', 'update', 'setMetadata', 'getMetadata'], | ||
}); |
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,8 @@ | ||
'use strict'; | ||
|
||
var StripeResource = require('../../StripeResource'); | ||
|
||
module.exports = StripeResource.extend({ | ||
path: 'issuing/transactions', | ||
includeBasic: ['list', 'retrieve', 'update', 'setMetadata', 'getMetadata'], | ||
}); |
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,78 @@ | ||
'use strict'; | ||
|
||
var stripe = require('../../testUtils').getSpyableStripe(); | ||
var expect = require('chai').expect; | ||
|
||
describe('Issuing', function () { | ||
describe('Authorization Resource', function() { | ||
describe('retrieve', function() { | ||
it('Sends the correct request', function() { | ||
stripe.issuing.authorizations.retrieve('iauth_123'); | ||
expect(stripe.LAST_REQUEST).to.deep.equal({ | ||
method: 'GET', | ||
url: '/v1/issuing/authorizations/iauth_123', | ||
data: {}, | ||
headers: {}, | ||
}); | ||
}); | ||
}); | ||
|
||
describe('list', function() { | ||
it('Sends the correct request', function() { | ||
stripe.issuing.authorizations.list(); | ||
expect(stripe.LAST_REQUEST).to.deep.equal({ | ||
method: 'GET', | ||
url: '/v1/issuing/authorizations', | ||
data: {}, | ||
headers: {}, | ||
}); | ||
}); | ||
}); | ||
|
||
describe('update', function() { | ||
it('Sends the correct request', function() { | ||
stripe.issuing.authorizations.update('iauth_123', { | ||
metadata: { | ||
thing1: true, | ||
thing2: 'yes' | ||
}, | ||
}); | ||
expect(stripe.LAST_REQUEST).to.deep.equal({ | ||
method: 'POST', | ||
url: '/v1/issuing/authorizations/iauth_123', | ||
headers: {}, | ||
data: { | ||
metadata: { | ||
thing1: true, | ||
thing2: 'yes' | ||
}, | ||
}, | ||
}); | ||
}); | ||
}); | ||
|
||
describe('approve', function() { | ||
it('Sends the correct request', function() { | ||
stripe.issuing.authorizations.approve('iauth_123'); | ||
expect(stripe.LAST_REQUEST).to.deep.equal({ | ||
method: 'POST', | ||
url: '/v1/issuing/authorizations/iauth_123/approve', | ||
headers: {}, | ||
data: {}, | ||
}); | ||
}); | ||
}); | ||
|
||
describe('decline', function() { | ||
it('Sends the correct request', function() { | ||
stripe.issuing.authorizations.decline('iauth_123'); | ||
expect(stripe.LAST_REQUEST).to.deep.equal({ | ||
method: 'POST', | ||
url: '/v1/issuing/authorizations/iauth_123/decline', | ||
headers: {}, | ||
data: {}, | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
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,76 @@ | ||
'use strict'; | ||
|
||
var stripe = require('../../testUtils').getSpyableStripe(); | ||
|
||
var expect = require('chai').expect; | ||
|
||
describe('Issuing', function () { | ||
describe('Cardholders Resource', function () { | ||
describe('retrieve', function () { | ||
it('Sends the correct request', function () { | ||
stripe.issuing.cardholders.retrieve('ich_123'); | ||
|
||
expect(stripe.LAST_REQUEST).to.deep.equal({ | ||
method: 'GET', | ||
url: '/v1/issuing/cardholders/ich_123', | ||
headers: {}, | ||
data: {}, | ||
}); | ||
}); | ||
}); | ||
|
||
describe('create', function () { | ||
it('Sends the correct request', function () { | ||
stripe.issuing.cardholders.create({ | ||
billing: {}, | ||
name: 'Tim Testperson', | ||
type: 'individual', | ||
}); | ||
expect(stripe.LAST_REQUEST).to.deep.equal({ | ||
method: 'POST', | ||
url: '/v1/issuing/cardholders', | ||
headers: {}, | ||
data: { | ||
billing: {}, | ||
name: 'Tim Testperson', | ||
type: 'individual', | ||
}, | ||
}); | ||
}); | ||
}); | ||
|
||
describe('update', function () { | ||
it('Sends the correct request', function () { | ||
stripe.issuing.cardholders.update('ich_123', { | ||
metadata: { | ||
thing1: true, | ||
thing2: 'yes' | ||
}, | ||
}); | ||
expect(stripe.LAST_REQUEST).to.deep.equal({ | ||
method: 'POST', | ||
url: '/v1/issuing/cardholders/ich_123', | ||
headers: {}, | ||
data: { | ||
metadata: { | ||
thing1: true, | ||
thing2: 'yes' | ||
}, | ||
}, | ||
}); | ||
}); | ||
}); | ||
|
||
describe('list', function () { | ||
it('Sends the correct request', function () { | ||
stripe.issuing.cardholders.list(); | ||
expect(stripe.LAST_REQUEST).to.deep.equal({ | ||
method: 'GET', | ||
url: '/v1/issuing/cardholders', | ||
headers: {}, | ||
data: {}, | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
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,89 @@ | ||
'use strict'; | ||
|
||
var stripe = require('../../testUtils').getSpyableStripe(); | ||
|
||
var expect = require('chai').expect; | ||
|
||
describe('Issuing', function () { | ||
describe('Cards Resource', function () { | ||
describe('retrieve', function () { | ||
it('Sends the correct request', function () { | ||
stripe.issuing.cards.retrieve('ic_123'); | ||
|
||
expect(stripe.LAST_REQUEST).to.deep.equal({ | ||
method: 'GET', | ||
url: '/v1/issuing/cards/ic_123', | ||
headers: {}, | ||
data: {}, | ||
}); | ||
}); | ||
}); | ||
|
||
describe('create', function () { | ||
it('Sends the correct request', function () { | ||
stripe.issuing.cards.create({ | ||
currency: 'usd', | ||
type: 'physical', | ||
}); | ||
expect(stripe.LAST_REQUEST).to.deep.equal({ | ||
method: 'POST', | ||
url: '/v1/issuing/cards', | ||
headers: {}, | ||
data: { | ||
currency: 'usd', | ||
type: 'physical', | ||
}, | ||
}); | ||
}); | ||
}); | ||
|
||
describe('update', function () { | ||
it('Sends the correct request', function () { | ||
stripe.issuing.cards.update('ic_123', { | ||
metadata: { | ||
thing1: true, | ||
thing2: 'yes' | ||
}, | ||
}); | ||
expect(stripe.LAST_REQUEST).to.deep.equal({ | ||
method: 'POST', | ||
url: '/v1/issuing/cards/ic_123', | ||
headers: {}, | ||
data: { | ||
metadata: { | ||
thing1: true, | ||
thing2: 'yes' | ||
}, | ||
}, | ||
}); | ||
}); | ||
}); | ||
|
||
describe('list', function () { | ||
it('Sends the correct request', function () { | ||
stripe.issuing.cards.list(); | ||
expect(stripe.LAST_REQUEST).to.deep.equal({ | ||
method: 'GET', | ||
url: '/v1/issuing/cards', | ||
headers: {}, | ||
data: {}, | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('Virtual Cards Resource', function () { | ||
describe('retrieve', function () { | ||
it('Sends the correct request', function () { | ||
stripe.issuing.cards.retrieveDetails('ic_123'); | ||
|
||
expect(stripe.LAST_REQUEST).to.deep.equal({ | ||
method: 'GET', | ||
url: '/v1/issuing/cards/ic_123/details', | ||
headers: {}, | ||
data: {}, | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.