Skip to content

Commit

Permalink
Add paymentMethodOrder option to paymentMethodMessaging element types (
Browse files Browse the repository at this point in the history
  • Loading branch information
sawyer-stripe committed Sep 13, 2024
1 parent 01b5871 commit 7d14c55
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tests/types/src/invalid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -443,3 +443,11 @@ paymentRequest.update({
// @ts-expect-error Object literal may only specify known properties, and 'onBehalfOf' does not exist in type 'PaymentRequestUpdateOptions'.
onBehalfOf: 'acct_123',
});

// @ts-expect-error: No overload matches this call
elements.create('paymentMethodMessaging', {
amount: 2000,
countryCode: 'US',
currency: 'USD',
paymentMethodOrder: ['invalid_type'],
});
7 changes: 7 additions & 0 deletions tests/types/src/valid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,13 @@ elements.create('paymentMethodMessaging', {
paymentMethodTypes: ['afterpay_clearpay', 'klarna', 'affirm'],
});

elements.create('paymentMethodMessaging', {
amount: 2000,
countryCode: 'US',
currency: 'USD',
paymentMethodOrder: ['klarna'],
});

const paymentElement: StripePaymentElement = elements.create('payment', {
defaultValues: {
billingDetails: {
Expand Down
6 changes: 6 additions & 0 deletions types/stripe-js/elements/payment-method-messaging.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ export interface StripePaymentMethodMessagingElementOptions {
*/
paymentMethodTypes?: Array<'afterpay_clearpay' | 'klarna' | 'affirm'>;

/**
* Override the order in which payment methods are displayed in the Payment Method Messaging Element.
* By default, the Payment Method Messaging Element will use a dynamic ordering that optimizes payment method display for each user.
*/
paymentMethodOrder?: Array<'afterpay_clearpay' | 'klarna' | 'affirm'>;

/**
* @deprecated Use `paymentMethodTypes` instead.
*/
Expand Down

0 comments on commit 7d14c55

Please sign in to comment.