{"version":3,"sources":["webpack:///../src/VStripeCard.ts","webpack:///../src/index.ts"],"names":["base","extend","mixins","VTextField","name","props","apiKey","type","String","required","create","default","customStyle","Object","fontName","fontUrl","hideIcon","Boolean","hidePostalCode","iconStyle","options","zip","data","card","elements","isReady","okToSubmit","stripe","computed","classes","call","this","theme","$vuetify","currentTheme","watch","isDark","val","oldVal","style","genStyle","update","isDisabled","disabled","mounted","checkAPIKey","loadStripe","methods","key","test","console","error","warn","clearableCallback","clear","genCard","cardProps","genCardProps","Stripe","font","genFont","on","onCardBlur","onCardChange","onCardFocus","onCardReady","mount","computedId","complete","empty","focus","invalid","webkitAutofill","value","postalCode","cssSrc","isURL","encodeURI","fonts","genInput","$createElement","attrs","id","tabindex","genProgress","loading","$slots","progress","VProgressLinear","absolute","color","height","loaderHeight","indeterminate","defaults","fontFamily","fontSize","fontSmoothing","iconColor","url","protocolAndDomainRegex","localhostDomainRegex","nonLocalhostDomainRegex","match","everythingAfterProtocol","src","document","querySelector","$root","$once","$loadScript","errorBucket","push","Error","then","$emit","message","e","isFocused","processCard","lazyValue","autofocus","createToken","token","createSource","source","VStripeElements","install","Vue","component","window","use"],"mappings":"2PAkBMA,EAAO,OAAIC,OAAO,CAAEC,OAAQ,CAACC,EAAA,QA+BpB,EAAAH,EAAKC,SAAkBA,OAAO,CAC3CG,KAAM,gBACNC,MAAO,CACLC,OAAQ,CACNC,KAAMC,OACNC,UAAU,GAEZC,OAAQ,CACNH,KAAMC,OACNG,QAAS,SAEXC,YAAa,CACXL,KAAMM,OACNF,QAAS,iBAAO,KAElBG,SAAU,CACRP,KAAMC,OACNG,QAAS,UAEXI,QAAS,CACPR,KAAMC,OACNG,QAAS,IAEXK,SAAUC,QACVC,eAAgBD,QAChBE,UAAW,CACTZ,KAAMC,OACNG,QAAS,WAEXS,QAAS,CACPb,KAAMM,OAMNF,QAAS,iBAAO,KAElBU,IAAK,CACHd,KAAMC,OACNG,QAAS,KAGbW,KAAM,iBAAO,CACXC,KAAM,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AnBU,OCxafC,EAAkB,CACtBC,QAAO,SAAEC,EAAqB5G,GAC5B4G,EAAIC,UAAU,gBAAiB,KAKpB,SAEO,qBAAXC,QAA0BA,OAAOF,KAC1CE,OAAOF,IAAIG,IAAIL,I","file":"js/chunk-vendors~d174cdb2.836d9ec6.js","sourcesContent":["// Imported Types\n/// \nimport Vue, { VNode } from 'vue'\nimport { VuetifyThemeVariant } from 'vuetify/types/services/theme'\n// import { VuetifyObject } from 'vuetify/types' // !this causes type errors if imported\nimport { ElementStyles } from '../types'\n\n// 3rd Party Libs\nimport merge from 'deepmerge'\n\n// Styles\nimport './VStripeCard.sass'\n\n// Extensions and Components\n// @ts-ignore\nimport { VProgressLinear, VTextField } from 'vuetify/lib'\n\n// Create Base Mixins and Define Custom Properties\nconst base = Vue.extend({ mixins: [VTextField] })\ninterface options extends InstanceType {\n /**\n * Props unique to VStripeCard\n */\n $loadScript: (url: string) => Promise\n onCardBlur: stripe.elements.handler\n onCardChange: stripe.elements.handler\n onCardFocus: stripe.elements.handler\n onCardReady: stripe.elements.handler\n /**\n * Props that **should** have been inherited from VTextField\n * TODO: Figure out why these types aren't being recognized automatically\n */\n autofocus: boolean\n color: string|null\n computedId: string\n disabled: boolean\n errorBucket: string[]\n iconStyle: 'default'|'solid'\n isDark: boolean\n isFocused: boolean\n labelWidth: number|string\n lazyValue: any\n loaderHeight: number|string\n loading: string|boolean\n outlined: boolean\n $vuetify: any // VuetifyObject // importing this type from Vuetify causes errors for some reason\n}\n\n// Extend VTextField to define the VStripeCard component\nexport default base.extend().extend({\n name: 'v-stripe-card',\n props: {\n apiKey: {\n type: String,\n required: true,\n },\n create: {\n type: String,\n default: 'token',\n },\n customStyle: {\n type: Object,\n default: () => ({}),\n },\n fontName: {\n type: String,\n default: 'Roboto',\n },\n fontUrl: {\n type: String,\n default: '',\n },\n hideIcon: Boolean,\n hidePostalCode: Boolean,\n iconStyle: {\n type: String,\n default: 'default',\n },\n options: {\n type: Object,\n /**\n * TODO: Document available options in README.md\n * These can be any and all available options for creating\n * either a token or a source.\n */\n default: () => ({}),\n },\n zip: {\n type: String,\n default: '',\n },\n },\n data: () => ({\n card: null as stripe.elements.Element | null,\n elements: null as stripe.elements.Elements | null,\n isReady: false,\n okToSubmit: false,\n stripe: null as stripe.Stripe | null,\n }),\n computed: {\n classes (): object {\n return {\n ...VTextField.options.computed.classes.call(this),\n 'v-stripe-card': true,\n }\n },\n theme (): VuetifyThemeVariant {\n return this.$vuetify.theme.currentTheme\n },\n },\n watch: {\n isDark (val: boolean, oldVal: boolean) {\n // if the theme changes and a card has already been initialized\n if (val !== oldVal && this.card !== null) {\n // extract key variables from the context\n const { isDark, fontName, theme, customStyle } = this\n // generate styles to match the theme\n const style = this.genStyle(customStyle, fontName, isDark, theme)\n // then update the card\n this.card.update({ style })\n }\n },\n isDisabled (val: boolean, oldVal: boolean) {\n // if the disabled status changes and the card has already been initialized\n if (val !== oldVal && this.card !== null) {\n // update its disabled status\n this.card.update({ disabled: val })\n }\n },\n },\n mounted () {\n // make sure the API key is set correctly\n this.checkAPIKey(this.apiKey)\n // make sure the Stripe.js library is loaded\n this.loadStripe()\n },\n methods: {\n /**\n * Checks the API key and warns the user if they are using a secret\n * key (instead of a public key), or if they are using a test key.\n *\n * @param {string} key An API key\n */\n checkAPIKey (key: string): void {\n // if they are using a secret key\n if (/^sk_/.test(key)) {\n console.error('[VStripeCard Error] It looks like you are using a SECRET API key! You should be using your PUBLIC API key. If you have mistakenly made your secret key publicly available on the web, you should strongly consider rolling your API keys. See: https://stripe.com/docs/keys#keeping-your-keys-safe')\n }\n // if they are using a test key\n if (/^pk_test/.test(key)) {\n console.warn('[VStripeCard Warning] Your `v-stripe-card` instance was initialized with a TEST key. This is correct and appropriate for development and/or testing environments. For production environments, please use your LIVE key. See https://stripe.com/docs/keys for more information.')\n }\n },\n clearableCallback () {\n this.card !== null && this.card.clear()\n VTextField.options.methods.clearableCallback.call(this)\n },\n /**\n * Instantiates a Stripe card element and mounts it in the DOM.\n */\n genCard () {\n // extract props from the context\n const { disabled, fontName, fontUrl, hideIcon, hidePostalCode, iconStyle, isDark, customStyle, theme, zip } = this\n // use them to generate the options we'll need to generate the Stripe and card instances\n const style = this.genStyle(customStyle, fontName, isDark, theme)\n const cardProps = this.genCardProps({ disabled, hideIcon, hidePostalCode, iconStyle, style, zip })\n // initialize Stripe\n this.stripe = Stripe(this.apiKey) // eslint-disable-line no-undef\n // create an Elements generator\n const font = fontUrl || fontName\n this.elements = this.stripe.elements(this.genFont(font))\n // then initialize the card\n this.card = this.elements.create('card', cardProps)\n // setup card event handlers and mount the card\n if (this.card !== null) {\n this.card.on('blur', this.onCardBlur)\n this.card.on('change', this.onCardChange)\n this.card.on('focus', this.onCardFocus)\n this.card.on('ready', this.onCardReady)\n this.card.mount(`#${this.computedId}`)\n }\n },\n /**\n * Generates a well-formed object with all of the values necessary to\n * correctly create a `stripe.elements.Element` card object.\n *\n * @param {object} params An object with all data necessary to generate valid card props\n * @param {boolean} params.disabled Is the input disabled?\n * @param {boolean} params.hideIcon Should the card icon be hidden?\n * @param {boolean} params.hidePostalCode Should the postal code field be hidden?\n * @param {string} params.iconStyle 'solid' or 'default'\n * @param {ElementStyles} params.style Output from `genStyle()`\n * @param {string} params.zip Zip code to be pre-filled, if known\n * @returns {stripe.elements.ElementsOptions} Object to be fed to the `stripe.create('card')` function\n */\n genCardProps ({\n disabled = false,\n hideIcon = false,\n hidePostalCode = false,\n iconStyle = 'default' as 'default' | 'solid' | undefined,\n style = {},\n zip = '',\n } = {}): stripe.elements.ElementsOptions {\n const cardProps: stripe.elements.ElementsOptions = {\n classes: {\n base: 'VStripeCard',\n complete: 'VStripeCard--complete',\n empty: 'VStripeCard--empty',\n focus: 'VStripeCard--focus',\n invalid: 'VStripeCard--invalid',\n webkitAutofill: 'VStripeCard--webkit-autofill',\n },\n disabled,\n hideIcon,\n hidePostalCode,\n iconStyle,\n style,\n }\n zip && (cardProps.value = { postalCode: zip })\n return cardProps\n },\n /**\n * TODO: Should this throw an error if the font is invalid?\n * Allows users of the component to specify the font that will be used\n * inside the text fields generated by Stripe. Does NOT affect the font\n * used by the label, hint, or error messages. These fonts can/should be\n * set at the app level along with all of the other UI fonts.\n *\n * @param {string} font The name of a Google font, or a URL to a valid font\n * @returns {object} An object in the form required by `Stripe.elements()`\n */\n genFont (font = 'Roboto'): stripe.elements.ElementsCreateOptions {\n const cssSrc = this.isURL(font)\n ? font\n : `https://fonts.googleapis.com/css?family=${encodeURI(font)}:400`\n return { fonts: [{ cssSrc }] }\n },\n /**\n * Generates the HTML element to which the Stripe element will attach\n * itself. All that is needed is a
with a known ID. This
\n * gets replaced by Stripe with an IFrame with their custom inputs.\n * see: {@link|https://stripe.com/docs/stripe-js/reference#element-mount}\n */\n genInput (): VNode {\n return this.$createElement('div', { attrs: { id: this.computedId, tabindex: -1 } })\n },\n /**\n * Maintains the ability for users of the component to control the\n * loading/progress indicator of the component, but also shows the\n * progress bar while the Stripe library is being loaded.\n */\n genProgress (): VNode | VNode[] | null {\n if (this.loading === false && this.isReady) return null\n return this.$slots.progress || this.$createElement(VProgressLinear, {\n props: {\n absolute: true,\n color: (this.loading === true || this.loading === '')\n ? (this.color || 'primary')\n : (this.loading || 'primary'),\n height: this.loaderHeight,\n indeterminate: true,\n },\n })\n },\n /**\n * Generate styles for Stripe elements\n *\n * @param {string} font\n */\n genStyle: (customStyle: ElementStyles, fontName: string, isDark: boolean, theme: VuetifyThemeVariant): ElementStyles => {\n const defaults: ElementStyles = {\n base: {\n color: isDark ? '#ffffff' : '#000000',\n fontFamily: `'${fontName}', sans-serif`,\n fontSize: '16px',\n fontSmoothing: 'antialiased',\n iconColor: isDark ? '#eceff1' : '#455a64',\n '::placeholder': {\n color: isDark ? 'rgb(255,255,255,0.7)' : 'rgb(0,0,0,0.54)',\n },\n },\n invalid: {\n color: theme.error as string || '#ff5252',\n iconColor: theme.error as string || '#ff5252',\n },\n }\n return merge(defaults, customStyle)\n },\n /**\n * Loosely validates a URL\n * Based on: {@link|https://github.com/segmentio/is-url}\n *\n * @param {string} url The string to be tested\n * @returns {boolean} True if the url string passes the test\n */\n isURL: (url: string): boolean => {\n const protocolAndDomainRegex = /^(?:\\w+:)?\\/\\/(\\S+)$/\n const localhostDomainRegex = /^localhost[:?\\d]*(?:[^:?\\d]\\S*)?$/\n const nonLocalhostDomainRegex = /^[^\\s.]+\\.\\S{2,}$/\n if (typeof url !== 'string') return false\n const match = url.match(protocolAndDomainRegex)\n if (!match) return false\n const everythingAfterProtocol = match[1]\n if (!everythingAfterProtocol) return false\n if (\n localhostDomainRegex.test(everythingAfterProtocol) ||\n nonLocalhostDomainRegex.test(everythingAfterProtocol)\n ) {\n return true\n }\n return false\n },\n /**\n * Check to see if the Stripe.js library has been loaded into the\n * browser. If it has not, try to load it. If Stripe cannot be\n * loaded or there was a problem with loading, an error is thrown.\n *\n * @throws {Error} Could not load Stripe because `vue-plugin-load-script` is not available\n * @throws {Error} Could not load Stripe because of a network (or other) error\n */\n loadStripe () {\n // Is Stripe already loaded?\n if (typeof Stripe === 'function') {\n // Yes. Generate the card.\n this.genCard()\n } else {\n // No. Set the Stripe URL.\n const src = 'https://js.stripe.com/v3/'\n // Is it already being loaded by another component?\n if (document.querySelector(`script[src=\"${src}\"]`)) {\n // Yes, it's being loaded, so listen for it.\n this.$root.$once('stripe-loaded', () => {\n // instantiate the card\n this.genCard()\n })\n } else {\n // No. Is the script loader installed?\n if (typeof this.$loadScript === 'undefined') {\n // No.\n this.loading = false\n this.errorBucket.push('Stripe could not be loaded')\n throw new Error('[VStripeCard Error]: Stripe is not available and could not be loaded. Please make sure that you have installed and configured all of the necessary dependencies to use this component.')\n } else {\n // Yes, so try to load it.\n this.$loadScript(src).then(() => {\n // Let other potential components know...\n this.$root.$emit('stripe-loaded')\n // and generate the card\n this.genCard()\n }).catch((error: Error) => {\n this.loading = false\n this.errorBucket.push('Error loading stripe')\n throw new Error('[VStripeCard Error] There was a problem loading Stripe: ' + error.message)\n })\n }\n }\n }\n },\n /**\n * Handles card blur events. Propagates (emits) a blur event to\n * allow other components to register event handlers that can\n * respond to the card being blurred.\n *\n * @param {ElementChangeResponse} e Event data from the card element\n */\n onCardBlur (e: stripe.elements.ElementChangeResponse) {\n this.isFocused = false\n // if we have enough info, process the card\n if (this.okToSubmit) {\n this.processCard()\n }\n this.$emit('blur', e)\n },\n /**\n * Handles card change events. Clears or sets errors in the\n * `errorBucket`. If the card is empty, sets `lazyValue` to false.\n *\n * @param {ElementChangeResponse} e Event data from the card element\n */\n onCardChange (e: stripe.elements.ElementChangeResponse) {\n if (e.error) {\n // handle card errors\n this.okToSubmit = false\n e.error.message && this.errorBucket.push(e.error.message)\n }\n if (e.complete) {\n // handle card input is complete\n this.okToSubmit = true\n this.errorBucket = []\n }\n if (e.empty) {\n this.okToSubmit = false\n this.lazyValue = !e.empty\n }\n },\n /**\n * TODO: Should this function emit? Does it emit the right value?\n * Handles card focus events. Propagates (emits) a focus event to\n * allow other components to register event handlers that can\n * respond to the card being focused.\n *\n * @param {ElementChangeResponse} e Event data from the card element\n */\n onCardFocus (e: stripe.elements.ElementChangeResponse) {\n this.isFocused = true\n this.$emit('focus', true)\n },\n /**\n * Handles card initialization events. Propagates (emits) a ready event to\n * allow other components to register event handlers that can\n * respond to the card being ready. Will also focus the card input\n * if `autofocus` is true.\n *\n * @param {ElementChangeResponse} e Event data from the card element\n */\n onCardReady (e: stripe.elements.ElementChangeResponse) {\n this.isReady = true\n this.autofocus && this.card !== null && this.card.focus()\n this.$emit('ready', e)\n },\n /**\n * Converts the collected payment information into a single-use token\n * or a multi-use source that can safely be passed to your backend\n * API server where a payment request can be processed.\n *\n * See {@link|https://stripe.com/docs/stripe-js/reference#stripe-create-token}\n */\n async processCard () {\n if (this.stripe && this.card) {\n if (this.create === 'token') {\n const { token, error } = await this.stripe.createToken(this.card, this.options)\n if (!error) {\n this.errorBucket = []\n this.$emit('input', token)\n } else {\n // handle error\n error.message && this.errorBucket.push(error.message)\n }\n } else {\n const { source, error } = await this.stripe.createSource(this.card, this.options)\n if (!error) {\n this.errorBucket = []\n this.$emit('input', source)\n } else {\n // handle error\n error.message && this.errorBucket.push(error.message)\n }\n }\n }\n },\n },\n})\n","import { VueConstructor } from 'vue'\nimport VStripeCard from './VStripeCard'\n\nconst VStripeElements = {\n install (Vue: VueConstructor, options?: any) {\n Vue.component('v-stripe-card', VStripeCard)\n },\n}\n\nexport { VStripeCard }\nexport default VStripeElements\n\nif (typeof window !== 'undefined' && window.Vue) {\n window.Vue.use(VStripeElements)\n}\n"],"sourceRoot":""}