-
Notifications
You must be signed in to change notification settings - Fork 750
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 the
SetupIntent
resource and APIs
- Loading branch information
1 parent
de7b272
commit 44e9b54
Showing
3 changed files
with
106 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
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,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', | ||
}), | ||
}); |
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,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: {}, | ||
}); | ||
}); | ||
}); | ||
}); |