<stripe-currency-selector>
このページは
src/components/stripe-currency-selector/readme.mdから自動生成されています。
initStripe
Section titled “initStripe”Get Stripe.js, and initialize elements
const stripeCurrencySelector = document.createElement('stripe-currency-selector');customElements .whenDefined('stripe-currency-selector') .then(() => { stripeCurrencySelector.initStripe('pk_test_XXXXXXXXX') })setErrorMessage
Section titled “setErrorMessage”Set error message
const stripeCurrencySelector = document.createElement('stripe-currency-selector');customElements .whenDefined('stripe-currency-selector') .then(() => { stripeCurrencySelector.setErrorMessage('Invalid currency selected'); });getSelectedCurrency
Section titled “getSelectedCurrency”Get the selected currency
const stripeCurrencySelector = document.querySelector('stripe-currency-selector');const currency = await stripeCurrencySelector.getSelectedCurrency();console.log('Selected currency:', currency);stripeLoaded
Section titled “stripeLoaded”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); }); })currencyChange
Section titled “currencyChange”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); }) })Overview
Section titled “Overview”Stripe Currency Selector Element Allows customers to select their preferred currency for Adaptive Pricing
Properties
Section titled “Properties”| 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 |
Events
Section titled “Events”| Event | Description | Type |
|---|---|---|
currencyChange |
Currency change event | CustomEvent<{ currency: string; }> |
stripeLoaded |
Stripe Client loaded event | CustomEvent<{ stripe: Stripe; }> |
Methods
Section titled “Methods”getSelectedCurrency() => Promise<string | undefined>
Section titled “getSelectedCurrency() => Promise<string | undefined>”Get the selected currency
Returns
Section titled “Returns”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
Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
publishableKey |
string |
- Your Stripe publishable API key |
options |
{ stripeAccount?: string; } |
- Optional initialization options (e.g., stripeAccount) |
Returns
Section titled “Returns”Type: Promise<void>
setErrorMessage(errorMessage: string) => Promise<this>
Section titled “setErrorMessage(errorMessage: string) => Promise<this>”Set error message
Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
errorMessage |
string |
- The error message to display |
Returns
Section titled “Returns”Type: Promise<this>
Promise resolving to this instance for method chaining
Built with StencilJS