JezK
Edit File: sc-order-confirmation.cjs.entry.js.map
{"file":"sc-order-confirmation.entry.cjs.js","mappings":";;;;;;;;;;;AAAA,MAAM,sBAAsB,GAAG,0VAA0V,CAAC;AAC1X,kCAAe,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6BCiEhB,UAAE;;;;;;;;;;;;;;;;;;;;;;;;;yEAyBZ,UAAE;;;;;;;;;;;;;;;qXAkCE,UAAE,4HACuB,UAAE;;;;;;;","names":[],"sources":["src/components/controllers/confirmation/order-confirmation/sc-order-confirmation.css?tag=sc-order-confirmation&encapsulation=shadow","src/components/controllers/confirmation/order-confirmation/sc-order-confirmation.tsx"],"sourcesContent":[":host {\n display: block;\n max-width: 800px;\n margin: auto;\n}\n\n::slotted(*:not(:last-child)),\nsc-form form > *:not(:last-child) {\n margin-bottom: var(--sc-form-row-spacing-large)\n}\n\n.order-confirmation__content {\n color: var(--sc-order-confirmation-color, var(--sc-color-gray-500));\n}\n\n.order-confirmation__content.hidden {\n display: none;\n}\n\n::part(line-items) {\n display: grid;\n gap: 0.5em;\n}\n","import apiFetch from '../../../../functions/fetch';\nimport { Checkout, ManualPaymentMethod } from '../../../../types';\nimport { Component, State, h, Prop } from '@stencil/core';\nimport { __ } from '@wordpress/i18n';\nimport { addQueryArgs, getQueryArg } from '@wordpress/url';\nimport { Universe } from 'stencil-wormhole';\n\n@Component({\n tag: 'sc-order-confirmation',\n styleUrl: 'sc-order-confirmation.css',\n shadow: true,\n})\nexport class ScOrderConfirmation {\n @Prop({ mutable: true }) order: Checkout;\n\n /** Loading */\n @State() loading: boolean = false;\n\n /** Error */\n @State() error: string;\n\n componentWillLoad() {\n // @ts-ignore\n Universe.create(this, this.state());\n // get teh session\n this.getSession();\n }\n\n /** Get session id from url. */\n getSessionId() {\n if (this.order?.id) return this.order.id;\n return getQueryArg(window.location.href, 'sc_order');\n }\n\n /** Update a session */\n async getSession() {\n if (!this.getSessionId()) return;\n if (this.order?.id) return;\n try {\n this.loading = true;\n this.order = (await await apiFetch({\n path: addQueryArgs(`surecart/v1/checkouts/${this.getSessionId()}`, {\n expand: [\n 'checkout_fees',\n 'shipping_fees',\n 'line_items',\n 'line_item.price',\n 'line_item.fees',\n 'price.product',\n 'customer',\n 'customer.shipping_address',\n 'payment_intent',\n 'discount',\n 'manual_payment_method',\n 'discount.promotion',\n 'billing_address',\n 'shipping_address',\n ],\n refresh_status: true,\n currency_conversion: false,\n }),\n })) as Checkout;\n } catch (e) {\n if (e?.message) {\n this.error = e.message;\n } else {\n this.error = __('Something went wrong', 'surecart');\n }\n } finally {\n this.loading = false;\n }\n }\n\n state() {\n const manualPaymentMethod = this.order?.manual_payment_method as ManualPaymentMethod;\n return {\n processor: 'stripe',\n loading: this.loading,\n orderId: this.getSessionId(),\n order: this.order,\n customer: this.order?.customer,\n manualPaymentTitle: manualPaymentMethod?.name,\n manualPaymentInstructions: manualPaymentMethod?.instructions,\n };\n }\n\n renderOnHold() {\n if (this.order?.status !== 'processing') return null;\n if (this?.order?.payment_intent?.processor_type === 'paypal') {\n return (\n <sc-alert type=\"warning\" open={true}>\n {__('Paypal is taking a closer look at this payment. It’s required for some payments and normally takes up to 3 business days.', 'surecart')}\n </sc-alert>\n );\n }\n }\n\n renderManualInstructions() {\n const paymentMethod = this.order?.manual_payment_method as ManualPaymentMethod;\n if (!paymentMethod?.instructions) return;\n return (\n <sc-alert type=\"info\" open>\n <span slot=\"title\">{paymentMethod?.name}</span>\n <div innerHTML={paymentMethod?.instructions}></div>\n </sc-alert>\n );\n }\n\n render() {\n return (\n <Universe.Provider state={this.state()}>\n <div class={{ 'order-confirmation': true }}>\n <div\n class={{\n 'order-confirmation__content': true,\n 'hidden': !this.order?.id && !this.loading,\n }}\n >\n <sc-order-confirm-components-validator checkout={this.order}>\n <slot />\n </sc-order-confirm-components-validator>\n </div>\n\n {!this.order?.id && !this.loading && (\n <sc-heading>\n {__('Order not found.', 'surecart')}\n <span slot=\"description\">{__('This order could not be found. Please try again.', 'surecart')}</span>\n </sc-heading>\n )}\n </div>\n </Universe.Provider>\n );\n }\n}\n"],"version":3}