/stripe-pwa-elements:stripe-pwa-elementsfrom stripe-pwa-elements
Integrates Stripe payments via the stripe-pwa-elements Web Component library. Covers install, component selection, key wiring, lazy-load timing, and submit/confirm flow for plain HTML/JS, React, Vue, Angular, and Svelte.
Ships in stripe-pwa-elements. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
stripe-pwa-elements is a framework-agnostic Web Component library (built with
Stencil) that wraps Stripe Elements. It works in plain HTML, React, Vue, Angular,
and Svelte. This skill helps you pick the right component and wire it up correctly.
pk_test_
(publishable), sk_test_ (secret) and rk_test_ (restricted).@stripe/stripe-js is a regular dependency of stripe-pwa-elements, so installing
the package installs it too. Do not add a second copy by hand.These steps change a real Stripe account, so treat them as external side effects: creating objects (PaymentIntents, Customers, Checkout Sessions) with the Stripe CLI or API, registering payment method domains, and changing Dashboard settings.
--help, list, retrieve) to
check the target account and parameters.--live. Never add --live, and never use a pk_live_ / sk_live_ /
rk_live_ key, unless the user explicitly asks for live mode.From the Stripe docs (API keys, Express Checkout Element):
<stripe-express-checkout-element> (Apple Pay, Google Pay, Link, …) need
the domain registered
in both the sandbox and live mode, and some payment methods must be activated in the
Dashboard before they appear.allow="payment").npm install stripe-pwa-elements
With a bundler (Vite, webpack, …), import each component you use from the custom-elements build. Importing it registers the tag:
import 'stripe-pwa-elements/dist/components/stripe-payment-element';
Or load directly from a CDN (no build step):
<script type="module" src="https://unpkg.com/stripe-pwa-elements/dist/stripe-elements/stripe-elements.esm.js"></script>
| You want to… | Use this tag |
|---|---|
| One unified form for cards, wallets & local methods (recommended) | <stripe-payment-element> |
| One-click Apple Pay / Google Pay / Link / PayPal | <stripe-express-checkout-element> |
| Classic split card fields (number / expiry / CVC) | <stripe-card-element> |
| Card fields presented inside a built-in modal | <stripe-card-element-modal> |
| Collect a billing/shipping address | <stripe-address-element> |
| Collect email + offer Stripe Link | <stripe-link-authentication-element> |
| Let the buyer choose a currency (Adaptive Pricing) | <stripe-currency-selector> |
| A reusable modal wrapper around any of the above | <stripe-modal> |
When unsure, prefer <stripe-payment-element> — it adapts to the buyer's location
and the payment methods enabled in the Stripe Dashboard.
Do not recommend stripe-payment-request-button for new integrations. Stripe is
removing stripe.paymentRequest(); use <stripe-express-checkout-element> instead.
Migration guide: https://stripe-pwa-elements-docs.wp-kyoto.workers.dev/en/guides/migrate-payment-request-button-to-express-checkout/
Secrets come from the server. Create the PaymentIntent / SetupIntent /
Checkout Session on your backend with your secret key, and pass only the
publishable key (pk_test_… / pk_live_…) and the resulting client secret
to the browser. Never put a secret key (sk_… / rk_…) in client code.
Set the publishable key plus the correct secret prop for the component:
<stripe-payment-element>, <stripe-card-element>, <stripe-card-element-modal> → intent-client-secret (pi_…_secret_… or seti_…_secret_…)<stripe-payment-element> in Checkout Session mode → checkout-session-client-secret (or the initStripeWithCheckoutSession() method)<stripe-express-checkout-element> → client-secret<stripe-currency-selector> → client-secret (Checkout Session)<stripe-address-element> / <stripe-link-authentication-element> → publishable key onlyWait for the element before scripting it. Components lazy-load Stripe.js, so
guard with await customElements.whenDefined('<tag>') and/or listen for the
stripeLoaded event before calling any method.
Verify before opening a PR. In this repository run pnpm run verify:agent
(lint, types, unit + component tests, build). Use pnpm run verify:agent -- --quick
for a shorter loop; --quick cannot be combined with --stripe-e2e. Optional
real-browser check: pnpm run verify:agent -- --stripe-e2e. Maps: repo root
AGENTS.md and the docs
verification map.
Attributes are kebab-case; events are camelCase CustomEvents. A prop like
intentClientSecret is the HTML attribute intent-client-secret. Read event
payloads from event.detail. In React attach listeners with addEventListener
on a ref (onFormSubmit does not fire); in Vue use @formSubmit.
Default vs. manual submit. By default the form components confirm the payment
for you and emit the result on defaultFormSubmitResult (or defaultConfirmResult
for express checkout). To run your own logic instead, set
should-use-default-form-submit-action="false" (express checkout:
should-use-default-confirm-action="false") and handle the formSubmit /
confirm event yourself.
Use test mode while developing (pk_test_…). Generate a client secret fast
with the Stripe CLI, e.g.
stripe payment_intents create --amount=1099 --currency=usd | jq -r .client_secret.
initStripe(publishableKey, { stripeAccount? }) — load Stripe.js & mount.updateProgress('' | 'loading' | 'success' | 'failure') — drive the button state.setErrorMessage(message) — show an inline error.stripeLoaded event — fires with { stripe } once Stripe.js is ready.applicationName and stripe-account (Connect) props are available on every
Stripe-backed component. i18n (English, Japanese, Portuguese) is auto-detected from
the browser.
Do not guess attribute or event names. Look them up in the generated API, which always matches the code:
node_modules/stripe-pwa-elements/dist/types/components.d.ts
(matches the installed version; each prop and event has its doc comment).Copy-paste starting points. Replace the placeholder values.
Simplest path. The component calls stripe.confirmPayment() and emits the result.
<stripe-payment-element
publishable-key="pk_test_xxxxx"
intent-client-secret="pi_xxxxx_secret_xxxxx"
></stripe-payment-element>
<script>
customElements.whenDefined('stripe-payment-element').then(() => {
const el = document.querySelector('stripe-payment-element');
el.addEventListener('defaultFormSubmitResult', ({ detail }) => {
if (detail instanceof Error || detail.error) {
el.updateProgress('failure');
console.error('Payment failed', detail);
} else {
el.updateProgress('success');
console.log('Payment succeeded', detail);
// redirect to your success page, close modal, etc.
}
});
});
</script>
To save a card instead of charging, set intent-type="setup" and pass a SetupIntent
client secret (seti_…_secret_…).
Set should-use-default-form-submit-action="false" and handle formSubmit.
<stripe-payment-element
publishable-key="pk_test_xxxxx"
intent-client-secret="pi_xxxxx_secret_xxxxx"
should-use-default-form-submit-action="false"
></stripe-payment-element>
<script>
customElements.whenDefined('stripe-payment-element').then(() => {
const el = document.querySelector('stripe-payment-element');
el.addEventListener('formSubmit', async ({ detail: { stripe, elements } }) => {
const result = await stripe.confirmPayment({
elements,
confirmParams: { return_url: 'https://example.com/order/complete' },
redirect: 'if_required',
});
if (result.error) {
el.setErrorMessage(result.error.message);
el.updateProgress('failure');
} else {
el.updateProgress('success');
}
});
});
</script>
Use a Checkout Session client secret (cs_…_secret_…) via the dedicated method.
const el = document.querySelector('stripe-payment-element');
await customElements.whenDefined('stripe-payment-element');
await el.initStripeWithCheckoutSession('pk_test_xxxxx', 'cs_xxxxx_secret_xxxxx');
el.addEventListener('checkoutSessionConfirmResult', ({ detail }) => {
if (detail instanceof Error) {
el.setErrorMessage(detail.message);
el.updateProgress('failure');
} else if (detail.type === 'error') {
el.setErrorMessage(detail.error.message);
el.updateProgress('failure');
} else {
el.updateProgress('success'); // detail.session has the result
}
});
You can also set the checkout-session-client-secret attribute declaratively
instead of calling the method.
Related attributes (Checkout Session mode only):
checkout-session-return-url — redirect target used when the Session was created
WITHOUT return_url (defaults to the current page; a Session created WITH
return_url redirects there automatically)checkout-session-email — required when the Session has no customer_email/customercheckoutSessionDefaultValues (JS property only) — prefill email/address, same shape as
defaultValues of stripe.initCheckoutElementsSdkconst el = document.createElement('stripe-express-checkout-element');
el.setAttribute('publishable-key', 'pk_test_xxxxx');
el.setAttribute('client-secret', 'pi_xxxxx_secret_xxxxx');
el.setAttribute('amount', '1099'); // minor units
el.setAttribute('currency', 'usd');
el.setAttribute('button-height', '48px');
document.getElementById('container').appendChild(el);
await customElements.whenDefined('stripe-express-checkout-element');
el.addEventListener('defaultConfirmResult', ({ detail }) => {
if (detail instanceof Error || detail.error) {
el.setErrorMessage(detail.error ? detail.error.message : detail.message);
el.updateProgress('failure');
} else {
el.updateProgress('success');
}
});
await el.initStripe('pk_test_xxxxx');
Buttons only appear when the browser/device supports the wallet. For custom
handling set should-use-default-confirm-action="false" and handle confirm.
<stripe-modal open="true">
<stripe-card-element
publishable-key="pk_test_xxxxx"
intent-client-secret="pi_xxxxx_secret_xxxxx"
should-use-default-form-submit-action="false"
></stripe-card-element>
</stripe-modal>
<script>
customElements.whenDefined('stripe-card-element').then(() => {
const el = document.querySelector('stripe-card-element');
el.addEventListener('formSubmit', async ({ detail }) => {
const { stripe, cardNumberElement } = detail;
const result = await stripe.createPaymentMethod({
type: 'card',
card: cardNumberElement, // also: cardExpiryElement, cardCVCElement
});
if (result.error) {
el.setErrorMessage(result.error.message);
el.updateProgress('failure');
} else {
// Send result.paymentMethod.id to your server to confirm the PaymentIntent.
el.updateProgress('success');
}
});
});
</script>
const el = document.querySelector('stripe-address-element'); // mode="shipping" / "billing"
await customElements.whenDefined('stripe-address-element');
el.addEventListener('formSubmit', ({ detail: { address } }) => {
console.log(address.value, address.complete);
el.updateProgress('success');
});
// Or read on demand:
const { value, complete } = await el.getValue();
const el = document.querySelector('stripe-link-authentication-element');
await customElements.whenDefined('stripe-link-authentication-element');
el.addEventListener('linkAuthenticationChange', ({ detail: { email } }) => {
console.log('email', email);
});
const email = await el.getEmail();
stripe-pwa-elements/dist/components/<tag>
(the lazy loader fails under Vite). Attach event listeners with
addEventListener on a ref: React 18 ignores custom element event props, and
React 19 takes the text after on as the event name, so onFormSubmit waits
for FormSubmit and never fires. Set array/object props (like
allowedCountries) via the same ref since they aren't attributes.dist/components/<tag>; use @formSubmit="handler"; set
isCustomElement: (tag) => tag.startsWith('stripe-') in the Vue compiler options.CUSTOM_ELEMENTS_SCHEMA; bind with (formSubmit)="handler($event)".customElements.whenDefined.Never expose your secret key in the browser. Create the intent server-side:
// Node.js — wrap in an async function (top-level await isn't valid in CommonJS)
const stripe = require('stripe')(process.env.STRIPE_SECRET_KEY);
async function createIntent() {
const intent = await stripe.paymentIntents.create({
amount: 1099,
currency: 'usd',
automatic_payment_methods: { enabled: true },
});
return intent.client_secret; // send this to the browser
}
For quick local testing, generate one with the Stripe CLI:
stripe payment_intents create --amount=1099 --currency=usd | jq -r .client_secret
Follow golden-path rule 4 (pnpm run verify:agent). After a successful build, you may also run pnpm run example:copy && pnpm run check:example-smoke, then open the page named in example/FEATURE_MAP.md via pnpm run example:serve and attach a screenshot to the pull request. Do not add new demos using deprecated <stripe-payment-request-button>.
What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub hideokamoto/stripe-pwa-elements --plugin stripe-pwa-elements