JezK
Edit File: sc-order-submit.cjs.entry.js.map
{"file":"sc-order-submit.entry.cjs.js","mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAO,MAAM,gBAAgB,GAAG,CAAC,UAAU,GAAG,EAAE,EAAE,IAAI,EAAE,IAAI;;IAC1D,OAAO,CAAA,MAAA,CAAC,UAAU,IAAI,EAAE,EAAE,IAAI,CAAC,SAAS,IAAI,CAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,cAAc,MAAK,IAAI,IAAI,CAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,SAAS,MAAK,CAAC,EAAE,IAAI,KAAK,MAAM,CAAC,CAAC,0CAAE,cAAc,KAAI,EAAE,CAAC;AACxJ,CAAC;;ACFD,MAAM,gBAAgB,GAAG,6IAA6I,CAAC;AACvK,4BAAe,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0ICqGd,UAAE,oJAOa,UAAE;;;;;;sIAyBjB,UAAE,oJAOa,UAAE,4MAIsB,UAAE;;;AAO1DA;;;;;","names":["openWormhole"],"sources":["src/functions/processor.ts","src/components/controllers/checkout-form/order-submit/sc-order-submit.scss?tag=sc-order-submit","src/components/controllers/checkout-form/order-submit/sc-order-submit.tsx"],"sourcesContent":["export const getProcessorData = (processors = [], type, mode) => {\n return (processors || []).find(processor => processor?.processor_type === type && processor?.live_mode === !!(mode === 'live'))?.processor_data || {};\n};\n","sc-order-submit {\n display: block;\n width: auto;\n display: grid;\n gap: var(--sc-form-row-spacing);\n}\n\n.sc-secure-notice {\n display: flex;\n justify-content: center;\n}\n","import { Component, Fragment, h, Prop } from '@stencil/core';\nimport { checkoutIsLocked } from '@store/checkout/getters';\nimport { availableProcessors } from '@store/processors/getters';\nimport { state as selectedProcessor } from '@store/selected-processor';\nimport { state as checkoutState } from '@store/checkout';\nimport { __ } from '@wordpress/i18n';\nimport { openWormhole } from 'stencil-wormhole';\n\nimport { getProcessorData } from '../../../../functions/processor';\nimport { Checkout, Processor, ProcessorName } from '../../../../types';\nimport { formBusy } from '@store/form/getters';\n\n@Component({\n tag: 'sc-order-submit',\n styleUrl: 'sc-order-submit.scss',\n shadow: false,\n})\nexport class ScOrderSubmit {\n /** Is the order loading. */\n @Prop() loading: boolean;\n\n /** Is the order paying. */\n @Prop() paying: boolean;\n\n /** The button type. */\n @Prop({ reflect: true }) type: 'default' | 'primary' | 'success' | 'info' | 'warning' | 'danger' | 'text' | 'link' = 'primary';\n\n /** The button's size. */\n @Prop({ reflect: true }) size: 'small' | 'medium' | 'large' = 'medium';\n\n /** Show a full-width button. */\n @Prop() full: boolean = true;\n\n /** Icon to show. */\n @Prop() icon: string;\n\n /** Show the total. */\n @Prop() showTotal: boolean;\n\n /** Keys and secrets for processors. */\n @Prop() processors: Processor[];\n\n /** The current order. */\n @Prop() order: Checkout;\n\n /** Currency Code */\n @Prop() currencyCode: string = 'usd';\n\n /** The selected processor. */\n @Prop() processor: ProcessorName;\n\n /** Secure */\n @Prop() secureNoticeText: string;\n\n /** Show the secure notice */\n @Prop() secureNotice: boolean = true;\n\n /* Background color */\n @Prop() backgroundColor: string = '';\n\n /* Text color */\n @Prop() textColor: string = '';\n\n cannotShipToLocation() {\n return checkoutState?.checkout?.selected_shipping_choice_required && !checkoutState.checkout?.selected_shipping_choice;\n }\n\n renderPayPalButton(buttons) {\n const { client_id, account_id, merchant_initiated_enabled } = getProcessorData(availableProcessors(), 'paypal', checkoutState.mode);\n if (!client_id && !account_id) return null;\n\n return (\n <sc-paypal-buttons\n buttons={buttons}\n busy={formBusy() || checkoutIsLocked()}\n mode={checkoutState.mode}\n order={checkoutState.checkout}\n merchantInitiated={merchant_initiated_enabled}\n currency-code={checkoutState.currencyCode}\n client-id={client_id}\n merchant-id={account_id}\n label=\"checkout\"\n color=\"blue\"\n ></sc-paypal-buttons>\n );\n }\n\n render() {\n if (this.cannotShipToLocation() || checkoutIsLocked('OUT_OF_STOCK')) {\n return (\n <sc-button\n type={this.type}\n size={this.size}\n full={this.full}\n loading={this.loading || this.paying}\n disabled={true}\n style={{\n '--sc-color-primary-text': this.textColor,\n '--sc-color-primary-500': this.backgroundColor,\n }}\n >\n {!!this.icon && <sc-icon name={this.icon} slot=\"prefix\" aria-hidden=\"true\"></sc-icon>}\n <slot>{__('Purchase', 'surecart')}</slot>\n {this.showTotal && (\n <span>\n {'\\u00A0'}\n <sc-total></sc-total>\n </span>\n )}\n <sc-visually-hidden> {__('Press enter to purchase', 'surecart')}</sc-visually-hidden>\n </sc-button>\n );\n }\n\n const paymentRequired = checkoutState.checkout?.payment_method_required;\n\n return (\n <Fragment>\n {paymentRequired && selectedProcessor.id === 'paypal' && !selectedProcessor?.method && this.renderPayPalButton(['paypal'])}\n {paymentRequired && selectedProcessor.id === 'paypal' && selectedProcessor?.method === 'card' && this.renderPayPalButton(['card'])}\n <sc-button\n hidden={['paypal', 'paypal-card'].includes(selectedProcessor.id) && paymentRequired}\n submit\n type={this.type}\n size={this.size}\n full={this.full}\n loading={this.loading || this.paying}\n disabled={this.loading || this.paying || formBusy() || checkoutIsLocked() || this.cannotShipToLocation()}\n style={{\n '--sc-color-primary-text': this.textColor,\n '--sc-color-primary-500': this.backgroundColor,\n }}\n >\n {!!this.icon && <sc-icon name={this.icon} slot=\"prefix\" aria-hidden=\"true\"></sc-icon>}\n <slot>{__('Purchase', 'surecart')}</slot>\n {this.showTotal && (\n <span>\n {'\\u00A0'}\n <sc-total></sc-total>\n </span>\n )}\n <sc-visually-hidden> {__('Press enter to purchase', 'surecart')}</sc-visually-hidden>\n </sc-button>\n {this.secureNotice && location.protocol === 'https:' && (\n <div class=\"sc-secure-notice\">\n <sc-secure-notice>{this.secureNoticeText || __('This is a secure, encrypted payment.', 'surecart')}</sc-secure-notice>\n </div>\n )}\n </Fragment>\n );\n }\n}\nopenWormhole(ScOrderSubmit, ['loading', 'paying', 'processors', 'processor', 'currencyCode', 'order'], false);\n"],"version":3}