-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* pl - add Custom Checkout types * pl - add .vscode to .gitignore
- Loading branch information
1 parent
cac790b
commit b387cee
Showing
4 changed files
with
230 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ node_modules | |
dist | ||
*.log | ||
.vim | ||
.vscode/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,216 @@ | ||
import { | ||
LayoutObject, | ||
Layout, | ||
TermsOption, | ||
StripePaymentElement, | ||
} from './elements/payment'; | ||
import { | ||
AddressMode, | ||
ContactOption, | ||
StripeAddressElement, | ||
} from './elements/address'; | ||
import {Appearance, CssFontSource, CustomFontSource} from './elements-group'; | ||
|
||
/** | ||
* Requires beta access: | ||
* Contact [Stripe support](https://support.stripe.com/) for more information. | ||
*/ | ||
|
||
/** | ||
* StripeCustomCheckoutInitOptions | ||
*/ | ||
export interface StripeCustomCheckoutElementsOptions { | ||
appearance?: Appearance; | ||
loader?: 'auto' | 'always' | 'never'; | ||
fonts?: Array<CssFontSource | CustomFontSource>; | ||
} | ||
|
||
export interface StripeCustomCheckoutOptions { | ||
clientSecret: string; | ||
elementsOptions?: StripeCustomCheckoutElementsOptions; | ||
} | ||
|
||
/** | ||
* StripeCustomCheckoutActions | ||
*/ | ||
|
||
export type StripeCustomCheckoutAddress = { | ||
country: string | null; | ||
line1: string | null; | ||
line2?: string | null; | ||
city: string | null; | ||
postal_code: string | null; | ||
state: string | null; | ||
}; | ||
|
||
export type StripeCustomCheckoutShippingAddress = { | ||
name?: string | null; | ||
address: StripeCustomCheckoutAddress; | ||
}; | ||
|
||
export type StripeCustomCheckoutBillingAddress = StripeCustomCheckoutShippingAddress; | ||
|
||
export interface StripeCustomCheckoutActions { | ||
applyPromotionCode: (promotionCode: string) => Promise<void>; | ||
removePromotionCode: () => Promise<void>; | ||
updateShippingAddress: ( | ||
shippingAddress: StripeCustomCheckoutShippingAddress | ||
) => Promise<void>; | ||
updateBillingAddress: ( | ||
billingAddress: StripeCustomCheckoutBillingAddress | ||
) => Promise<void>; | ||
updatePhoneNumber: (phoneNumber: string) => void; | ||
updateEmail: (email: string) => void; | ||
updateLineItemQuantity: (args: { | ||
lineItem: string; | ||
quantity: number; | ||
}) => Promise<void>; | ||
updateShippingOption: (shippingOption: string) => Promise<void>; | ||
confirm: (args?: {return_url?: string}) => Promise<void>; | ||
} | ||
|
||
/** | ||
* StripeCustomCheckoutSession | ||
*/ | ||
|
||
export type StripeCustomCheckoutTaxAmount = { | ||
amount: number; | ||
inclusive: boolean; | ||
displayName: string; | ||
}; | ||
|
||
export type StripeCustomCheckoutDiscountAmount = { | ||
amount: number; | ||
displayName: string; | ||
promotionCode?: string | null; | ||
}; | ||
|
||
export type StripeCustomCheckoutShipping = { | ||
shippingOption: StripeCustomCheckoutShippingOption; | ||
taxAmounts?: Array<StripeCustomCheckoutTaxAmount> | null; | ||
}; | ||
|
||
export type StripeCustomCheckoutShippingOption = { | ||
id: string; | ||
amount: number; | ||
currency: string; | ||
displayName?: string | null; | ||
deliveryEstimate?: StripeCustomCheckoutDeliveryEstimate | null; | ||
}; | ||
|
||
export type StripeCustomCheckoutDeliveryEstimate = { | ||
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' | ||
| 'week' | ||
| 'year'; | ||
|
||
export type StripeCustomCheckoutLineItem = { | ||
id: string; | ||
name: string; | ||
amount: number; | ||
unitAmount: number; | ||
description?: string | null; | ||
quantity: number; | ||
discountAmounts?: Array<StripeCustomCheckoutLineItemDiscountAmount> | null; | ||
recurring?: { | ||
interval: StripeCustomCheckoutBillingInterval; | ||
interval_count: number; | ||
}; | ||
}; | ||
|
||
export type StripeCustomCheckoutTotalSummary = { | ||
subtotal: number; | ||
taxExclusive: number; | ||
taxInclusive: number; | ||
shippingRate: number; | ||
discount: number; | ||
total: number; | ||
}; | ||
|
||
export type StripeCustomCheckoutConfirmationRequirement = | ||
| 'phoneNumber' | ||
| 'shippingAddress' | ||
| 'billingAddress' | ||
| 'paymentDetails' | ||
| 'email'; | ||
|
||
export interface StripeCustomCheckoutSession { | ||
lineItems: Array<StripeCustomCheckoutLineItem>; | ||
taxAmounts?: Array<StripeCustomCheckoutTaxAmount> | null; | ||
discountAmounts?: Array<StripeCustomCheckoutDiscountAmount> | null; | ||
currency: string; | ||
shipping?: StripeCustomCheckoutShipping | null; | ||
shippingOptions: Array<StripeCustomCheckoutShippingOption>; | ||
shippingAddress?: StripeCustomCheckoutShippingAddress | null; | ||
billingAddress?: StripeCustomCheckoutBillingAddress | null; | ||
phoneNumber?: string | null; | ||
email?: string | null; | ||
total: StripeCustomCheckoutTotalSummary; | ||
confirmationRequirements: StripeCustomCheckoutConfirmationRequirement[]; | ||
canConfirm: boolean; | ||
} | ||
|
||
/** | ||
* StripeCustomCheckoutElements | ||
*/ | ||
export type StripeCustomCheckoutPaymentElementOptions = { | ||
layout?: Layout | LayoutObject; | ||
paymentMethodOrder?: Array<string>; | ||
readonly?: boolean; | ||
terms?: TermsOption; | ||
}; | ||
|
||
export type StripeCustomCheckoutAddressElementOptions = { | ||
mode: AddressMode; | ||
contacts?: ContactOption[]; | ||
display?: { | ||
name?: 'full' | 'split' | 'organization'; | ||
}; | ||
}; | ||
|
||
export interface StripeCustomCheckoutElementsActions { | ||
changeAppearance: (appearance: Appearance) => void; | ||
getElement(elementType: 'payment'): StripePaymentElement | null; | ||
getElement( | ||
elementType: 'address', | ||
mode: AddressMode | ||
): StripeAddressElement | null; | ||
createElement( | ||
elementType: 'payment', | ||
options?: StripeCustomCheckoutPaymentElementOptions | ||
): StripePaymentElement; | ||
createElement( | ||
elementType: 'address', | ||
options: StripeCustomCheckoutAddressElementOptions | ||
): StripeAddressElement; | ||
} | ||
|
||
/** | ||
* StripeCustomCheckout | ||
*/ | ||
export type StripeCustomCheckoutUpdateHandler = ( | ||
session: StripeCustomCheckoutSession | ||
) => void; | ||
|
||
export interface StripeCustomCheckout | ||
extends StripeCustomCheckoutActions, | ||
StripeCustomCheckoutSession, | ||
StripeCustomCheckoutElementsActions { | ||
session: () => StripeCustomCheckoutSession; | ||
on: (event: 'change', handler: StripeCustomCheckoutUpdateHandler) => void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters