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.
Merge pull request stripe#874 from stripe/remi/codegen-824d494
Add support for `billingPortal` namespace and `session` resource and APIs
- Loading branch information
Showing
8 changed files
with
119 additions
and
6 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,9 @@ | ||
'use strict'; | ||
|
||
const StripeResource = require('../../StripeResource'); | ||
|
||
module.exports = StripeResource.extend({ | ||
path: 'billing_portal/sessions', | ||
|
||
includeBasic: ['create'], | ||
}); |
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,27 @@ | ||
'use strict'; | ||
|
||
const stripe = require('../../../testUtils').getSpyableStripe(); | ||
|
||
const expect = require('chai').expect; | ||
|
||
describe('BillingPortal', () => { | ||
describe('Sessions Resource', () => { | ||
describe('create', () => { | ||
it('Sends the correct request', () => { | ||
const params = { | ||
customer: 'cus_123', | ||
return_url: 'https://stripe.com/return', | ||
}; | ||
stripe.billingPortal.sessions.create(params); | ||
|
||
expect(stripe.LAST_REQUEST).to.deep.equal({ | ||
method: 'POST', | ||
url: '/v1/billing_portal/sessions', | ||
headers: {}, | ||
data: params, | ||
settings: {}, | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
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,72 @@ | ||
declare module 'stripe' { | ||
namespace Stripe { | ||
namespace BillingPortal { | ||
/** | ||
* The Session object. | ||
*/ | ||
interface Session { | ||
/** | ||
* Unique identifier for the object. | ||
*/ | ||
id: string; | ||
|
||
/** | ||
* String representing the object's type. Objects of the same type share the same value. | ||
*/ | ||
object: 'billing_portal.session'; | ||
|
||
/** | ||
* Time at which the object was created. Measured in seconds since the Unix epoch. | ||
*/ | ||
created: number; | ||
|
||
/** | ||
* The ID of the customer for this session. | ||
*/ | ||
customer: string; | ||
|
||
/** | ||
* Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode. | ||
*/ | ||
livemode: boolean; | ||
|
||
/** | ||
* The URL to which Stripe should send customers when they click on the link to return to your website. | ||
*/ | ||
return_url: string; | ||
|
||
/** | ||
* The short-lived URL of the session giving customers access to the self-serve portal. | ||
*/ | ||
url: string; | ||
} | ||
|
||
interface SessionCreateParams { | ||
/** | ||
* The ID of an existing customer. | ||
*/ | ||
customer: string; | ||
|
||
/** | ||
* Specifies which fields in the response should be expanded. | ||
*/ | ||
expand?: Array<string>; | ||
|
||
/** | ||
* The URL to which Stripe should send customers when they click on the link to return to your website. This field is required if a default return URL has not been configured for the portal. | ||
*/ | ||
return_url?: string; | ||
} | ||
|
||
class SessionsResource { | ||
/** | ||
* Creates a session of the Self-service Portal. | ||
*/ | ||
create( | ||
params: SessionCreateParams, | ||
options?: RequestOptions | ||
): Promise<Stripe.BillingPortal.Session>; | ||
} | ||
} | ||
} | ||
} |
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
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