Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API Updates #1292

Merged
merged 1 commit into from
Nov 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/resources/Checkout/Sessions.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ module.exports = StripeResource.extend({
methodType: 'list',
}),

expire: stripeMethod({
method: 'POST',
path: '/{session}/expire',
}),

listLineItems: stripeMethod({
method: 'GET',
path: '/{session}/line_items',
Expand Down
5 changes: 5 additions & 0 deletions test/resources/generated_examples_test.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,11 @@ describe('Checkout.Session', function() {
const sessions = await stripe.checkout.sessions.list({limit: 3});
expect(sessions).not.to.be.null;
});

it('expire method', async function() {
const session = await stripe.checkout.sessions.expire('sess_xyz');
expect(session).not.to.be.null;
});
});

describe('Coupon', function() {
Expand Down
4 changes: 2 additions & 2 deletions types/2020-08-27/Accounts.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1075,7 +1075,7 @@ declare module 'stripe' {
expand?: Array<string>;

/**
* A card or bank account to attach to the account for receiving [payouts](https://stripe.com/docs/connect/bank-debit-card-payouts) (you won't be able to use it for top-ups). You can provide either a token, like the ones returned by [Stripe.js](https://stripe.com/docs/stripe-js), or a dictionary, as documented in the `external_account` parameter for [bank account](https://stripe.com/docs/api#account_create_bank_account) creation.
* A card or bank account to attach to the account for receiving [payouts](https://stripe.com/docs/connect/bank-debit-card-payouts) (you won't be able to use it for top-ups). You can provide either a token, like the ones returned by [Stripe.js](https://stripe.com/docs/js), or a dictionary, as documented in the `external_account` parameter for [bank account](https://stripe.com/docs/api#account_create_bank_account) creation.
*
* By default, providing an external account sets it as the new default external account for its currency, and deletes the old default if one exists. To add additional external accounts without replacing the existing default for the currency, use the bank account or card creation API.
*/
Expand Down Expand Up @@ -2150,7 +2150,7 @@ declare module 'stripe' {
expand?: Array<string>;

/**
* A card or bank account to attach to the account for receiving [payouts](https://stripe.com/docs/connect/bank-debit-card-payouts) (you won't be able to use it for top-ups). You can provide either a token, like the ones returned by [Stripe.js](https://stripe.com/docs/stripe-js), or a dictionary, as documented in the `external_account` parameter for [bank account](https://stripe.com/docs/api#account_create_bank_account) creation.
* A card or bank account to attach to the account for receiving [payouts](https://stripe.com/docs/connect/bank-debit-card-payouts) (you won't be able to use it for top-ups). You can provide either a token, like the ones returned by [Stripe.js](https://stripe.com/docs/js), or a dictionary, as documented in the `external_account` parameter for [bank account](https://stripe.com/docs/api#account_create_bank_account) creation.
*
* By default, providing an external account sets it as the new default external account for its currency, and deletes the old default if one exists. To add additional external accounts without replacing the existing default for the currency, use the bank account or card creation API.
*/
Expand Down
32 changes: 31 additions & 1 deletion types/2020-08-27/Checkout/Sessions.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,11 @@ declare module 'stripe' {
*/
shipping_address_collection: Session.ShippingAddressCollection | null;

/**
* The status of the Checkout Session, one of `open`, `complete`, or `expired`.
*/
status: Session.Status | null;

/**
* Describes the type of transaction being performed by Checkout in order to customize
* relevant text on the page, such as the submit button. `submit_type` can only be
Expand Down Expand Up @@ -758,6 +763,8 @@ declare module 'stripe' {
| 'ZZ';
}

type Status = 'complete' | 'expired' | 'open';

type SubmitType = 'auto' | 'book' | 'donate' | 'pay';

interface TaxIdCollection {
Expand Down Expand Up @@ -885,7 +892,8 @@ declare module 'stripe' {
* on the Checkout page. In `subscription` mode, the customer's [default payment method](https://stripe.com/docs/api/customers/update#update_customer-invoice_settings-default_payment_method)
* will be used if it's a card, and otherwise the most recent card will be used. A valid billing address is required for Checkout to prefill the customer's card details.
*
* If the customer changes their email on the Checkout page, the Customer object will be updated with the new email.
* If the Customer already has a valid [email](https://stripe.com/docs/api/customers/object#customer_object-email) set, the email will be prefilled and not editable in Checkout.
* If the Customer does not have a valid `email`, Checkout will set the email entered during the session on the Customer.
*
* If blank for Checkout Sessions in `payment` or `subscription` mode, Checkout will create a new Customer object based on information provided during the payment flow.
*
Expand Down Expand Up @@ -1959,6 +1967,13 @@ declare module 'stripe' {
subscription?: string;
}

interface SessionExpireParams {
/**
* Specifies which fields in the response should be expanded.
*/
expand?: Array<string>;
}

class SessionsResource {
/**
* Creates a Session object.
Expand Down Expand Up @@ -1990,6 +2005,21 @@ declare module 'stripe' {
): ApiListPromise<Stripe.Checkout.Session>;
list(options?: RequestOptions): ApiListPromise<Stripe.Checkout.Session>;

/**
* A Session can be expired when it is in one of these statuses: open
*
* After it expires, a customer can't complete a Session and customers loading the Session see a message saying the Session is expired.
*/
expire(
id: string,
params?: SessionExpireParams,
options?: RequestOptions
): Promise<Stripe.Response<Stripe.Checkout.Session>>;
expire(
id: string,
options?: RequestOptions
): Promise<Stripe.Response<Stripe.Checkout.Session>>;

/**
* When retrieving a Checkout Session, there is an includable line_items property containing the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of line items.
*/
Expand Down
2 changes: 1 addition & 1 deletion types/2020-08-27/InvoiceLineItems.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ declare module 'stripe' {
subscription_trial_end?: 'now' | number;

/**
* Indicates if a plan's `trial_period_days` should be applied to the subscription. Setting `subscription_trial_end` per subscription is preferred, and this defaults to `false`. Setting this flag to `true` together with `subscription_trial_end` is not allowed.
* Indicates if a plan's `trial_period_days` should be applied to the subscription. Setting `subscription_trial_end` per subscription is preferred, and this defaults to `false`. Setting this flag to `true` together with `subscription_trial_end` is not allowed. See [Using trial periods on subscriptions](docs/billing/subscriptions/trials) to learn more.
*/
subscription_trial_from_plan?: boolean;
}
Expand Down
2 changes: 1 addition & 1 deletion types/2020-08-27/Invoices.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1497,7 +1497,7 @@ declare module 'stripe' {
subscription_trial_end?: 'now' | number;

/**
* Indicates if a plan's `trial_period_days` should be applied to the subscription. Setting `subscription_trial_end` per subscription is preferred, and this defaults to `false`. Setting this flag to `true` together with `subscription_trial_end` is not allowed.
* Indicates if a plan's `trial_period_days` should be applied to the subscription. Setting `subscription_trial_end` per subscription is preferred, and this defaults to `false`. Setting this flag to `true` together with `subscription_trial_end` is not allowed. See [Using trial periods on subscriptions](docs/billing/subscriptions/trials) to learn more.
*/
subscription_trial_from_plan?: boolean;
}
Expand Down
10 changes: 5 additions & 5 deletions types/2020-08-27/Subscriptions.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ declare module 'stripe' {
trial_end: number | null;

/**
* Indicates if a plan's `trial_period_days` should be applied to the subscription. Setting `trial_end` per subscription is preferred, and this defaults to `false`. Setting this flag to `true` together with `trial_end` is not allowed.
* Indicates if a plan's `trial_period_days` should be applied to the subscription. Setting `trial_end` per subscription is preferred, and this defaults to `false`. Setting this flag to `true` together with `trial_end` is not allowed. See [Using trial periods on subscriptions](docs/billing/subscriptions/trials) to learn more.
*/
trial_from_plan: boolean | null;
}
Expand Down Expand Up @@ -530,17 +530,17 @@ declare module 'stripe' {
transfer_data?: SubscriptionCreateParams.TransferData;

/**
* Unix timestamp representing the end of the trial period the customer will get before being charged for the first time. This will always overwrite any trials that might apply via a subscribed plan. If set, trial_end will override the default trial period of the plan the customer is being subscribed to. The special value `now` can be provided to end the customer's trial immediately. Can be at most two years from `billing_cycle_anchor`.
* Unix timestamp representing the end of the trial period the customer will get before being charged for the first time. This will always overwrite any trials that might apply via a subscribed plan. If set, trial_end will override the default trial period of the plan the customer is being subscribed to. The special value `now` can be provided to end the customer's trial immediately. Can be at most two years from `billing_cycle_anchor`. See [Using trial periods on subscriptions](docs/billing/subscriptions/trials) to learn more.
*/
trial_end?: 'now' | number;

/**
* Indicates if a plan's `trial_period_days` should be applied to the subscription. Setting `trial_end` per subscription is preferred, and this defaults to `false`. Setting this flag to `true` together with `trial_end` is not allowed.
* Indicates if a plan's `trial_period_days` should be applied to the subscription. Setting `trial_end` per subscription is preferred, and this defaults to `false`. Setting this flag to `true` together with `trial_end` is not allowed. See [Using trial periods on subscriptions](docs/billing/subscriptions/trials) to learn more.
*/
trial_from_plan?: boolean;

/**
* Integer representing the number of trial period days before the customer is charged for the first time. This will always overwrite any trials that might apply via a subscribed plan.
* Integer representing the number of trial period days before the customer is charged for the first time. This will always overwrite any trials that might apply via a subscribed plan. See [Using trial periods on subscriptions](docs/billing/subscriptions/trials) to learn more.
*/
trial_period_days?: number;
}
Expand Down Expand Up @@ -1013,7 +1013,7 @@ declare module 'stripe' {
trial_end?: 'now' | number;

/**
* Indicates if a plan's `trial_period_days` should be applied to the subscription. Setting `trial_end` per subscription is preferred, and this defaults to `false`. Setting this flag to `true` together with `trial_end` is not allowed.
* Indicates if a plan's `trial_period_days` should be applied to the subscription. Setting `trial_end` per subscription is preferred, and this defaults to `false`. Setting this flag to `true` together with `trial_end` is not allowed. See [Using trial periods on subscriptions](docs/billing/subscriptions/trials) to learn more.
*/
trial_from_plan?: boolean;
}
Expand Down