@kizlo/woocommerce 0.6.1 → 0.7.0

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/dist/index.d.ts CHANGED
@@ -1042,6 +1042,8 @@ declare const ConfirmCheckoutInput: z$2.ZodObject<{
1042
1042
  }, z$2.core.$strip>>>;
1043
1043
  additionalFields: z$2.ZodOptional<z$2.ZodRecord<z$2.ZodString, z$2.ZodUnion<readonly [z$2.ZodString, z$2.ZodBoolean]>>>;
1044
1044
  extensions: z$2.ZodOptional<z$2.ZodRecord<z$2.ZodString, z$2.ZodUnknown>>;
1045
+ successPath: z$2.ZodOptional<z$2.ZodString>;
1046
+ cancelPath: z$2.ZodOptional<z$2.ZodString>;
1045
1047
  }, z$2.core.$strip>;
1046
1048
  type ConfirmCheckoutInput = z$2.input<typeof ConfirmCheckoutInput>;
1047
1049
  declare const RetryCheckoutInput: z$2.ZodObject<{
@@ -1083,6 +1085,8 @@ declare const RetryCheckoutInput: z$2.ZodObject<{
1083
1085
  customerNote: z$2.ZodOptional<z$2.ZodString>;
1084
1086
  additionalFields: z$2.ZodOptional<z$2.ZodRecord<z$2.ZodString, z$2.ZodUnion<readonly [z$2.ZodString, z$2.ZodBoolean]>>>;
1085
1087
  extensions: z$2.ZodOptional<z$2.ZodRecord<z$2.ZodString, z$2.ZodUnknown>>;
1088
+ successPath: z$2.ZodOptional<z$2.ZodString>;
1089
+ cancelPath: z$2.ZodOptional<z$2.ZodString>;
1086
1090
  }, z$2.core.$strip>;
1087
1091
  type RetryCheckoutInput = z$2.input<typeof RetryCheckoutInput>;
1088
1092
  //#endregion
@@ -8486,6 +8490,8 @@ declare function woocommerce(): kizlo0.Integration<"woocommerce", {
8486
8490
  }[] | undefined;
8487
8491
  additionalFields?: Record<string, string | boolean> | undefined;
8488
8492
  extensions?: Record<string, unknown> | undefined;
8493
+ successPath?: string | undefined;
8494
+ cancelPath?: string | undefined;
8489
8495
  };
8490
8496
  }, {
8491
8497
  orderId: number | null;
@@ -11067,6 +11073,8 @@ declare function woocommerce(): kizlo0.Integration<"woocommerce", {
11067
11073
  key: string;
11068
11074
  value: string | boolean;
11069
11075
  }[] | undefined;
11076
+ successPath?: string | undefined;
11077
+ cancelPath?: string | undefined;
11070
11078
  billingEmail?: string | undefined;
11071
11079
  };
