diff --git a/src/assets/scripts.ts b/src/assets/scripts.ts index 9f6be1bc..213b0913 100644 --- a/src/assets/scripts.ts +++ b/src/assets/scripts.ts @@ -1,22 +1,19 @@ /** * @desc Main js entry point module (scripts) * @module src/assets/scripts.ts - * @changed 2024.04.04, 16:06 + * @changed 2024.04.06, 22:00 */ -/* NOTE: These modules are unused. Used only - * `src/assets/stripe-init/stripe_payment_intents_support.ts`, via requirejs, - * without exposing to global scope. +/* // NOTE: These modules are unused. Used only + * // `src/assets/stripe-init/stripe_payment_intents_support.ts`, via requirejs, + * // without exposing to global scope. * - * import { billing_event_stripe_payment_proceed } from './stripe-init/billing_event_stripe_payment_proceed'; - * import { billing_membership_stripe_payment_proceed } from './stripe-init/billing_membership_stripe_payment_proceed'; - * - * // Expose functions to global scope... - * window.billing_event_stripe_payment_proceed = billing_event_stripe_payment_proceed; - * window.billing_membership_stripe_payment_proceed = billing_membership_stripe_payment_proceed; + * import { startStripeElementsForm } from './stripe-init/stripe_payment_intents_support'; * * console.log('[scripts] Main client code entry point', { - * billing_event_stripe_payment_proceed, - * billing_membership_stripe_payment_proceed, + * startStripeElementsForm, * }); */ + +// Empty root module +export {}; diff --git a/static/assets/scripts.js b/static/assets/scripts.js index 323f8e17..b6ca862a 100644 --- a/static/assets/scripts.js +++ b/static/assets/scripts.js @@ -1,24 +1,12 @@ /** * @desc Main js entry point module (scripts) * @module src/assets/scripts.ts - * @changed 2024.04.04, 16:06 - */ -/* NOTE: These modules are unused. Used only - * `src/assets/stripe-init/stripe_payment_intents_support.ts`, via requirejs, - * without exposing to global scope. - * - * import { billing_event_stripe_payment_proceed } from './stripe-init/billing_event_stripe_payment_proceed'; - * import { billing_membership_stripe_payment_proceed } from './stripe-init/billing_membership_stripe_payment_proceed'; - * - * // Expose functions to global scope... - * window.billing_event_stripe_payment_proceed = billing_event_stripe_payment_proceed; - * window.billing_membership_stripe_payment_proceed = billing_membership_stripe_payment_proceed; - * - * console.log('[scripts] Main client code entry point', { - * billing_event_stripe_payment_proceed, - * billing_membership_stripe_payment_proceed, - * }); + * @changed 2024.04.06, 22:00 */ +define("scripts", ["require", "exports"], function (require, exports) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); +}); /** * @module stripe_payment_intents_support.ts * @changed 2024.04.04, 00:21 @@ -32,7 +20,7 @@ define("stripe-init/stripe_payment_intents_support", ["require", "exports"], fun var success_url = params.success_url; event.preventDefault(); // @see https://docs.stripe.com/payments/accept-a-payment?platform=web&ui=elements#web-submit-payment - // const result = await + // TODO: Show 'busy' spinner at stripe interaction begin? (It could take some time.) stripe .confirmPayment({ elements: elements, @@ -43,7 +31,6 @@ define("stripe-init/stripe_payment_intents_support", ["require", "exports"], fun .then(function (result) { var error = result.error; if (error) { - // debugger; console.error('[stripe_payment_intents_support:startStripeElementsForm:submitStripeForm] error', { error: error, event: event, @@ -64,7 +51,6 @@ define("stripe-init/stripe_payment_intents_support", ["require", "exports"], fun params: params, stripe: stripe, }); - debugger; window.location.href = success_url; } }) @@ -100,7 +86,7 @@ define("stripe-init/stripe_payment_intents_support", ["require", "exports"], fun if (!form) { var errorText = 'Form node could not be found!'; var error = new Error(errorText); - console.log('[stripe_payment_intents_support:startStripeElementsForm] error', errorText, { + console.error('[stripe_payment_intents_support:startStripeElementsForm] error', errorText, { error: error, params: params, stripe: stripe, @@ -109,6 +95,7 @@ define("stripe-init/stripe_payment_intents_support", ["require", "exports"], fun paymentElement: paymentElement, form: form, }); + // eslint-disable-next-line no-debugger debugger; return; } diff --git a/static/assets/scripts.js.map b/static/assets/scripts.js.map index e8c58cf8..1e2e27ef 100644 --- a/static/assets/scripts.js.map +++ b/static/assets/scripts.js.map @@ -1 +1 @@ -{"version":3,"sources":["src/assets/scripts.ts","src/assets/stripe-init/stripe_payment_intents_support.ts","src/assets/test/test.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;;;;;;;GAeG;ACrBH;;;GAGG;;;;;IAUH,kBAAkB;IAClB,SAAS,gBAAgB,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AoC;QAExE,IAAA,sBAAsB,GAGpB,MAAM,uBAHc;QACtB,eAAe;QACf,aAAa,GACX,MAAM,cADK,CACJ;QAEX,uBAAuB;QACvB,IAAM,MAAM,GAAW,MAAM,CAAC,MAAM,CAAC,sBAAsB,CAAC,CAAC;QAE7D,wGAAwG;QACxG,IAAM,OAAO,GAAsC;YACjD,YAAY,EAAE,aAAa;YAC3B,kDAAkD;YAClD,kBAAkB;SACnB,CAAC;QAEF,+GAA+G;QAC/G,IAAM,QAAQ,GAAmB,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QAE1D,uCAAuC;QACvC,yEAAyE;QACzE,IAAM,cAAc,GAAyB,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QACxE,cAAc,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC;QAEzC,IAAM,IAAI,GAAG,QAAQ,CAAC,cAAc,CAAC,cAAc,CAAC,CAAC;QAErD,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,IAAM,SAAS,GAAG,+BAA+B,CAAC;YAClD,IAAM,KAAK,GAAG,IAAI,KAAK,CAAC,SAAS,CAAC,CAAC;YACnC,OAAO,CAAC,GAAG,CAAC,gEAAgE,EAAE,SAAS,EAAE;gBACvF,KAAK,OAAA;gBACL,MAAM,QAAA;gBACN,MAAM,QAAA;gBACN,OAAO,SAAA;gBACP,QAAQ,UAAA;gBACR,cAAc,gBAAA;gBACd,IAAI,MAAA;aACL,CAAC,CAAC;YACH,QAAQ,CAAC;YACT,OAAO;QACT,CAAC;QAED,IAAI,CAAC,gBAAgB,CAAC,QAAQ,EAAE,gBAAgB,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;IACzF,CAAC;IA5CD,0DA4CC;;AC9HD;;;GAGG;AAEH,+BAA+B","file":"scripts.js","sourcesContent":["/**\n * @desc Main js entry point module (scripts)\n * @module src/assets/scripts.ts\n * @changed 2024.04.04, 16:06\n */\n\n/* NOTE: These modules are unused. Used only\n * `src/assets/stripe-init/stripe_payment_intents_support.ts`, via requirejs,\n * without exposing to global scope.\n *\n * import { billing_event_stripe_payment_proceed } from './stripe-init/billing_event_stripe_payment_proceed';\n * import { billing_membership_stripe_payment_proceed } from './stripe-init/billing_membership_stripe_payment_proceed';\n *\n * // Expose functions to global scope...\n * window.billing_event_stripe_payment_proceed = billing_event_stripe_payment_proceed;\n * window.billing_membership_stripe_payment_proceed = billing_membership_stripe_payment_proceed;\n *\n * console.log('[scripts] Main client code entry point', {\n * billing_event_stripe_payment_proceed,\n * billing_membership_stripe_payment_proceed,\n * });\n */\n","/**\n * @module stripe_payment_intents_support.ts\n * @changed 2024.04.04, 00:21\n */\n\nimport type {\n Stripe,\n StripeElements,\n StripeElementsOptionsClientSecret,\n StripeError,\n StripePaymentElement,\n} from '@stripe/stripe-js/dist/stripe-js';\n\n/** Form action */\nfunction submitStripeForm(\n stripe: Stripe,\n params: TCreateCheckoutSessionParams,\n elements: StripeElements,\n event: SubmitEvent,\n) {\n const { success_url } = params;\n\n event.preventDefault();\n\n // @see https://docs.stripe.com/payments/accept-a-payment?platform=web&ui=elements#web-submit-payment\n // const result = await\n stripe\n .confirmPayment({\n elements,\n confirmParams: {\n return_url: success_url,\n },\n })\n .then((result) => {\n const error: StripeError = result.error;\n\n if (error) {\n // debugger;\n console.error(\n '[stripe_payment_intents_support:startStripeElementsForm:submitStripeForm] error',\n {\n error,\n event,\n params,\n stripe,\n },\n );\n\n // Show error\n const messageContainer = document.querySelector('#error-message');\n if (messageContainer) {\n messageContainer.textContent = error.message || '';\n }\n } else {\n // Success: redirect to success message\n console.log(\n '[stripe_payment_intents_support:startStripeElementsForm:submitStripeForm] success',\n {\n success_url,\n event,\n params,\n stripe,\n },\n );\n debugger;\n window.location.href = success_url;\n }\n })\n .catch((error) => {\n console.error(\n '[stripe_payment_intents_support:startStripeElementsForm:submitStripeForm] error',\n {\n error,\n event,\n params,\n stripe,\n },\n );\n });\n}\n\n/** Start stripe payment form */\nexport function startStripeElementsForm(params: TCreateCheckoutSessionParams) {\n const {\n STRIPE_PUBLISHABLE_KEY,\n // success_url,\n client_secret,\n } = params;\n\n // Initialize Stripe.js\n const stripe: Stripe = window.Stripe(STRIPE_PUBLISHABLE_KEY);\n\n // @see https://docs.stripe.com/js/elements_object/create_payment_element#payment_element_create-options\n const options: StripeElementsOptionsClientSecret = {\n clientSecret: client_secret,\n // TODO: Customize forms (use bootstrap styles)...\n // appearance: {},\n };\n\n // Set up Stripe.js and Elements to use in checkout form, passing the client secret obtained in a previous step\n const elements: StripeElements = stripe.elements(options);\n\n // Create and mount the Payment Element\n // @see https://docs.stripe.com/js/elements_object/create_payment_element\n const paymentElement: StripePaymentElement = elements.create('payment');\n paymentElement.mount('#payment-element');\n\n const form = document.getElementById('payment-form');\n\n if (!form) {\n const errorText = 'Form node could not be found!';\n const error = new Error(errorText);\n console.log('[stripe_payment_intents_support:startStripeElementsForm] error', errorText, {\n error,\n params,\n stripe,\n options,\n elements,\n paymentElement,\n form,\n });\n debugger;\n return;\n }\n\n form.addEventListener('submit', submitStripeForm.bind(null, stripe, params, elements));\n}\n","/**\n * @module test.ts\n * @changed 2024.04.04, 16:19\n */\n\n// console.log('Test', window);\n"]} \ No newline at end of file +{"version":3,"sources":["src/assets/scripts.ts","src/assets/stripe-init/stripe_payment_intents_support.ts","src/assets/test/test.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;;;;ACJH;;;GAGG;;;;;IAUH,kBAAkB;IAClB,SAAS,gBAAgB,CACvB,MAAc,EACd,MAAoC,EACpC,QAAwB,EACxB,KAAkB;QAEV,IAAA,WAAW,GAAK,MAAM,YAAX,CAAY;QAE/B,KAAK,CAAC,cAAc,EAAE,CAAC;QAEvB,qGAAqG;QACrG,oFAAoF;QACpF,MAAM;aACH,cAAc,CAAC;YACd,QAAQ,UAAA;YACR,aAAa,EAAE;gBACb,UAAU,EAAE,WAAW;aACxB;SACF,CAAC;aACD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,IAAM,QAAQ,GAAmB,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QAE1D,uCAAuC;QACvC,yEAAyE;QACzE,IAAM,cAAc,GAAyB,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QACxE,cAAc,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC;QAEzC,IAAM,IAAI,GAAG,QAAQ,CAAC,cAAc,CAAC,cAAc,CAAC,CAAC;QAErD,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,IAAM,SAAS,GAAG,+BAA+B,CAAC;YAClD,IAAM,KAAK,GAAG,IAAI,KAAK,CAAC,SAAS,CAAC,CAAC;YACnC,OAAO,CAAC,KAAK,CAAC,gEAAgE,EAAE,SAAS,EAAE;gBACzF,KAAK,OAAA;gBACL,MAAM,QAAA;gBACN,MAAM,QAAA;gBACN,OAAO,SAAA;gBACP,QAAQ,UAAA;gBACR,cAAc,gBAAA;gBACd,IAAI,MAAA;aACL,CAAC,CAAC;YACH,uCAAuC;YACvC,QAAQ,CAAC;YACT,OAAO;QACT,CAAC;QAED,IAAI,CAAC,gBAAgB,CAAC,QAAQ,EAAE,gBAAgB,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;IACzF,CAAC;IA7CD,0DA6CC;;AC7HD;;;GAGG;AAEH,+BAA+B","file":"scripts.js","sourcesContent":["/**\n * @desc Main js entry point module (scripts)\n * @module src/assets/scripts.ts\n * @changed 2024.04.06, 22:00\n */\n\n/* // NOTE: These modules are unused. Used only\n * // `src/assets/stripe-init/stripe_payment_intents_support.ts`, via requirejs,\n * // without exposing to global scope.\n *\n * import { startStripeElementsForm } from './stripe-init/stripe_payment_intents_support';\n *\n * console.log('[scripts] Main client code entry point', {\n * startStripeElementsForm,\n * });\n */\n\n// Empty root module\nexport {};\n","/**\n * @module stripe_payment_intents_support.ts\n * @changed 2024.04.04, 00:21\n */\n\nimport type {\n Stripe,\n StripeElements,\n StripeElementsOptionsClientSecret,\n StripeError,\n StripePaymentElement,\n} from '@stripe/stripe-js/dist/stripe-js';\n\n/** Form action */\nfunction submitStripeForm(\n stripe: Stripe,\n params: TCreateCheckoutSessionParams,\n elements: StripeElements,\n event: SubmitEvent,\n) {\n const { success_url } = params;\n\n event.preventDefault();\n\n // @see https://docs.stripe.com/payments/accept-a-payment?platform=web&ui=elements#web-submit-payment\n // TODO: Show 'busy' spinner at stripe interaction begin? (It could take some time.)\n stripe\n .confirmPayment({\n elements,\n confirmParams: {\n return_url: success_url,\n },\n })\n .then((result) => {\n const error: StripeError = result.error;\n\n if (error) {\n console.error(\n '[stripe_payment_intents_support:startStripeElementsForm:submitStripeForm] error',\n {\n error,\n event,\n params,\n stripe,\n },\n );\n\n // Show error\n const messageContainer = document.querySelector('#error-message');\n if (messageContainer) {\n messageContainer.textContent = error.message || '';\n }\n } else {\n // Success: redirect to success message\n console.log(\n '[stripe_payment_intents_support:startStripeElementsForm:submitStripeForm] success',\n {\n success_url,\n event,\n params,\n stripe,\n },\n );\n window.location.href = success_url;\n }\n })\n .catch((error) => {\n console.error(\n '[stripe_payment_intents_support:startStripeElementsForm:submitStripeForm] error',\n {\n error,\n event,\n params,\n stripe,\n },\n );\n });\n}\n\n/** Start stripe payment form */\nexport function startStripeElementsForm(params: TCreateCheckoutSessionParams) {\n const {\n STRIPE_PUBLISHABLE_KEY,\n // success_url,\n client_secret,\n } = params;\n\n // Initialize Stripe.js\n const stripe: Stripe = window.Stripe(STRIPE_PUBLISHABLE_KEY);\n\n // @see https://docs.stripe.com/js/elements_object/create_payment_element#payment_element_create-options\n const options: StripeElementsOptionsClientSecret = {\n clientSecret: client_secret,\n // TODO: Customize forms (use bootstrap styles)...\n // appearance: {},\n };\n\n // Set up Stripe.js and Elements to use in checkout form, passing the client secret obtained in a previous step\n const elements: StripeElements = stripe.elements(options);\n\n // Create and mount the Payment Element\n // @see https://docs.stripe.com/js/elements_object/create_payment_element\n const paymentElement: StripePaymentElement = elements.create('payment');\n paymentElement.mount('#payment-element');\n\n const form = document.getElementById('payment-form');\n\n if (!form) {\n const errorText = 'Form node could not be found!';\n const error = new Error(errorText);\n console.error('[stripe_payment_intents_support:startStripeElementsForm] error', errorText, {\n error,\n params,\n stripe,\n options,\n elements,\n paymentElement,\n form,\n });\n // eslint-disable-next-line no-debugger\n debugger;\n return;\n }\n\n form.addEventListener('submit', submitStripeForm.bind(null, stripe, params, elements));\n}\n","/**\n * @module test.ts\n * @changed 2024.04.04, 16:19\n */\n\n// console.log('Test', window);\n"]} \ No newline at end of file