Skip to content

feat: add missing properties to Elements #130

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"semantic-release": "semantic-release"
},
"devDependencies": {
"@stripe/stripe-js": "^3.3.0",
"@stripe/stripe-js": "^5.2.0",
"@sveltejs/adapter-vercel": "^5.3.0",
"@sveltejs/kit": "^2.5.7",
"@sveltejs/package": "^2.3.1",
Expand All @@ -39,7 +39,7 @@
"vite": "^5.2.11"
},
"peerDependencies": {
"@stripe/stripe-js": "^3 || ^4",
"@stripe/stripe-js": "^3 || ^4 || ^5",
"svelte": "^3 || ^4 || ^5"
},
"type": "module",
Expand Down
10 changes: 5 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 27 additions & 3 deletions src/lib/Elements.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/** @type {import('@stripe/stripe-js').Stripe?} */
export let stripe

/** @type {StripeElementsOptions["mode"]} */
/** @type {import('@stripe/stripe-js').StripeElementsOptionsMode["mode"]} */
export let mode = undefined

/** @typedef { import('@stripe/stripe-js').Appearance } Appearance */
Expand All @@ -22,7 +22,7 @@
/** @type {Appearance["labels"]} */
export let labels = 'above'

/** @typedef { import('@stripe/stripe-js').StripeElementsOptions } StripeElementsOptions */
/** @typedef { import('@stripe/stripe-js').StripeElementsOptionsClientSecret & import('@stripe/stripe-js').StripeElementsOptionsMode } StripeElementsOptions */

/** @type {StripeElementsOptions["loader"]} */
export let loader = 'auto'
Expand All @@ -42,6 +42,30 @@
/** @type {string?} */
export let clientSecret = undefined

/** @type {StripeElementsOptions["paymentMethodTypes"]} */
export let paymentMethodTypes = undefined

/** @type {StripeElementsOptions["setupFutureUsage"]} */
export let setupFutureUsage = undefined

/** @type {StripeElementsOptions["captureMethod"]} */
export let captureMethod = undefined

/** @type {StripeElementsOptions["customerOptions"]} */
export let customerOptions = undefined

/** @type {StripeElementsOptions["externalPaymentMethodTypes"]} */
export let externalPaymentMethodTypes = undefined

/** @type {StripeElementsOptions["paymentMethodConfiguration"]} */
export let paymentMethodConfiguration = undefined

/** @type {StripeElementsOptions["paymentMethodCreation"]} */
export let paymentMethodCreation = undefined

/** @type {StripeElementsOptions["paymentMethodOptions"]} */
export let paymentMethodOptions = undefined

$: appearance = {
theme, variables, rules, labels
}
Expand All @@ -50,7 +74,7 @@
export let elements = null

$: if (stripe && !elements) {
elements = stripe.elements({ mode, currency, amount, appearance, clientSecret, fonts, loader, locale })
elements = stripe.elements({ mode, currency, amount, appearance, clientSecret, fonts, loader, locale, paymentMethodTypes, setupFutureUsage, captureMethod, customerOptions, externalPaymentMethodTypes, paymentMethodConfiguration, paymentMethodCreation, paymentMethodOptions })

register(stripe)
setContext('stripe', { stripe, elements })
Expand Down