11072
11080
  params: {
package/dist/index.js CHANGED
@@ -1574,6 +1574,7 @@ const CheckoutPaymentData = z$2.array(z$2.object({
1574
1574
  key: z$2.string(),
1575
1575
  value: z$2.union([z$2.string(), z$2.boolean()])
1576
1576
  }));
1577
+ const RelativePath = z$2.string().refine((value) => /^\/(?![/\\])/.test(value), "must be a relative path starting with a single '/'");
1577
1578
  const CheckoutPaymentResult = z$2.object({
1578
1579
  status: z$2.string(),
1579
1580
  details: z$2.array(z$2.object({
@@ -1613,7 +1614,9 @@ const ConfirmCheckoutInput = z$2.object({
1613
1614
  customerPassword: z$2.string().optional(),
1614
1615
  paymentData: CheckoutPaymentData.optional(),
1615
1616
  additionalFields: CheckoutAdditionalFields.optional(),
1616
- extensions: CheckoutExtensions.optional()
1617
+ extensions: CheckoutExtensions.optional(),
1618
+ successPath: RelativePath.optional(),
1619
+ cancelPath: RelativePath.optional()
1617
1620
  });
1618
1621
  const RetryCheckoutInput = z$2.object({
1619
1622
  key: z$2.string(),
@@ -1625,7 +1628,9 @@ const RetryCheckoutInput = z$2.object({
1625
1628
  shippingAddress: CartShippingAddress.optional(),
1626
1629
  customerNote: z$2.string().optional(),
1627
1630
  additionalFields: CheckoutAdditionalFields.optional(),
1628
- extensions: CheckoutExtensions.optional()
1631
+ extensions: CheckoutExtensions.optional(),
1632
+ successPath: RelativePath.optional(),
1633
+ cancelPath: RelativePath.optional()
1629
1634
  });
1630
1635
 
1631
1636
  //#endregion
@@ -1661,6 +1666,27 @@ function deserializeCheckout(data) {
1661
1666
  extensions
1662
1667
  };
1663
1668
  }
1669
+ /**
1670
+ * Fold the per-checkout redirect paths into `extensions.kizlo` so WooCommerce can
1671
+ * stamp them on the order and redirect there after checkout. Only defined paths
1672
+ * are added, and any existing `extensions.kizlo` block a caller passed is kept.
1673
+ * Returns the extensions unchanged when neither path is set.
1674
+ */
1675
+ function withKizloRedirectPaths(extensions, paths) {
1676
+ const kizlo = {};
1677
+ if (paths.successPath !== void 0) kizlo.success_path = paths.successPath;
1678
+ if (paths.cancelPath !== void 0) kizlo.cancel_path = paths.cancelPath;
1679
+ if (Object.keys(kizlo).length === 0) return extensions;
1680
+ const existing = extensions?.kizlo;
1681
+ const existingKizlo = typeof existing === "object" && existing !== null && !Array.isArray(existing) ? existing : {};
1682
+ return {
1683
+ ...extensions,
1684
+ kizlo: {
1685
+ ...existingKizlo,
1686
+ ...kizlo
1687
+ }
1688
+ };
1689
+ }
1664
1690
  function serializeCheckoutShippingAddress(address) {
1665
1691
  return serializeCartShippingAddress(address);
1666
1692
  }
@@ -1761,7 +1787,10 @@ const CHECKOUT_PROCEDURES = {
1761
1787
  customer_password: input.body.customerPassword,
1762
1788
  payment_data: input.body.paymentData,
1763
1789
  additional_fields: input.body.additionalFields,
1764
- extensions: input.body.extensions
1790
+ extensions: withKizloRedirectPaths(input.body.extensions, {
1791
+ successPath: input.body.successPath,
1792
+ cancelPath: input.body.cancelPath
1793
+ })
1765
1794
  }, { headers: context.sessionHeaders });
1766
1795
  if (response.error) {
1767
1796
  const conflict = conflictData(response.error.data);
@@ -1844,7 +1873,10 @@ const CHECKOUT_PROCEDURES = {
1844
1873
  shipping_address: input.body.shippingAddress ? serializeCheckoutShippingAddress(input.body.shippingAddress) : void 0,
1845
1874
  customer_note: input.body.customerNote,
1846
1875
  additional_fields: input.body.additionalFields,
1847
- extensions: input.body.extensions
1876
+ extensions: withKizloRedirectPaths(input.body.extensions, {
1877
+ successPath: input.body.successPath,
1878
+ cancelPath: input.body.cancelPath
1879
+ })
1848
1880
  }, { headers: context.sessionHeaders });
1849
1881
  if (response.error) switch (response.error.code) {
1850
1882
  case "rest_invalid_param": throw errors.CHECKOUT_VALIDATION_FAILED({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kizlo/woocommerce",
3
- "version": "0.6.1",
3
+ "version": "0.7.0",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "description": "WooCommerce integration for Kizlo.",