From b1a192dc681f1378911be7a4e73159a2e0d229d9 Mon Sep 17 00:00:00 2001 From: Polo Li <65737086+pololi-stripe@users.noreply.github.com> Date: Wed, 9 Oct 2024 13:36:13 -0700 Subject: [PATCH] pl - add onLineItemsChange option for embeddedCheckout (#665) --- types/stripe-js/embedded-checkout.d.ts | 30 ++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/types/stripe-js/embedded-checkout.d.ts b/types/stripe-js/embedded-checkout.d.ts index 6a1af394..ef03f35c 100644 --- a/types/stripe-js/embedded-checkout.d.ts +++ b/types/stripe-js/embedded-checkout.d.ts @@ -17,6 +17,29 @@ export type StripeEmbeddedCheckoutShippingDetailsChangeEvent = { shippingDetails: StripeEmbeddedCheckoutShippingDetails; }; +export type StripeEmbeddedCheckoutLineItem = { + id?: string; + quantity?: number; + price?: string; + display?: { + name?: string; + description?: string; + images?: string[]; + }; + pricingSpec?: { + unitAmount?: number; + unitAmountDecimal?: string; + currency?: string; + taxBehavior?: 'inclusive' | 'exclusive' | 'unspecified'; + taxCode?: string; + }; +}; + +export type StripeEmbeddedCheckoutLineItemsChangeEvent = { + checkoutSessionId: string; + lineItems: StripeEmbeddedCheckoutLineItem[]; +}; + export type ResultAction = | {type: 'accept'} | {type: 'reject'; errorMessage?: string}; @@ -45,6 +68,13 @@ export interface StripeEmbeddedCheckoutOptions { onShippingDetailsChange?: ( event: StripeEmbeddedCheckoutShippingDetailsChangeEvent ) => Promise; + /** + * onLineItemsChange is called when the customer adds, removes, or modifies a line item. + * The callback is required when [permissions.update.line_items](https://docs.stripe.com/api/checkout/sessions/create#create_checkout_session-permissions-update-line_items) is set to `server_only`. + */ + onLineItemsChange?: ( + event: StripeEmbeddedCheckoutLineItemsChangeEvent + ) => Promise; } export interface StripeEmbeddedCheckout {