diff --git a/lib/resources/Checkout/Sessions.js b/lib/resources/Checkout/Sessions.js index 91192db866..1cef4d65d7 100644 --- a/lib/resources/Checkout/Sessions.js +++ b/lib/resources/Checkout/Sessions.js @@ -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', diff --git a/test/resources/generated_examples_test.spec.js b/test/resources/generated_examples_test.spec.js index 564aef8ff5..30391141ed 100644 --- a/test/resources/generated_examples_test.spec.js +++ b/test/resources/generated_examples_test.spec.js @@ -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() { diff --git a/types/2020-08-27/Accounts.d.ts b/types/2020-08-27/Accounts.d.ts index 82c89356c5..f073afb6f9 100644 --- a/types/2020-08-27/Accounts.d.ts +++ b/types/2020-08-27/Accounts.d.ts @@ -1075,7 +1075,7 @@ declare module 'stripe' { expand?: Array; /** - * 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. */ @@ -2150,7 +2150,7 @@ declare module 'stripe' { expand?: Array; /** - * 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. */ diff --git a/types/2020-08-27/Checkout/Sessions.d.ts b/types/2020-08-27/Checkout/Sessions.d.ts index a49d686935..6248d77573 100644 --- a/types/2020-08-27/Checkout/Sessions.d.ts +++ b/types/2020-08-27/Checkout/Sessions.d.ts @@ -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 @@ -758,6 +763,8 @@ declare module 'stripe' { | 'ZZ'; } + type Status = 'complete' | 'expired' | 'open'; + type SubmitType = 'auto' | 'book' | 'donate' | 'pay'; interface TaxIdCollection { @@ -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. * @@ -1959,6 +1967,13 @@ declare module 'stripe' { subscription?: string; } + interface SessionExpireParams { + /** + * Specifies which fields in the response should be expanded. + */ + expand?: Array; + } + class SessionsResource { /** * Creates a Session object. @@ -1990,6 +2005,21 @@ declare module 'stripe' { ): ApiListPromise; list(options?: RequestOptions): ApiListPromise; + /** + * 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>; + expire( + id: string, + options?: RequestOptions + ): Promise>; + /** * 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. */ diff --git a/types/2020-08-27/InvoiceLineItems.d.ts b/types/2020-08-27/InvoiceLineItems.d.ts index 5df57d0899..3f5de646cb 100644 --- a/types/2020-08-27/InvoiceLineItems.d.ts +++ b/types/2020-08-27/InvoiceLineItems.d.ts @@ -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; } diff --git a/types/2020-08-27/Invoices.d.ts b/types/2020-08-27/Invoices.d.ts index b9af4d70bb..649e303003 100644 --- a/types/2020-08-27/Invoices.d.ts +++ b/types/2020-08-27/Invoices.d.ts @@ -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; } diff --git a/types/2020-08-27/Subscriptions.d.ts b/types/2020-08-27/Subscriptions.d.ts index 903e049f80..5af1624fdb 100644 --- a/types/2020-08-27/Subscriptions.d.ts +++ b/types/2020-08-27/Subscriptions.d.ts @@ -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; } @@ -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; } @@ -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; }