@@ -9,8 +9,6 @@ import type {
99 StripeCardExpiryElementOptions ,
1010 StripeCardNumberElementOptions ,
1111 StripeConstructorOptions ,
12- StripeCurrencySelectorElement ,
13- StripeElement ,
1412 StripeElementType ,
1513 StripeElements ,
1614 StripeElementsOptions ,
@@ -26,7 +24,6 @@ import type {
2624 StripeIssuingCardExpiryDisplayElementOptions ,
2725 StripeIssuingCardNumberDisplayElementOptions ,
2826 StripeIssuingCardPinDisplayElementOptions ,
29- StripeLinkAuthenticationElement ,
3027 StripeP24BankElementOptions ,
3128 StripePaymentElementOptions ,
3229 StripePaymentMethodMessagingElementOptions ,
@@ -43,7 +40,6 @@ export type StripeElementOptions =
4340 | StripeCardElementOptions
4441 | StripeCardExpiryElementOptions
4542 | StripeCardNumberElementOptions
46- | StripeCurrencySelectorElement
4743 | StripeEpsBankElementOptions
4844 | StripeExpressCheckoutElementOptions
4945 | StripeFpxBankElementOptions
@@ -54,14 +50,13 @@ export type StripeElementOptions =
5450 | StripeIssuingCardExpiryDisplayElementOptions
5551 | StripeIssuingCardNumberDisplayElementOptions
5652 | StripeIssuingCardPinDisplayElementOptions
57- | StripeLinkAuthenticationElement
5853 | StripeP24BankElementOptions
5954 | StripePaymentElementOptions
6055 | StripePaymentMethodMessagingElementOptions
6156 | StripePaymentRequestButtonElementOptions
6257 | StripeShippingAddressElementOptions
6358
64- /* type StripeElementOptionsMap = {
59+ export type StripeElementOptionsMap = {
6560 address : StripeAddressElementOptions
6661 affirmMessage : StripeAffirmMessageElementOptions
6762 afterpayClearpayMessage : StripeAfterpayClearpayMessageElementOptions
@@ -87,12 +82,13 @@ export type StripeElementOptions =
8782 paymentMethodMessaging : StripePaymentMethodMessagingElementOptions
8883 paymentRequestButton : StripePaymentRequestButtonElementOptions
8984 shippingAddress : StripeShippingAddressElementOptions
90- } */
85+ }
9186
9287export const ERRORS = {
93- STRIPE_NOT_LOADED : "Stripe script is not loaded" ,
88+ STRIPE_NOT_LOADED :
89+ "Stripe is not loaded. Include it as script or load using loadStripe method of @stripe/stripe-js" ,
9490 INSTANCE_NOT_DEFINED :
95- "Instance object is not defined. Initialize Stripe before creating elements" ,
91+ "Stripe instance is not defined. Initialize Stripe before creating elements" ,
9692 ELEMENTS_NOT_DEFINED :
9793 "Elements object is not defined. You can't create stripe element without it" ,
9894 ELEMENT_TYPE_NOT_DEFINED :
@@ -134,16 +130,16 @@ export const createElements = (
134130export const createElement = (
135131 elements : StripeElements ,
136132 elementType : StripeElementType ,
137- options ?: StripeElementOptions ,
138- ) : StripeElement | undefined => {
133+ options ?: StripeElementOptionsMap [ StripeElementType ] ,
134+ ) => {
139135 try {
140136 if ( ! elements ) {
141137 throw new Error ( ERRORS . ELEMENTS_NOT_DEFINED )
142138 }
143139 if ( ! elementType ) {
144140 throw new Error ( ERRORS . ELEMENT_TYPE_NOT_DEFINED )
145141 }
146- return elements . create ( elementType as any , options as any )
142+ return elements . create ( elementType , options )
147143 } catch ( error ) {
148144 console . error ( error )
149145 }
0 commit comments