@gomusdev/web-components 4.9.0 → 4.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 4.9.1 (2026-07-20)
4
+
5
+ ### Bug Fixes
6
+
7
+ * **checkoutForm:** handle meta.status and payment_data on checkout, closes [#152](https://gitlab.giantmonkey.de/gomus/frontend/issues/152)
8
+
3
9
  ## 4.9.0 (2026-07-16)
4
10
 
5
11
  ### Features
@@ -12238,6 +12238,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
12238
12238
  };
12239
12239
  return {
12240
12240
  ...finalOptions,
12241
+ quantity: finalOptions.quantity ?? 0,
12242
+ time: finalOptions.time ?? "",
12241
12243
  type: product.type,
12242
12244
  product,
12243
12245
  /**
@@ -12297,7 +12299,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
12297
12299
  return this.uuid + ":" + this.quantity;
12298
12300
  },
12299
12301
  get price_cents() {
12300
- if (this.time && this.product.dynamic_prices?.[this.time] != null) return this.product.dynamic_prices[this.time];
12302
+ const dynamicPrices = "dynamic_prices" in this.product ? this.product.dynamic_prices : null;
12303
+ if (this.time && dynamicPrices?.[this.time] != null) return dynamicPrices[this.time];
12301
12304
  return this.product.price_cents;
12302
12305
  },
12303
12306
  get price_formatted() {
@@ -12480,10 +12483,18 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
12480
12483
  //#region src/lib/models/cart/cart.svelte.ts
12481
12484
  var lastUuid = 0;
12482
12485
  function createCart(products, contingent = 20) {
12486
+ const items = proxy([]);
12487
+ const coupons = proxy([]);
12488
+ let paymentModeId = /* @__PURE__ */ state(void 0);
12483
12489
  const cart = {
12484
- items: proxy([]),
12485
- coupons: proxy([]),
12486
- paymentModeId: void 0,
12490
+ items,
12491
+ coupons,
12492
+ get paymentModeId() {
12493
+ return get$2(paymentModeId);
12494
+ },
12495
+ set paymentModeId(value) {
12496
+ set(paymentModeId, value, true);
12497
+ },
12487
12498
  uid: `cart-${lastUuid++}`,
12488
12499
  get nonEmptyItems() {
12489
12500
  return this.items.filter((i) => i.quantity > 0);
@@ -14695,7 +14706,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
14695
14706
  function AnnualTicketPersonalizationForm($$anchor, $$props) {
14696
14707
  push($$props, true);
14697
14708
  let token = prop($$props, "token", 7), ticketSaleId = prop($$props, "ticketSaleId", 7);
14698
- let form;
14709
+ let form = null;
14699
14710
  const details = new PersonalizationDetails();
14700
14711
  setPersonalizationDetails($$props.$$host, details);
14701
14712
  user_effect(() => {
@@ -14763,12 +14774,13 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
14763
14774
  } };
14764
14775
  const result = await shop.finalizePersonalizations(token(), body);
14765
14776
  if (result.error) {
14766
- form.details.apiErrors = [result.error.error];
14777
+ form.details.apiErrors = result.error.error ? [result.error.error] : [];
14767
14778
  return;
14768
14779
  }
14769
14780
  const beforeSubmit = configStore.config.forms.personalization?.beforeSubmit;
14770
14781
  if (beforeSubmit) beforeSubmit(body);
14771
- if (configStore.config.urls.annualTicketPersonalizationFormSubmit?.()) configStore.config.navigateTo(configStore.config.urls.annualTicketPersonalizationFormSubmit());
14782
+ const submitUrl = configStore.config.urls.annualTicketPersonalizationFormSubmit?.(token());
14783
+ if (submitUrl) configStore.config.navigateTo(submitUrl);
14772
14784
  }
14773
14785
  let templateForm = null;
14774
14786
  let templateBlueprint = null;
@@ -18511,6 +18523,20 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
18511
18523
  customElements.define("go-cart-counter", create_custom_element(CartCounter, {}, [], []));
18512
18524
  //#endregion
18513
18525
  //#region src/components/checkoutForm/lib.ts
18526
+ function postToPaymentProvider(paymentData) {
18527
+ const form = document.createElement("form");
18528
+ form.method = "post";
18529
+ form.action = paymentData.url;
18530
+ for (const [key, value] of Object.entries(paymentData.params)) {
18531
+ const input = document.createElement("input");
18532
+ input.type = "hidden";
18533
+ input.name = key;
18534
+ input.value = String(value);
18535
+ form.appendChild(input);
18536
+ }
18537
+ document.body.appendChild(form);
18538
+ form.submit();
18539
+ }
18514
18540
  async function finalizeCheckout(form, formId) {
18515
18541
  const cart = shop.cart;
18516
18542
  if (!cart) return;
@@ -18523,8 +18549,13 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
18523
18549
  }
18524
18550
  const beforeSubmit = configStore.config.forms[formId]?.beforeSubmit;
18525
18551
  if (beforeSubmit) await beforeSubmit(form.details.formData);
18526
- const paymentUrl = checkout.data.meta.payment_url;
18527
- configStore.config.navigateTo?.(paymentUrl);
18552
+ const meta = checkout.data.meta;
18553
+ const navigateTo = configStore.config.navigateTo;
18554
+ if (meta.status === "success") navigateTo?.(shop.urls.checkoutSuccess(checkout.data.order.token));
18555
+ else if (meta.status === "fail") navigateTo?.(shop.urls.checkoutFailure(""));
18556
+ else if (meta.payment_url) navigateTo?.(meta.payment_url);
18557
+ else if (meta.payment_data) postToPaymentProvider(meta.payment_data);
18558
+ else navigateTo?.(shop.urls.checkoutFailure(""));
18528
18559
  }
18529
18560
  function setupGuestCheckout(host, custom) {
18530
18561
  Forms.defineForm({
@@ -12237,6 +12237,8 @@ function createCartItem(product, options) {
12237
12237
  };
12238
12238
  return {
12239
12239
  ...finalOptions,
12240
+ quantity: finalOptions.quantity ?? 0,
12241
+ time: finalOptions.time ?? "",
12240
12242
  type: product.type,
12241
12243
  product,
12242
12244
  /**
@@ -12296,7 +12298,8 @@ function createCartItem(product, options) {
12296
12298
  return this.uuid + ":" + this.quantity;
12297
12299
  },
12298
12300
  get price_cents() {
12299
- if (this.time && this.product.dynamic_prices?.[this.time] != null) return this.product.dynamic_prices[this.time];
12301
+ const dynamicPrices = "dynamic_prices" in this.product ? this.product.dynamic_prices : null;
12302
+ if (this.time && dynamicPrices?.[this.time] != null) return dynamicPrices[this.time];
12300
12303
  return this.product.price_cents;
12301
12304
  },
12302
12305
  get price_formatted() {
@@ -12479,10 +12482,18 @@ var defined = (x) => x !== void 0;
12479
12482
  //#region src/lib/models/cart/cart.svelte.ts
12480
12483
  var lastUuid = 0;
12481
12484
  function createCart(products, contingent = 20) {
12485
+ const items = proxy([]);
12486
+ const coupons = proxy([]);
12487
+ let paymentModeId = /* @__PURE__ */ state(void 0);
12482
12488
  const cart = {
12483
- items: proxy([]),
12484
- coupons: proxy([]),
12485
- paymentModeId: void 0,
12489
+ items,
12490
+ coupons,
12491
+ get paymentModeId() {
12492
+ return get$2(paymentModeId);
12493
+ },
12494
+ set paymentModeId(value) {
12495
+ set(paymentModeId, value, true);
12496
+ },
12486
12497
  uid: `cart-${lastUuid++}`,
12487
12498
  get nonEmptyItems() {
12488
12499
  return this.items.filter((i) => i.quantity > 0);
@@ -14694,7 +14705,7 @@ function errors(fields) {
14694
14705
  function AnnualTicketPersonalizationForm($$anchor, $$props) {
14695
14706
  push($$props, true);
14696
14707
  let token = prop($$props, "token", 7), ticketSaleId = prop($$props, "ticketSaleId", 7);
14697
- let form;
14708
+ let form = null;
14698
14709
  const details = new PersonalizationDetails();
14699
14710
  setPersonalizationDetails($$props.$$host, details);
14700
14711
  user_effect(() => {
@@ -14762,12 +14773,13 @@ function AnnualTicketPersonalizationForm($$anchor, $$props) {
14762
14773
  } };
14763
14774
  const result = await shop.finalizePersonalizations(token(), body);
14764
14775
  if (result.error) {
14765
- form.details.apiErrors = [result.error.error];
14776
+ form.details.apiErrors = result.error.error ? [result.error.error] : [];
14766
14777
  return;
14767
14778
  }
14768
14779
  const beforeSubmit = configStore.config.forms.personalization?.beforeSubmit;
14769
14780
  if (beforeSubmit) beforeSubmit(body);
14770
- if (configStore.config.urls.annualTicketPersonalizationFormSubmit?.()) configStore.config.navigateTo(configStore.config.urls.annualTicketPersonalizationFormSubmit());
14781
+ const submitUrl = configStore.config.urls.annualTicketPersonalizationFormSubmit?.(token());
14782
+ if (submitUrl) configStore.config.navigateTo(submitUrl);
14771
14783
  }
14772
14784
  let templateForm = null;
14773
14785
  let templateBlueprint = null;
@@ -18510,6 +18522,20 @@ function CartCounter($$anchor, $$props) {
18510
18522
  customElements.define("go-cart-counter", create_custom_element(CartCounter, {}, [], []));
18511
18523
  //#endregion
18512
18524
  //#region src/components/checkoutForm/lib.ts
18525
+ function postToPaymentProvider(paymentData) {
18526
+ const form = document.createElement("form");
18527
+ form.method = "post";
18528
+ form.action = paymentData.url;
18529
+ for (const [key, value] of Object.entries(paymentData.params)) {
18530
+ const input = document.createElement("input");
18531
+ input.type = "hidden";
18532
+ input.name = key;
18533
+ input.value = String(value);
18534
+ form.appendChild(input);
18535
+ }
18536
+ document.body.appendChild(form);
18537
+ form.submit();
18538
+ }
18513
18539
  async function finalizeCheckout(form, formId) {
18514
18540
  const cart = shop.cart;
18515
18541
  if (!cart) return;
@@ -18522,8 +18548,13 @@ async function finalizeCheckout(form, formId) {
18522
18548
  }
18523
18549
  const beforeSubmit = configStore.config.forms[formId]?.beforeSubmit;
18524
18550
  if (beforeSubmit) await beforeSubmit(form.details.formData);
18525
- const paymentUrl = checkout.data.meta.payment_url;
18526
- configStore.config.navigateTo?.(paymentUrl);
18551
+ const meta = checkout.data.meta;
18552
+ const navigateTo = configStore.config.navigateTo;
18553
+ if (meta.status === "success") navigateTo?.(shop.urls.checkoutSuccess(checkout.data.order.token));
18554
+ else if (meta.status === "fail") navigateTo?.(shop.urls.checkoutFailure(""));
18555
+ else if (meta.payment_url) navigateTo?.(meta.payment_url);
18556
+ else if (meta.payment_data) postToPaymentProvider(meta.payment_data);
18557
+ else navigateTo?.(shop.urls.checkoutFailure(""));
18527
18558
  }
18528
18559
  function setupGuestCheckout(host, custom) {
18529
18560
  Forms.defineForm({