コンテンツにスキップ

<stripe-currency-selector>

このページは src/components/stripe-currency-selector/readme.md から自動生成されています。

Get Stripe.js, and initialize elements

const stripeCurrencySelector = document.createElement('stripe-currency-selector');
customElements
.whenDefined('stripe-currency-selector')
.then(() => {
stripeCurrencySelector.initStripe('pk_test_XXXXXXXXX')
})

Set error message

const stripeCurrencySelector = document.createElement('stripe-currency-selector');
customElements
.whenDefined('stripe-currency-selector')
.then(() => {
stripeCurrencySelector.setErrorMessage('Invalid currency selected');
});

Get the selected currency

const stripeCurrencySelector = document.querySelector('stripe-currency-selector');
const currency = await stripeCurrencySelector.getSelectedCurrency();
console.log('Selected currency:', currency);

Stripe Client loaded event

const stripeCurrencySelector = document.createElement('stripe-currency-selector');
customElements
.whenDefined('stripe-currency-selector')
.then(() => {
stripeCurrencySelector
.addEventListener('stripeLoaded', async ({ detail: {stripe} }) => {
console.log('Stripe loaded:', stripe);
});
})

Currency change event

const stripeCurrencySelector = document.createElement('stripe-currency-selector');
customElements
.whenDefined('stripe-currency-selector')
.then(() => {
stripeCurrencySelector
.addEventListener('currencyChange', async props => {
const { detail: { currency } } = props;
console.log('Currency changed:', currency);
})
})

Stripe Currency Selector Element Allows customers to select their preferred currency for Adaptive Pricing

Property Attribute Description Type Default
applicationName application-name Overwrite the application name that registered For wrapper library (like Capacitor) string 'stripe-pwa-elements'
clientSecret client-secret The client secret from Checkout Session Required for Currency Selector Element string undefined
handleCurrencyChange – Currency change event handler (props: CurrencySelectorChangeEvent) => Promise<void> undefined
publishableKey publishable-key Your Stripe publishable API key. string undefined
stripeAccount stripe-account Optional. Making API calls for connected accounts string undefined
stripeDidLoaded – Stripe.js class loaded handler (event: StripeLoadedEvent) => Promise<void> undefined
Event Description Type
currencyChange Currency change event CustomEvent<{ currency: string; }>
stripeLoaded Stripe Client loaded event CustomEvent<{ stripe: Stripe; }>

getSelectedCurrency() => Promise<string | undefined>

Section titled “getSelectedCurrency() => Promise<string | undefined>”

Get the selected currency

Type: Promise<string>

Promise resolving to the selected currency code (e.g., ‘USD’, ‘EUR’)

initStripe(publishableKey: string, options?: InitStripeOptions) => Promise<void>

Section titled “initStripe(publishableKey: string, options?: InitStripeOptions) => Promise<void>”

Get Stripe.js, and initialize elements

Name Type Description
publishableKey string - Your Stripe publishable API key
options { stripeAccount?: string; } - Optional initialization options (e.g., stripeAccount)

Type: Promise<void>

setErrorMessage(errorMessage: string) => Promise<this>

Section titled “setErrorMessage(errorMessage: string) => Promise<this>”

Set error message

Name Type Description
errorMessage string - The error message to display

Type: Promise<this>

Promise resolving to this instance for method chaining


Built with StencilJS