diff --git a/docs/index.md b/docs/index.md index 8bb3132..f52090b 100644 --- a/docs/index.md +++ b/docs/index.md @@ -46,6 +46,8 @@ Enter a valid _testing_ publishable key in the input below to activate the examp Once you've set the `publishable-key` attribute (or the `publishableKey` DOM property), Stripe will create a Stripe Card Element on your page. +For use with Stripe Connect, you can provide the optional `stripe-account` attribute set to the account ID of the connected account. + ### Accepting Payments Fill out some payment information here, then choose the type of payment object you'd like to generate. diff --git a/src/StripeBase.ts b/src/StripeBase.ts index fa13e7a..2b14b81 100644 --- a/src/StripeBase.ts +++ b/src/StripeBase.ts @@ -139,6 +139,10 @@ export class StripeBase extends LitElement { @property({ type: Boolean, attribute: 'show-error', reflect: true }) showError = false; + /** Stripe account to use (connect) */ + @property({ type: String, attribute: 'stripe-account' }) + stripeAccount: string; + /* READ-ONLY FIELDS */ /* PAYMENT REPRESENTATIONS */ @@ -388,13 +392,14 @@ export class StripeBase extends LitElement { * Initializes Stripe and elements. */ private async initStripe(): Promise { - const { publishableKey } = this; + const { publishableKey, stripeAccount } = this; if (!publishableKey) readonly.set(this, { elements: null, element: null, stripe: null }); else { try { + const options = stripeAccount ? { 'stripeAccount': stripeAccount } : {}; const stripe = - (window.Stripe) ? window.Stripe(publishableKey) : await loadStripe(publishableKey); + (window.Stripe) ? window.Stripe(publishableKey, options) : await loadStripe(publishableKey, options); const elements = stripe?.elements(); readonly.set(this, { elements, error: null, stripe }); } catch (e) {