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

Update Custom Checkout types #500

Merged
merged 2 commits into from
Sep 12, 2023
Merged
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
58 changes: 26 additions & 32 deletions types/stripe-js/custom-checkout.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,19 @@ export interface StripeCustomCheckoutOptions {
*/

export type StripeCustomCheckoutAddress = {
country: string | null;
line1: string | null;
country: string;
line1?: string | null;
line2?: string | null;
city: string | null;
postal_code: string | null;
state: string | null;
city?: string | null;
postal_code?: string | null;
state?: string | null;
};

export type StripeCustomCheckoutShippingAddress = {
export type StripeCustomCheckoutContact = {
name?: string | null;
address: StripeCustomCheckoutAddress;
};

export type StripeCustomCheckoutBillingAddress = StripeCustomCheckoutShippingAddress;
export type StripeCustomCheckoutResult =
| {session: StripeCustomCheckoutSession; error?: undefined}
| {session?: undefined; error: StripeError};
Expand All @@ -60,10 +59,10 @@ export interface StripeCustomCheckoutActions {
) => Promise<StripeCustomCheckoutResult>;
removePromotionCode: () => Promise<StripeCustomCheckoutResult>;
updateShippingAddress: (
shippingAddress: StripeCustomCheckoutShippingAddress
shippingAddress: StripeCustomCheckoutContact
) => Promise<StripeCustomCheckoutResult>;
updateBillingAddress: (
billingAddress: StripeCustomCheckoutBillingAddress
billingAddress: StripeCustomCheckoutContact
) => Promise<StripeCustomCheckoutResult>;
updatePhoneNumber: (phoneNumber: string) => void;
updateEmail: (email: string) => void;
Expand Down Expand Up @@ -92,37 +91,32 @@ export type StripeCustomCheckoutTaxAmount = {
export type StripeCustomCheckoutDiscountAmount = {
amount: number;
displayName: string;
promotionCode?: string | null;
promotionCode: string | null;
};

export type StripeCustomCheckoutShipping = {
shippingOption: StripeCustomCheckoutShippingOption;
taxAmounts?: Array<StripeCustomCheckoutTaxAmount> | null;
taxAmounts: Array<StripeCustomCheckoutTaxAmount> | null;
};

export type StripeCustomCheckoutShippingOption = {
id: string;
amount: number;
currency: string;
displayName?: string | null;
deliveryEstimate?: StripeCustomCheckoutDeliveryEstimate | null;
displayName: string | null;
deliveryEstimate: StripeCustomCheckoutDeliveryEstimate | null;
};

export type StripeCustomCheckoutDeliveryEstimate = {
maximum?: StripeCustomCheckoutEstimate | null;
minimum?: StripeCustomCheckoutEstimate | null;
maximum: StripeCustomCheckoutEstimate | null;
minimum: StripeCustomCheckoutEstimate | null;
};

export type StripeCustomCheckoutEstimate = {
unit: 'business_day' | 'day' | 'hour' | 'week' | 'month';
value: number;
};

export type StripeCustomCheckoutLineItemDiscountAmount = {
amount: number;
promotionCode?: string | null;
};

export type StripeCustomCheckoutBillingInterval =
| 'day'
| 'month'
Expand All @@ -134,13 +128,14 @@ export type StripeCustomCheckoutLineItem = {
name: string;
amount: number;
unitAmount: number;
description?: string | null;
description: string | null;
quantity: number;
discountAmounts?: Array<StripeCustomCheckoutLineItemDiscountAmount> | null;
recurring?: {
discountAmounts: Array<StripeCustomCheckoutDiscountAmount> | null;
taxAmounts: Array<StripeCustomCheckoutTaxAmount> | null;
recurring: {
interval: StripeCustomCheckoutBillingInterval;
interval_count: number;
};
} | null;
};

export type StripeCustomCheckoutTotalSummary = {
Expand All @@ -161,15 +156,15 @@ export type StripeCustomCheckoutConfirmationRequirement =

export interface StripeCustomCheckoutSession {
lineItems: Array<StripeCustomCheckoutLineItem>;
taxAmounts?: Array<StripeCustomCheckoutTaxAmount> | null;
discountAmounts?: Array<StripeCustomCheckoutDiscountAmount> | null;
taxAmounts: Array<StripeCustomCheckoutTaxAmount> | null;
discountAmounts: Array<StripeCustomCheckoutDiscountAmount> | null;
currency: string;
shipping?: StripeCustomCheckoutShipping | null;
shipping: StripeCustomCheckoutShipping | null;
shippingOptions: Array<StripeCustomCheckoutShippingOption>;
shippingAddress?: StripeCustomCheckoutShippingAddress | null;
billingAddress?: StripeCustomCheckoutBillingAddress | null;
phoneNumber?: string | null;
email?: string | null;
shippingAddress: StripeCustomCheckoutContact | null;
billingAddress: StripeCustomCheckoutContact | null;
phoneNumber: string | null;
email: string | null;
total: StripeCustomCheckoutTotalSummary;
confirmationRequirements: StripeCustomCheckoutConfirmationRequirement[];
canConfirm: boolean;
Expand Down Expand Up @@ -219,7 +214,6 @@ export type StripeCustomCheckoutUpdateHandler = (

export interface StripeCustomCheckout
extends StripeCustomCheckoutActions,
StripeCustomCheckoutSession,
StripeCustomCheckoutElementsActions {
session: () => StripeCustomCheckoutSession;
on: (event: 'change', handler: StripeCustomCheckoutUpdateHandler) => void;
Expand Down
Loading