@kizlo/woocommerce 0.14.1 → 0.15.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/README.md +22 -0
- package/dist/index.d.ts +314 -0
- package/dist/index.js +29 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -70,6 +70,28 @@ Storefront field definitions include SDK binding paths derived from the same add
|
|
|
70
70
|
|
|
71
71
|
Update, confirm, and retry expose `CHECKOUT_VALIDATION_FAILED.data = { issues }`. Registered fields carry literal IDs and normalized SDK buckets for Kit or standalone consumers to match against loaded bindings. The browser entry retains schemas/types; the SDK resolver is removed. See [client handling and Kit requirements](./docs/checkout-validation.md) and the [breaking handler migration](./docs/checkout-validation-migration.md).
|
|
72
72
|
|
|
73
|
+
## Protect a reviewed checkout total
|
|
74
|
+
|
|
75
|
+
Pass optional `expectedTotal` when confirming checkout to protect the amount your shopper reviewed. Capture it with the cart you display, in minor units: `"1250"` means 12.50 in a currency with two decimal places. The input accepts digits-only strings, including `"0"`, and forwards them unchanged as WooCommerce's `expected_total`.
|
|
76
|
+
|
|
77
|
+
```ts
|
|
78
|
+
const reviewedTotal = String(cart.totals.total)
|
|
79
|
+
|
|
80
|
+
const result = await kizlo.client.woocommerce.checkout.confirm({
|
|
81
|
+
body: { ...checkoutInput, expectedTotal: reviewedTotal },
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
if (!result.success && result.error.code === "CHECKOUT_TOTAL_MISMATCH") {
|
|
85
|
+
const { cart: updatedCart, expectedTotal, actualTotal } = result.error.data
|
|
86
|
+
// Display the available evidence and ask the shopper to review again.
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Upgrade `kizlo` to 0.26.1 or later alongside `@kizlo/woocommerce` so browser clients preserve the typed conflict. This protection requires [WooCommerce 11.1.0 or later](https://github.com/woocommerce/woocommerce/blob/11.1.0/plugins/woocommerce/src/StoreApi/Routes/V1/Checkout.php). An increased recalculated total returns `CHECKOUT_TOTAL_MISMATCH` with status 409 before order creation or payment; equal and decreased totals are allowed. Error data contains `cart: Cart | null` and optional minor-unit digit strings `expectedTotal` and `actualTotal`; missing or malformed evidence preserves the conflict. Omit the field for manual or express flows that cannot know the total up front, and on older WooCommerce versions that do not enforce it.
|
|
91
|
+
|
|
92
|
+
- Keep the reviewed amount until the shopper approves a new one. Confirmation performs no cart refresh, amount substitution, or automatic retry.
|
|
93
|
+
- `checkout.retry` pays an existing order through a separate protocol and does not accept `expectedTotal`.
|
|
94
|
+
|
|
73
95
|
## Storefront settings
|
|
74
96
|
|
|
75
97
|
`storefront.get` returns the store-wide settings a storefront renders with, so nothing has to be hardcoded:
|
package/dist/index.d.ts
CHANGED
|
@@ -478,6 +478,319 @@ declare const CONFIRM_CHECKOUT_ERROR_MAP: {
|
|
|
478
478
|
}, z$2.core.$strip>>;
|
|
479
479
|
}, z$2.core.$strip>;
|
|
480
480
|
};
|
|
481
|
+
readonly CHECKOUT_TOTAL_MISMATCH: {
|
|
482
|
+
readonly status: 409;
|
|
483
|
+
readonly message: "The order total increased. Please review the updated total.";
|
|
484
|
+
readonly data: z$2.ZodObject<{
|
|
485
|
+
cart: z$2.ZodNullable<z$2.ZodObject<{
|
|
486
|
+
items: z$2.ZodArray<z$2.ZodObject<{
|
|
487
|
+
key: z$2.ZodString;
|
|
488
|
+
productId: z$2.ZodNumber;
|
|
489
|
+
variationId: z$2.ZodNullable<z$2.ZodNumber>;
|
|
490
|
+
type: z$2.ZodString;
|
|
491
|
+
name: z$2.ZodString;
|
|
492
|
+
sku: z$2.ZodNullable<z$2.ZodString>;
|
|
493
|
+
slug: z$2.ZodString;
|
|
494
|
+
url: z$2.ZodNullable<z$2.ZodString>;
|
|
495
|
+
shortDescription: z$2.ZodString;
|
|
496
|
+
description: z$2.ZodString;
|
|
497
|
+
quantity: z$2.ZodNumber;
|
|
498
|
+
quantityLimits: z$2.ZodObject<{
|
|
499
|
+
minimum: z$2.ZodNumber;
|
|
500
|
+
maximum: z$2.ZodNumber;
|
|
501
|
+
multipleOf: z$2.ZodNumber;
|
|
502
|
+
editable: z$2.ZodBoolean;
|
|
503
|
+
}, z$2.core.$strip>;
|
|
504
|
+
lowStockRemaining: z$2.ZodNullable<z$2.ZodNumber>;
|
|
505
|
+
allowsBackorders: z$2.ZodBoolean;
|
|
506
|
+
showsBackorderBadge: z$2.ZodBoolean;
|
|
507
|
+
isSoldIndividually: z$2.ZodBoolean;
|
|
508
|
+
catalogVisibility: z$2.ZodString;
|
|
509
|
+
images: z$2.ZodArray<z$2.ZodObject<{
|
|
510
|
+
id: z$2.ZodNumber;
|
|
511
|
+
name: z$2.ZodString;
|
|
512
|
+
src: z$2.ZodString;
|
|
513
|
+
mime: z$2.ZodOptional<z$2.ZodString>;
|
|
514
|
+
type: z$2.ZodLiteral<"image">;
|
|
515
|
+
alt: z$2.ZodString;
|
|
516
|
+
width: z$2.ZodOptional<z$2.ZodNumber>;
|
|
517
|
+
height: z$2.ZodOptional<z$2.ZodNumber>;
|
|
518
|
+
variants: z$2.ZodOptional<z$2.ZodArray<z$2.ZodObject<{
|
|
519
|
+
src: z$2.ZodString;
|
|
520
|
+
width: z$2.ZodNumber;
|
|
521
|
+
height: z$2.ZodNumber;
|
|
522
|
+
}, z$2.core.$strict>>>;
|
|
523
|
+
srcset: z$2.ZodOptional<z$2.ZodString>;
|
|
524
|
+
}, z$2.core.$strict>>;
|
|
525
|
+
selectedAttributes: z$2.ZodArray<z$2.ZodObject<{
|
|
526
|
+
name: z$2.ZodString;
|
|
527
|
+
attribute: z$2.ZodString;
|
|
528
|
+
value: z$2.ZodString;
|
|
529
|
+
}, z$2.core.$strip>>;
|
|
530
|
+
itemData: z$2.ZodArray<z$2.ZodObject<{
|
|
531
|
+
name: z$2.ZodString;
|
|
532
|
+
value: z$2.ZodString;
|
|
533
|
+
display: z$2.ZodNullable<z$2.ZodString>;
|
|
534
|
+
}, z$2.core.$strip>>;
|
|
535
|
+
prices: z$2.ZodObject<{
|
|
536
|
+
price: z$2.ZodNumber;
|
|
537
|
+
regularPrice: z$2.ZodNumber;
|
|
538
|
+
salePrice: z$2.ZodNullable<z$2.ZodNumber>;
|
|
539
|
+
priceRange: z$2.ZodNullable<z$2.ZodObject<{
|
|
540
|
+
minAmount: z$2.ZodNumber;
|
|
541
|
+
maxAmount: z$2.ZodNumber;
|
|
542
|
+
}, z$2.core.$strip>>;
|
|
543
|
+
}, z$2.core.$strip>;
|
|
544
|
+
totals: z$2.ZodObject<{
|
|
545
|
+
subtotal: z$2.ZodNumber;
|
|
546
|
+
subtotalTax: z$2.ZodNumber;
|
|
547
|
+
total: z$2.ZodNumber;
|
|
548
|
+
totalTax: z$2.ZodNumber;
|
|
549
|
+
}, z$2.core.$strip>;
|
|
550
|
+
custom: z$2.ZodType<Record<string, unknown>, Record<string, unknown>, z$2.core.$ZodTypeInternals<Record<string, unknown>, Record<string, unknown>>>;
|
|
551
|
+
extensions: z$2.ZodRecord<z$2.ZodString, z$2.ZodUnknown>;
|
|
552
|
+
}, z$2.core.$strip>>;
|
|
553
|
+
itemCount: z$2.ZodNumber;
|
|
554
|
+
itemsWeight: z$2.ZodNumber;
|
|
555
|
+
billingAddress: z$2.ZodObject<{
|
|
556
|
+
additionalFields: z$2.ZodType<BillingAdditionalFields, BillingAdditionalFieldsInput, z$2.core.$ZodTypeInternals<BillingAdditionalFields, BillingAdditionalFieldsInput>>;
|
|
557
|
+
taxId: z$2.ZodDefault<z$2.ZodString>;
|
|
558
|
+
email: z$2.ZodString;
|
|
559
|
+
firstName: z$2.ZodString;
|
|
560
|
+
lastName: z$2.ZodString;
|
|
561
|
+
company: z$2.ZodString;
|
|
562
|
+
address1: z$2.ZodString;
|
|
563
|
+
address2: z$2.ZodString;
|
|
564
|
+
city: z$2.ZodString;
|
|
565
|
+
state: z$2.ZodString;
|
|
566
|
+
postcode: z$2.ZodString;
|
|
567
|
+
country: z$2.ZodString;
|
|
568
|
+
phone: z$2.ZodString;
|
|
569
|
+
}, z$2.core.$strip>;
|
|
570
|
+
shippingAddress: z$2.ZodObject<{
|
|
571
|
+
firstName: z$2.ZodString;
|
|
572
|
+
lastName: z$2.ZodString;
|
|
573
|
+
company: z$2.ZodString;
|
|
574
|
+
address1: z$2.ZodString;
|
|
575
|
+
address2: z$2.ZodString;
|
|
576
|
+
city: z$2.ZodString;
|
|
577
|
+
state: z$2.ZodString;
|
|
578
|
+
postcode: z$2.ZodString;
|
|
579
|
+
country: z$2.ZodString;
|
|
580
|
+
phone: z$2.ZodString;
|
|
581
|
+
additionalFields: z$2.ZodType<{
|
|
582
|
+
[x: string]: string | boolean | undefined;
|
|
583
|
+
}, Partial<{
|
|
584
|
+
[x: string]: string | boolean | undefined;
|
|
585
|
+
}>, z$2.core.$ZodTypeInternals<{
|
|
586
|
+
[x: string]: string | boolean | undefined;
|
|
587
|
+
}, Partial<{
|
|
588
|
+
[x: string]: string | boolean | undefined;
|
|
589
|
+
}>>>;
|
|
590
|
+
}, z$2.core.$strip>;
|
|
591
|
+
shippingPackages: z$2.ZodArray<z$2.ZodObject<{
|
|
592
|
+
id: z$2.ZodUnion<readonly [z$2.ZodNumber, z$2.ZodString]>;
|
|
593
|
+
name: z$2.ZodString;
|
|
594
|
+
destination: z$2.ZodObject<{
|
|
595
|
+
address1: z$2.ZodString;
|
|
596
|
+
address2: z$2.ZodString;
|
|
597
|
+
city: z$2.ZodString;
|
|
598
|
+
state: z$2.ZodString;
|
|
599
|
+
postcode: z$2.ZodString;
|
|
600
|
+
country: z$2.ZodString;
|
|
601
|
+
}, z$2.core.$strip>;
|
|
602
|
+
items: z$2.ZodArray<z$2.ZodObject<{
|
|
603
|
+
key: z$2.ZodString;
|
|
604
|
+
name: z$2.ZodString;
|
|
605
|
+
quantity: z$2.ZodNumber;
|
|
606
|
+
}, z$2.core.$strip>>;
|
|
607
|
+
rates: z$2.ZodArray<z$2.ZodObject<{
|
|
608
|
+
id: z$2.ZodString;
|
|
609
|
+
name: z$2.ZodString;
|
|
610
|
+
description: z$2.ZodString;
|
|
611
|
+
deliveryTime: z$2.ZodString;
|
|
612
|
+
price: z$2.ZodNumber;
|
|
613
|
+
taxes: z$2.ZodNumber;
|
|
614
|
+
methodId: z$2.ZodString;
|
|
615
|
+
instanceId: z$2.ZodNumber;
|
|
616
|
+
metadata: z$2.ZodArray<z$2.ZodObject<{
|
|
617
|
+
key: z$2.ZodString;
|
|
618
|
+
value: z$2.ZodString;
|
|
619
|
+
}, z$2.core.$strip>>;
|
|
620
|
+
selected: z$2.ZodBoolean;
|
|
621
|
+
}, z$2.core.$strip>>;
|
|
622
|
+
}, z$2.core.$strip>>;
|
|
623
|
+
coupons: z$2.ZodArray<z$2.ZodObject<{
|
|
624
|
+
code: z$2.ZodString;
|
|
625
|
+
discountType: z$2.ZodString;
|
|
626
|
+
totals: z$2.ZodObject<{
|
|
627
|
+
discount: z$2.ZodNumber;
|
|
628
|
+
discountTax: z$2.ZodNumber;
|
|
629
|
+
}, z$2.core.$strip>;
|
|
630
|
+
}, z$2.core.$strip>>;
|
|
631
|
+
fees: z$2.ZodArray<z$2.ZodObject<{
|
|
632
|
+
id: z$2.ZodString;
|
|
633
|
+
name: z$2.ZodString;
|
|
634
|
+
totals: z$2.ZodObject<{
|
|
635
|
+
total: z$2.ZodNumber;
|
|
636
|
+
tax: z$2.ZodNumber;
|
|
637
|
+
}, z$2.core.$strip>;
|
|
638
|
+
}, z$2.core.$strip>>;
|
|
639
|
+
crossSells: z$2.ZodArray<z$2.ZodObject<{
|
|
640
|
+
id: z$2.ZodNumber;
|
|
641
|
+
name: z$2.ZodString;
|
|
642
|
+
slug: z$2.ZodString;
|
|
643
|
+
parentId: z$2.ZodNullable<z$2.ZodNumber>;
|
|
644
|
+
type: z$2.ZodString;
|
|
645
|
+
variationDescription: z$2.ZodString;
|
|
646
|
+
url: z$2.ZodNullable<z$2.ZodString>;
|
|
647
|
+
sku: z$2.ZodNullable<z$2.ZodString>;
|
|
648
|
+
shortDescription: z$2.ZodString;
|
|
649
|
+
description: z$2.ZodString;
|
|
650
|
+
isPasswordProtected: z$2.ZodBoolean;
|
|
651
|
+
isOnSale: z$2.ZodBoolean;
|
|
652
|
+
prices: z$2.ZodObject<{
|
|
653
|
+
price: z$2.ZodNumber;
|
|
654
|
+
regularPrice: z$2.ZodNumber;
|
|
655
|
+
salePrice: z$2.ZodNullable<z$2.ZodNumber>;
|
|
656
|
+
priceRange: z$2.ZodNullable<z$2.ZodObject<{
|
|
657
|
+
minAmount: z$2.ZodNumber;
|
|
658
|
+
maxAmount: z$2.ZodNumber;
|
|
659
|
+
}, z$2.core.$strip>>;
|
|
660
|
+
}, z$2.core.$strip>;
|
|
661
|
+
currencyFormat: z$2.ZodObject<{
|
|
662
|
+
currencyCode: z$2.ZodString;
|
|
663
|
+
currencySymbol: z$2.ZodString;
|
|
664
|
+
currencyPrefix: z$2.ZodString;
|
|
665
|
+
currencySuffix: z$2.ZodString;
|
|
666
|
+
currencyMinorUnit: z$2.ZodNumber;
|
|
667
|
+
currencyDecimalSeparator: z$2.ZodString;
|
|
668
|
+
currencyThousandSeparator: z$2.ZodString;
|
|
669
|
+
}, z$2.core.$strip>;
|
|
670
|
+
priceHtml: z$2.ZodString;
|
|
671
|
+
averageRating: z$2.ZodNumber;
|
|
672
|
+
reviewCount: z$2.ZodNumber;
|
|
673
|
+
images: z$2.ZodArray<z$2.ZodObject<{
|
|
674
|
+
id: z$2.ZodNumber;
|
|
675
|
+
name: z$2.ZodString;
|
|
676
|
+
src: z$2.ZodString;
|
|
677
|
+
mime: z$2.ZodOptional<z$2.ZodString>;
|
|
678
|
+
type: z$2.ZodLiteral<"image">;
|
|
679
|
+
alt: z$2.ZodString;
|
|
680
|
+
width: z$2.ZodOptional<z$2.ZodNumber>;
|
|
681
|
+
height: z$2.ZodOptional<z$2.ZodNumber>;
|
|
682
|
+
variants: z$2.ZodOptional<z$2.ZodArray<z$2.ZodObject<{
|
|
683
|
+
src: z$2.ZodString;
|
|
684
|
+
width: z$2.ZodNumber;
|
|
685
|
+
height: z$2.ZodNumber;
|
|
686
|
+
}, z$2.core.$strict>>>;
|
|
687
|
+
srcset: z$2.ZodOptional<z$2.ZodString>;
|
|
688
|
+
}, z$2.core.$strict>>;
|
|
689
|
+
categories: z$2.ZodArray<z$2.ZodObject<{
|
|
690
|
+
id: z$2.ZodNumber;
|
|
691
|
+
name: z$2.ZodString;
|
|
692
|
+
slug: z$2.ZodString;
|
|
693
|
+
url: z$2.ZodNullable<z$2.ZodString>;
|
|
694
|
+
}, z$2.core.$strip>>;
|
|
695
|
+
tags: z$2.ZodArray<z$2.ZodObject<{
|
|
696
|
+
id: z$2.ZodNumber;
|
|
697
|
+
name: z$2.ZodString;
|
|
698
|
+
slug: z$2.ZodString;
|
|
699
|
+
url: z$2.ZodNullable<z$2.ZodString>;
|
|
700
|
+
}, z$2.core.$strip>>;
|
|
701
|
+
brands: z$2.ZodArray<z$2.ZodObject<{
|
|
702
|
+
id: z$2.ZodNumber;
|
|
703
|
+
name: z$2.ZodString;
|
|
704
|
+
slug: z$2.ZodString;
|
|
705
|
+
url: z$2.ZodNullable<z$2.ZodString>;
|
|
706
|
+
}, z$2.core.$strip>>;
|
|
707
|
+
attributes: z$2.ZodArray<z$2.ZodObject<{
|
|
708
|
+
id: z$2.ZodNumber;
|
|
709
|
+
name: z$2.ZodString;
|
|
710
|
+
taxonomy: z$2.ZodNullable<z$2.ZodString>;
|
|
711
|
+
hasVariations: z$2.ZodBoolean;
|
|
712
|
+
terms: z$2.ZodArray<z$2.ZodObject<{
|
|
713
|
+
id: z$2.ZodNumber;
|
|
714
|
+
name: z$2.ZodString;
|
|
715
|
+
slug: z$2.ZodString;
|
|
716
|
+
isDefault: z$2.ZodBoolean;
|
|
717
|
+
}, z$2.core.$strip>>;
|
|
718
|
+
}, z$2.core.$strip>>;
|
|
719
|
+
variations: z$2.ZodArray<z$2.ZodObject<{
|
|
720
|
+
id: z$2.ZodNumber;
|
|
721
|
+
attributes: z$2.ZodArray<z$2.ZodObject<{
|
|
722
|
+
name: z$2.ZodString;
|
|
723
|
+
value: z$2.ZodNullable<z$2.ZodString>;
|
|
724
|
+
}, z$2.core.$strip>>;
|
|
725
|
+
}, z$2.core.$strip>>;
|
|
726
|
+
groupedProductIds: z$2.ZodArray<z$2.ZodNumber>;
|
|
727
|
+
hasOptions: z$2.ZodBoolean;
|
|
728
|
+
isPurchasable: z$2.ZodBoolean;
|
|
729
|
+
isInStock: z$2.ZodBoolean;
|
|
730
|
+
isOnBackorder: z$2.ZodBoolean;
|
|
731
|
+
stockAvailability: z$2.ZodObject<{
|
|
732
|
+
text: z$2.ZodString;
|
|
733
|
+
class: z$2.ZodString;
|
|
734
|
+
}, z$2.core.$strip>;
|
|
735
|
+
lowStockRemaining: z$2.ZodNullable<z$2.ZodNumber>;
|
|
736
|
+
isSoldIndividually: z$2.ZodBoolean;
|
|
737
|
+
addToCart: z$2.ZodObject<{
|
|
738
|
+
text: z$2.ZodString;
|
|
739
|
+
description: z$2.ZodString;
|
|
740
|
+
singleText: z$2.ZodString;
|
|
741
|
+
minimum: z$2.ZodNumber;
|
|
742
|
+
maximum: z$2.ZodNumber;
|
|
743
|
+
multipleOf: z$2.ZodNumber;
|
|
744
|
+
}, z$2.core.$strip>;
|
|
745
|
+
extensions: z$2.ZodRecord<z$2.ZodString, z$2.ZodUnknown>;
|
|
746
|
+
}, z$2.core.$strip>>;
|
|
747
|
+
needsPayment: z$2.ZodBoolean;
|
|
748
|
+
needsShipping: z$2.ZodBoolean;
|
|
749
|
+
hasCalculatedShipping: z$2.ZodBoolean;
|
|
750
|
+
paymentMethods: z$2.ZodArray<z$2.ZodObject<{
|
|
751
|
+
id: z$2.ZodString;
|
|
752
|
+
title: z$2.ZodString;
|
|
753
|
+
description: z$2.ZodString;
|
|
754
|
+
order: z$2.ZodNumber;
|
|
755
|
+
enabled: z$2.ZodBoolean;
|
|
756
|
+
}, z$2.core.$strip>>;
|
|
757
|
+
paymentRequirements: z$2.ZodArray<z$2.ZodString>;
|
|
758
|
+
errors: z$2.ZodArray<z$2.ZodObject<{
|
|
759
|
+
code: z$2.ZodString;
|
|
760
|
+
message: z$2.ZodString;
|
|
761
|
+
}, z$2.core.$strip>>;
|
|
762
|
+
totals: z$2.ZodObject<{
|
|
763
|
+
itemsTotal: z$2.ZodNumber;
|
|
764
|
+
itemsTaxTotal: z$2.ZodNumber;
|
|
765
|
+
feesTotal: z$2.ZodNumber;
|
|
766
|
+
feesTaxTotal: z$2.ZodNumber;
|
|
767
|
+
discountTotal: z$2.ZodNumber;
|
|
768
|
+
discountTaxTotal: z$2.ZodNumber;
|
|
769
|
+
shippingTotal: z$2.ZodNullable<z$2.ZodNumber>;
|
|
770
|
+
shippingTaxTotal: z$2.ZodNullable<z$2.ZodNumber>;
|
|
771
|
+
total: z$2.ZodNumber;
|
|
772
|
+
taxTotal: z$2.ZodNumber;
|
|
773
|
+
taxLines: z$2.ZodArray<z$2.ZodObject<{
|
|
774
|
+
name: z$2.ZodString;
|
|
775
|
+
price: z$2.ZodNumber;
|
|
776
|
+
rate: z$2.ZodString;
|
|
777
|
+
}, z$2.core.$strip>>;
|
|
778
|
+
}, z$2.core.$strip>;
|
|
779
|
+
currencyFormat: z$2.ZodObject<{
|
|
780
|
+
currencyCode: z$2.ZodString;
|
|
781
|
+
currencySymbol: z$2.ZodString;
|
|
782
|
+
currencyPrefix: z$2.ZodString;
|
|
783
|
+
currencySuffix: z$2.ZodString;
|
|
784
|
+
currencyMinorUnit: z$2.ZodNumber;
|
|
785
|
+
currencyDecimalSeparator: z$2.ZodString;
|
|
786
|
+
currencyThousandSeparator: z$2.ZodString;
|
|
787
|
+
}, z$2.core.$strip>;
|
|
788
|
+
extensions: z$2.ZodRecord<z$2.ZodString, z$2.ZodUnknown>;
|
|
789
|
+
}, z$2.core.$strip>>;
|
|
790
|
+
expectedTotal: z$2.ZodOptional<z$2.ZodString>;
|
|
791
|
+
actualTotal: z$2.ZodOptional<z$2.ZodString>;
|
|
792
|
+
}, z$2.core.$strip>;
|
|
793
|
+
};
|
|
481
794
|
readonly CHECKOUT_CART_INVALID: {
|
|
482
795
|
readonly status: 409;
|
|
483
796
|
readonly message: "An item in the cart is no longer valid.";
|
|
@@ -3743,6 +4056,7 @@ declare const ConfirmCheckoutInput: z$2.ZodObject<{
|
|
|
3743
4056
|
}>>;
|
|
3744
4057
|
}, z$2.core.$strip>>;
|
|
3745
4058
|
paymentMethod: z$2.ZodString;
|
|
4059
|
+
expectedTotal: z$2.ZodOptional<z$2.ZodString>;
|
|
3746
4060
|
customerNote: z$2.ZodOptional<z$2.ZodString>;
|
|
3747
4061
|
createAccount: z$2.ZodOptional<z$2.ZodBoolean>;
|
|
3748
4062
|
customerPassword: z$2.ZodOptional<z$2.ZodString>;
|
package/dist/index.js
CHANGED
|
@@ -1383,6 +1383,10 @@ const CART_PROCEDURES = {
|
|
|
1383
1383
|
//#endregion
|
|
1384
1384
|
//#region src/checkout/error.ts
|
|
1385
1385
|
const CheckoutConflictData = z$2.object({ cart: Cart.nullable() });
|
|
1386
|
+
const CheckoutTotalMismatchData = CheckoutConflictData.extend({
|
|
1387
|
+
expectedTotal: z$2.string().regex(/^[0-9]+$/).optional(),
|
|
1388
|
+
actualTotal: z$2.string().regex(/^[0-9]+$/).optional()
|
|
1389
|
+
});
|
|
1386
1390
|
const GET_CHECKOUT_ERROR_MAP = defineErrorMap({ CHECKOUT_ORDER_NOT_FOUND: {
|
|
1387
1391
|
status: 404,
|
|
1388
1392
|
message: "No checkout order found."
|
|
@@ -1454,6 +1458,11 @@ const CONFIRM_CHECKOUT_ERROR_MAP = defineErrorMap({
|
|
|
1454
1458
|
message: "The cart is empty.",
|
|
1455
1459
|
data: CheckoutConflictData
|
|
1456
1460
|
},
|
|
1461
|
+
CHECKOUT_TOTAL_MISMATCH: {
|
|
1462
|
+
status: 409,
|
|
1463
|
+
message: "The order total increased. Please review the updated total.",
|
|
1464
|
+
data: CheckoutTotalMismatchData
|
|
1465
|
+
},
|
|
1457
1466
|
CHECKOUT_CART_INVALID: {
|
|
1458
1467
|
status: 409,
|
|
1459
1468
|
message: "An item in the cart is no longer valid.",
|
|
@@ -1613,6 +1622,7 @@ const ConfirmCheckoutInput = z$2.object({
|
|
|
1613
1622
|
billingAddress: CartBillingAddressSubmission,
|
|
1614
1623
|
shippingAddress: CartShippingAddressSubmission.optional(),
|
|
1615
1624
|
paymentMethod: z$2.string(),
|
|
1625
|
+
expectedTotal: z$2.string().regex(/^[0-9]+$/).optional(),
|
|
1616
1626
|
customerNote: z$2.string().optional(),
|
|
1617
1627
|
createAccount: z$2.boolean().optional(),
|
|
1618
1628
|
customerPassword: z$2.string().optional(),
|
|
@@ -1789,6 +1799,7 @@ const checkoutProcedures = {
|
|
|
1789
1799
|
shipping_address: input.body.shippingAddress ? serializeCheckoutShippingAddress(input.body.shippingAddress) : void 0,
|
|
1790
1800
|
payment_method: gateway(input.body.paymentMethod),
|
|
1791
1801
|
customer_note: input.body.customerNote,
|
|
1802
|
+
...input.body.expectedTotal !== void 0 && { expected_total: input.body.expectedTotal },
|
|
1792
1803
|
create_account: input.body.createAccount ?? false,
|
|
1793
1804
|
customer_password: input.body.customerPassword,
|
|
1794
1805
|
payment_data: input.body.paymentData,
|
|
@@ -1832,6 +1843,10 @@ const checkoutProcedures = {
|
|
|
1832
1843
|
message: response.error.message,
|
|
1833
1844
|
data: conflict
|
|
1834
1845
|
});
|
|
1846
|
+
case "woocommerce_rest_checkout_total_mismatch": throw errors.CHECKOUT_TOTAL_MISMATCH({
|
|
1847
|
+
message: response.error.message,
|
|
1848
|
+
data: totalMismatchData(response.error.data)
|
|
1849
|
+
});
|
|
1835
1850
|
case "woocommerce_rest_coupon_reserve_failed": throw errors.CHECKOUT_COUPON_RESERVATION_FAILED({
|
|
1836
1851
|
message: response.error.message,
|
|
1837
1852
|
data: conflict
|
|
@@ -1918,6 +1933,20 @@ function conflictData(data) {
|
|
|
1918
1933
|
function isRecord(value) {
|
|
1919
1934
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1920
1935
|
}
|
|
1936
|
+
function totalMismatchData(data) {
|
|
1937
|
+
const { cart } = conflictData(data);
|
|
1938
|
+
const expectedTotal = minorUnitTotal(isRecord(data) ? data.expected_total : void 0);
|
|
1939
|
+
const actualTotal = minorUnitTotal(isRecord(data) ? data.actual_total : void 0);
|
|
1940
|
+
return {
|
|
1941
|
+
cart: Cart.safeParse(cart).success ? cart : null,
|
|
1942
|
+
...expectedTotal !== void 0 && { expectedTotal },
|
|
1943
|
+
...actualTotal !== void 0 && { actualTotal }
|
|
1944
|
+
};
|
|
1945
|
+
}
|
|
1946
|
+
function minorUnitTotal(value) {
|
|
1947
|
+
if (typeof value === "string" && /^[0-9]+$/.test(value)) return value;
|
|
1948
|
+
if (typeof value === "number" && Number.isSafeInteger(value) && value >= 0) return String(value);
|
|
1949
|
+
}
|
|
1921
1950
|
/** Keep billing registry aliases consumer-resolved instead of emitting the build-time fallback. */
|
|
1922
1951
|
const CHECKOUT_PROCEDURES = checkoutProcedures;
|
|
1923
1952
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kizlo/woocommerce",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"description": "WooCommerce integration for Kizlo.",
|
|
@@ -60,6 +60,6 @@
|
|
|
60
60
|
"zod": "^4.3.6"
|
|
61
61
|
},
|
|
62
62
|
"peerDependencies": {
|
|
63
|
-
"kizlo": ">=0.
|
|
63
|
+
"kizlo": ">=0.26.1"
|
|
64
64
|
}
|
|
65
65
|
}
|