Skip to content

Commit

Permalink
Update elements options for deferred intent (#435)
Browse files Browse the repository at this point in the history
* Fix elements options for deferred intent

* Support camel or snake cased elements options params
  • Loading branch information
alexoser-stripe authored Mar 22, 2023
1 parent eaff4f3 commit dd3992b
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 3 deletions.
25 changes: 22 additions & 3 deletions tests/types/src/valid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,10 @@ const elements: StripeElements = stripe.elements({
mode: 'payment',
currency: 'usd',
amount: 1099,
setup_future_usage: 'off_session',
capture_method: 'automatic',
payment_method_types: ['card'],
setupFutureUsage: 'off_session',
captureMethod: 'automatic',
paymentMethodTypes: ['card'],
paymentMethodCreation: 'manual',
appearance: {
disableAnimations: false,
theme: 'night',
Expand All @@ -108,6 +109,15 @@ const elements: StripeElements = stripe.elements({
},
});

stripe.elements({
mode: 'setup',
currency: 'usd',
setup_future_usage: 'off_session',
capture_method: 'automatic',
payment_method_types: ['card'],
payment_method_creation: 'manual',
});

const elementsClientSecret: StripeElements = stripe.elements({
fonts: [OPEN_SANS, AVENIR],
locale: 'auto',
Expand Down Expand Up @@ -171,6 +181,15 @@ elements.update({
},
labels: 'floating',
},
mode: 'payment',
currency: 'usd',
amount: 1099,
setupFutureUsage: 'off_session',
captureMethod: 'automatic',
paymentMethodTypes: ['card'],
});

elements.update({
mode: 'payment',
currency: 'usd',
amount: 1099,
Expand Down
52 changes: 52 additions & 0 deletions types/stripe-js/elements-group.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -690,26 +690,57 @@ export interface StripeElementsOptionsMode extends BaseStripeElementsOptions {
*/
amount?: number;

/**
* Indicates that you intend to make future payments with this PaymentIntent’s payment method.
*
* @docs https://stripe.com/docs/api/payment_intents/create#create_payment_intent-setup_future_usage
*/
setupFutureUsage?: 'off_session' | 'on_session';

/**
* Indicates that you intend to make future payments with this PaymentIntent’s payment method.
*
* @docs https://stripe.com/docs/api/payment_intents/create#create_payment_intent-setup_future_usage
*/
setup_future_usage?: 'off_session' | 'on_session';

/**
* Controls when the funds will be captured from the customer’s account.
*
* @docs https://stripe.com/docs/api/payment_intents/create#create_payment_intent-capture_method
*/
captureMethod?: 'manual' | 'automatic';

/**
* Controls when the funds will be captured from the customer’s account.
*
* @docs https://stripe.com/docs/api/payment_intents/create#create_payment_intent-capture_method
*/
capture_method?: 'manual' | 'automatic';

/**
* Instead of using automatic payment methods, declare specific payment methods to enable.
*
* @docs https://stripe.com/docs/payments/payment-methods/overview
*/
paymentMethodTypes?: string[];

/**
* Instead of using automatic payment methods, declare specific payment methods to enable.
*
* @docs https://stripe.com/docs/payments/payment-methods/overview
*/
payment_method_types?: string[];

/**
* Allows PaymentMethods to be created from the Elements instance.
*/
paymentMethodCreation?: 'manual';

/**
* Allows PaymentMethods to be created from the Elements instance.
*/
payment_method_creation?: 'manual';
}

/*
Expand Down Expand Up @@ -746,13 +777,27 @@ export interface StripeElementsUpdateOptions {
*/
amount?: number;

/**
* Indicates that you intend to make future payments with this PaymentIntent’s payment method.
*
* @docs https://stripe.com/docs/api/payment_intents/create#create_payment_intent-setup_future_usage
*/
setupFutureUsage?: 'off_session' | 'on_session';

/**
* Indicates that you intend to make future payments with this PaymentIntent’s payment method.
*
* @docs https://stripe.com/docs/api/payment_intents/create#create_payment_intent-setup_future_usage
*/
setup_future_usage?: 'off_session' | 'on_session';

/**
* Controls when the funds will be captured from the customer’s account.
*
* @docs https://stripe.com/docs/api/payment_intents/create#create_payment_intent-capture_method
*/
captureMethod?: 'manual' | 'automatic';

/**
* Controls when the funds will be captured from the customer’s account.
*
Expand All @@ -766,6 +811,13 @@ export interface StripeElementsUpdateOptions {
* @docs https://stripe.com/docs/payments/payment-methods/overview
*/
payment_method_types?: string[];

/**
* Instead of using automatic payment methods, declare specific payment methods to enable.
*
* @docs https://stripe.com/docs/payments/payment-methods/overview
*/
paymentMethodTypes?: string[];
}

/*
Expand Down

0 comments on commit dd3992b

Please sign in to comment.