Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Hide nested serializer prices for gated storefront guests (#14258)
Damian Legawiec6ae9392e707d
diff --git a/packages/admin-sdk/.changeset/nullable-money-types.md b/packages/admin-sdk/.changeset/nullable-money-types.mdnew file mode 100644index 0000000000..a9a4e4db78--- /dev/null+++ b/packages/admin-sdk/.changeset/nullable-money-types.md@@ -0,0 +1,5 @@+---+"@spree/admin-sdk": patch+---++Regenerated types: fixes `created_at`/`updated_at` on Country, State, and other resources previously typed `unknown` to `string`. Admin money fields remain non-nullable — storefront price gating never applies to the Admin API.diff --git a/packages/admin-sdk/src/types/generated/Channel.ts b/packages/admin-sdk/src/types/generated/Channel.tsindex 4b83b6036d..07e6d4bf0e 100644--- a/packages/admin-sdk/src/types/generated/Channel.ts+++ b/packages/admin-sdk/src/types/generated/Channel.ts@@ -1,4 +1,4 @@-// Typelizer digest 8a76dd2cfe85bd42b35329b35e86f26d+// Typelizer digest 75b88735ba3cb2c664101d9511020ffe//// DO NOT MODIFY: This file was automatically generated by Typelizer.diff --git a/packages/admin-sdk/src/types/generated/Country.ts b/packages/admin-sdk/src/types/generated/Country.tsindex c46b43daa2..ded111d06f 100644--- a/packages/admin-sdk/src/types/generated/Country.ts+++ b/packages/admin-sdk/src/types/generated/Country.ts@@ -1,4 +1,4 @@-// Typelizer digest b178bbcdf98d347f041066d36303f61f+// Typelizer digest 4e9b255a21d2dcfa949a01e83f72f7ba//// DO NOT MODIFY: This file was automatically generated by Typelizer.import type {Market, State} from '@/types'@@ -11,8 +11,8 @@ interface Country {zipcode_required: boolean;states?: Array<State>;market?: Market | null;- created_at: unknown;- updated_at: unknown;+ created_at: string;+ updated_at: string;}export default Country;diff --git a/packages/admin-sdk/src/types/generated/Order.ts b/packages/admin-sdk/src/types/generated/Order.tsindex 277b7d87c9..0031ca9cd6 100644--- a/packages/admin-sdk/src/types/generated/Order.ts+++ b/packages/admin-sdk/src/types/generated/Order.ts@@ -1,4 +1,4 @@-// Typelizer digest 6b6a4a746ff39b95e210cd687d581db5+// Typelizer digest 7db4fa96518d9ed5a5001642abc23694//// DO NOT MODIFY: This file was automatically generated by Typelizer.import type {Discount, LineItem, Fulfillment, Payment, Address, GiftCard, Market, Channel, StockLocation, PaymentMethod, Customer, Adjustment, ReturnAuthorization, Reimbursement} from '@/types'@@ -13,6 +13,9 @@ interface Order {currency: string;locale: string | null;total_quantity: number;+ fulfillment_status: string | null;+ payment_status: string | null;+ completed_at: string | null;item_total: string;display_item_total: string;adjustment_total: string;@@ -33,9 +36,6 @@ interface Order {display_amount_due: string;delivery_total: string;display_delivery_total: string;- fulfillment_status: string | null;- payment_status: string | null;- completed_at: string | null;store_credit_total: string;display_store_credit_total: string;covered_by_store_credit: boolean;diff --git a/packages/admin-sdk/src/types/generated/PromotionRule.ts b/packages/admin-sdk/src/types/generated/PromotionRule.tsindex 0cf1ec951b..296526ca6f 100644--- a/packages/admin-sdk/src/types/generated/PromotionRule.ts+++ b/packages/admin-sdk/src/types/generated/PromotionRule.ts@@ -1,4 +1,4 @@-// Typelizer digest 216b085a4b19c589b137ef282f9f50aa+// Typelizer digest d0302c436cdf25cfa7b737c2c8bf25d9//// DO NOT MODIFY: This file was automatically generated by Typelizer.import type {Product, Category, Customer, CustomerGroup, Country, Channel, Market} from '@/types'diff --git a/packages/admin-sdk/src/types/generated/State.ts b/packages/admin-sdk/src/types/generated/State.tsindex 40ca43f440..71c51c27b9 100644--- a/packages/admin-sdk/src/types/generated/State.ts+++ b/packages/admin-sdk/src/types/generated/State.ts@@ -1,12 +1,12 @@-// Typelizer digest 2c41762cfe57b3597bda93d8aae7c0ef+// Typelizer digest 04283ac1fdabb31b971a64f9459efb1d//// DO NOT MODIFY: This file was automatically generated by Typelizer.interface State {abbr: string;name: string;- created_at: unknown;- updated_at: unknown;+ created_at: string;+ updated_at: string;}export default State;diff --git a/packages/admin-sdk/src/types/generated/Store.ts b/packages/admin-sdk/src/types/generated/Store.tsindex 3fd35327b9..daac72bd0e 100644--- a/packages/admin-sdk/src/types/generated/Store.ts+++ b/packages/admin-sdk/src/types/generated/Store.ts@@ -1,4 +1,4 @@-// Typelizer digest 2d7bb47b535b465c8fad0e4342c531e4+// Typelizer digest 60866b4527363a46cbbcaf63587b7d34//// DO NOT MODIFY: This file was automatically generated by Typelizer.diff --git a/packages/dashboard/src/routes/_authenticated/$storeId/orders/$orderId.tsx b/packages/dashboard/src/routes/_authenticated/$storeId/orders/$orderId.tsxindex 7817a3561b..64c9a8db16 100644--- a/packages/dashboard/src/routes/_authenticated/$storeId/orders/$orderId.tsx+++ b/packages/dashboard/src/routes/_authenticated/$storeId/orders/$orderId.tsx@@ -1306,7 +1306,7 @@ function SummaryRow({function OrderSummaryCard({ order }: { order: Order }) {const { t } = useTranslation()const { storeId } = Route.useParams()- const outstandingBalance = Number.parseFloat(order.amount_due ?? '0')+ const outstandingBalance = Number.parseFloat(order.amount_due)return (<Card>@@ -1474,7 +1474,7 @@ function DiscountsCard({ order }: { order: Order }) {adminClient.orders.storeCredits.remove(orderId),)- const hasStoreCredit = Number.parseFloat(order.store_credit_total ?? '0') > 0+ const hasStoreCredit = Number.parseFloat(order.store_credit_total) > 0const hasCustomer = Boolean(order.customer_id)return (diff --git a/packages/sdk/.changeset/nullable-money-fields.md b/packages/sdk/.changeset/nullable-money-fields.mdnew file mode 100644index 0000000000..f2b19a532c--- /dev/null+++ b/packages/sdk/.changeset/nullable-money-fields.md@@ -0,0 +1,5 @@+---+"@spree/sdk": minor+---++Money fields are now typed `string | null` across Cart, Order, LineItem, Payment, Fulfillment, GiftCard, and Discount (Zod schemas accept `null` accordingly). On a gated channel (`prices_hidden`), the Store API returns `null` for every monetary amount — including those on records nested inside a cart or order — so anonymous visitors cannot recover hidden prices. Handle `null` before formatting or doing arithmetic on these fields.diff --git a/packages/sdk/src/types/generated/Cart.ts b/packages/sdk/src/types/generated/Cart.tsindex 0a8c8c2677..db26b53081 100644--- a/packages/sdk/src/types/generated/Cart.ts+++ b/packages/sdk/src/types/generated/Cart.ts@@ -1,4 +1,4 @@-// Typelizer digest 484d8a6692cdc34860e4ecf139e0c35d+// Typelizer digest d6441f815fb2d55294bed5547f939b36//// DO NOT MODIFY: This file was automatically generated by Typelizer.import type {Discount, LineItem, Fulfillment, Payment, Address, PaymentMethod, GiftCard, Market} from '@/types'@@ -13,29 +13,29 @@ interface Cart {currency: string;locale: string | null;total_quantity: number;- item_total: string;- display_item_total: string;- adjustment_total: string;- display_adjustment_total: string;- discount_total: string;- display_discount_total: string;- tax_total: string;- display_tax_total: string;- included_tax_total: string;- display_included_tax_total: string;- additional_tax_total: string;- display_additional_tax_total: string;- total: string;- display_total: string;- gift_card_total: string;- display_gift_card_total: string;- amount_due: string;- display_amount_due: string;- delivery_total: string;- display_delivery_total: string;warnings: Array<{code: string, message: string, line_item_id?: string, variant_id?: string}>;- store_credit_total: string;- display_store_credit_total: string;+ item_total: string | null;+ display_item_total: string | null;+ adjustment_total: string | null;+ display_adjustment_total: string | null;+ discount_total: string | null;+ display_discount_total: string | null;+ tax_total: string | null;+ display_tax_total: string | null;+ included_tax_total: string | null;+ display_included_tax_total: string | null;+ additional_tax_total: string | null;+ display_additional_tax_total: string | null;+ total: string | null;+ display_total: string | null;+ gift_card_total: string | null;+ display_gift_card_total: string | null;+ amount_due: string | null;+ display_amount_due: string | null;+ delivery_total: string | null;+ display_delivery_total: string | null;+ store_credit_total: string | null;+ display_store_credit_total: string | null;covered_by_store_credit: boolean;current_step: string;completed_steps: Array<string>;diff --git a/packages/sdk/src/types/generated/Discount.ts b/packages/sdk/src/types/generated/Discount.tsindex c03238cf90..ae6ada5d47 100644--- a/packages/sdk/src/types/generated/Discount.ts+++ b/packages/sdk/src/types/generated/Discount.ts@@ -1,4 +1,4 @@-// Typelizer digest 722e5b14b91abb060eb4ecdbc858e112+// Typelizer digest 8b92b5d8ef68697c93ef497e34efe969//// DO NOT MODIFY: This file was automatically generated by Typelizer.@@ -8,8 +8,8 @@ interface Discount {name: string;description: string | null;code: string | null;- amount: string;- display_amount: string;+ amount: string | null;+ display_amount: string | null;}export default Discount;diff --git a/packages/sdk/src/types/generated/Fulfillment.ts b/packages/sdk/src/types/generated/Fulfillment.tsindex 85f1788b3e..68c8ca3ede 100644--- a/packages/sdk/src/types/generated/Fulfillment.ts+++ b/packages/sdk/src/types/generated/Fulfillment.ts@@ -1,4 +1,4 @@-// Typelizer digest 2071a1394fbfeebc7cf206c3e3fd74a8+// Typelizer digest 2b24c989e30e00e133595c66d998827f//// DO NOT MODIFY: This file was automatically generated by Typelizer.import type {DeliveryMethod, StockLocation, DeliveryRate} from '@/types'@@ -8,18 +8,18 @@ interface Fulfillment {number: string;tracking: string | null;tracking_url: string | null;- cost: string;- display_cost: string;- total: string;- display_total: string;- discount_total: string;- display_discount_total: string;- additional_tax_total: string;- display_additional_tax_total: string;- included_tax_total: string;- display_included_tax_total: string;- tax_total: string;- display_tax_total: string;+ cost: string | null;+ display_cost: string | null;+ total: string | null;+ display_total: string | null;+ discount_total: string | null;+ display_discount_total: string | null;+ additional_tax_total: string | null;+ display_additional_tax_total: string | null;+ included_tax_total: string | null;+ display_included_tax_total: string | null;+ tax_total: string | null;+ display_tax_total: string | null;status: string;fulfillment_type: string;fulfilled_at: string | null;diff --git a/packages/sdk/src/types/generated/GiftCard.ts b/packages/sdk/src/types/generated/GiftCard.tsindex 1f78bea5bb..6cb7c8a21e 100644--- a/packages/sdk/src/types/generated/GiftCard.ts+++ b/packages/sdk/src/types/generated/GiftCard.ts@@ -1,4 +1,4 @@-// Typelizer digest 6411918f8246ee4dea3f402e60e76245+// Typelizer digest ce59ae2d25781676f8c870cb1400a30f//// DO NOT MODIFY: This file was automatically generated by Typelizer.@@ -7,13 +7,13 @@ interface GiftCard {code: string;status: string;currency: string;- amount: string;- amount_used: string;- amount_authorized: string;- amount_remaining: string;- display_amount: string;- display_amount_used: string;- display_amount_remaining: string;+ amount: string | null;+ amount_used: string | null;+ amount_authorized: string | null;+ amount_remaining: string | null;+ display_amount: string | null;+ display_amount_used: string | null;+ display_amount_remaining: string | null;expires_at: string | null;redeemed_at: string | null;expired: boolean;diff --git a/packages/sdk/src/types/generated/LineItem.ts b/packages/sdk/src/types/generated/LineItem.tsindex 2d8876d11d..9abcfd0640 100644--- a/packages/sdk/src/types/generated/LineItem.ts+++ b/packages/sdk/src/types/generated/LineItem.ts@@ -1,4 +1,4 @@-// Typelizer digest 8c0b49f019367cedf7c6036ae7cf0c8b+// Typelizer digest df075d3eedc9748ec9650add24c2b6a1//// DO NOT MODIFY: This file was automatically generated by Typelizer.import type {OptionValue, DigitalLink} from '@/types'@@ -11,22 +11,22 @@ interface LineItem {name: string;slug: string;options_text: string;- price: string;- display_price: string;- total: string;- display_total: string;- adjustment_total: string;- display_adjustment_total: string;- additional_tax_total: string;- display_additional_tax_total: string;- included_tax_total: string;- display_included_tax_total: string;- discount_total: string;- display_discount_total: string;- pre_tax_amount: string;- display_pre_tax_amount: string;- discounted_amount: string;- display_discounted_amount: string;+ price: string | null;+ display_price: string | null;+ total: string | null;+ display_total: string | null;+ adjustment_total: string | null;+ display_adjustment_total: string | null;+ additional_tax_total: string | null;+ display_additional_tax_total: string | null;+ included_tax_total: string | null;+ display_included_tax_total: string | null;+ discount_total: string | null;+ display_discount_total: string | null;+ pre_tax_amount: string | null;+ display_pre_tax_amount: string | null;+ discounted_amount: string | null;+ display_discounted_amount: string | null;display_compare_at_amount: string | null;compare_at_amount: string | null;thumbnail_url: string | null;diff --git a/packages/sdk/src/types/generated/Order.ts b/packages/sdk/src/types/generated/Order.tsindex cd02e1d301..ed95db8ad3 100644--- a/packages/sdk/src/types/generated/Order.ts+++ b/packages/sdk/src/types/generated/Order.ts@@ -1,4 +1,4 @@-// Typelizer digest 5f1de00d99f6938a41bf22effd11e887+// Typelizer digest ff468dbc257cdcb510b5e55b7caf94ff//// DO NOT MODIFY: This file was automatically generated by Typelizer.import type {Discount, LineItem, Fulfillment, Payment, Address, GiftCard, Market} from '@/types'@@ -13,31 +13,31 @@ interface Order {currency: string;locale: string | null;total_quantity: number;- item_total: string;- display_item_total: string;- adjustment_total: string;- display_adjustment_total: string;- discount_total: string;- display_discount_total: string;- tax_total: string;- display_tax_total: string;- included_tax_total: string;- display_included_tax_total: string;- additional_tax_total: string;- display_additional_tax_total: string;- total: string;- display_total: string;- gift_card_total: string;- display_gift_card_total: string;- amount_due: string;- display_amount_due: string;- delivery_total: string;- display_delivery_total: string;fulfillment_status: string | null;payment_status: string | null;completed_at: string | null;- store_credit_total: string;- display_store_credit_total: string;+ item_total: string | null;+ display_item_total: string | null;+ adjustment_total: string | null;+ display_adjustment_total: string | null;+ discount_total: string | null;+ display_discount_total: string | null;+ tax_total: string | null;+ display_tax_total: string | null;+ included_tax_total: string | null;+ display_included_tax_total: string | null;+ additional_tax_total: string | null;+ display_additional_tax_total: string | null;+ total: string | null;+ display_total: string | null;+ gift_card_total: string | null;+ display_gift_card_total: string | null;+ amount_due: string | null;+ display_amount_due: string | null;+ delivery_total: string | null;+ display_delivery_total: string | null;+ store_credit_total: string | null;+ display_store_credit_total: string | null;covered_by_store_credit: boolean;discounts: Array<Discount>;items: Array<LineItem>;diff --git a/packages/sdk/src/types/generated/Payment.ts b/packages/sdk/src/types/generated/Payment.tsindex 87b05ab093..b9aee6aa83 100644--- a/packages/sdk/src/types/generated/Payment.ts+++ b/packages/sdk/src/types/generated/Payment.ts@@ -1,4 +1,4 @@-// Typelizer digest 9f3114bf5775cf48c19768b69d8db526+// Typelizer digest 684de79ea937c2068df10e074e901b38//// DO NOT MODIFY: This file was automatically generated by Typelizer.import type {CreditCard, StoreCredit, PaymentSource, PaymentMethod} from '@/types'@@ -8,8 +8,8 @@ interface Payment {payment_method_id: string;response_code: string | null;number: string;- amount: string;- display_amount: string;+ amount: string | null;+ display_amount: string | null;status: string;source_type: 'credit_card' | 'store_credit' | 'payment_source' | null;source_id: string | null;diff --git a/packages/sdk/src/zod/generated/Cart.ts b/packages/sdk/src/zod/generated/Cart.tsindex 4ba9d10990..ec5cd229c5 100644--- a/packages/sdk/src/zod/generated/Cart.ts+++ b/packages/sdk/src/zod/generated/Cart.ts@@ -19,29 +19,29 @@ export const CartSchema = z.object({currency: z.string(),locale: z.string().nullable(),total_quantity: z.number(),- item_total: z.string(),- display_item_total: z.string(),- adjustment_total: z.string(),- display_adjustment_total: z.string(),- discount_total: z.string(),- display_discount_total: z.string(),- tax_total: z.string(),- display_tax_total: z.string(),- included_tax_total: z.string(),- display_included_tax_total: z.string(),- additional_tax_total: z.string(),- display_additional_tax_total: z.string(),- total: z.string(),- display_total: z.string(),- gift_card_total: z.string(),- display_gift_card_total: z.string(),- amount_due: z.string(),- display_amount_due: z.string(),- delivery_total: z.string(),- display_delivery_total: z.string(),warnings: z.array(z.any()),- store_credit_total: z.string(),- display_store_credit_total: z.string(),+ item_total: z.string().nullable(),+ display_item_total: z.string().nullable(),+ adjustment_total: z.string().nullable(),+ display_adjustment_total: z.string().nullable(),+ discount_total: z.string().nullable(),+ display_discount_total: z.string().nullable(),+ tax_total: z.string().nullable(),+ display_tax_total: z.string().nullable(),+ included_tax_total: z.string().nullable(),+ display_included_tax_total: z.string().nullable(),+ additional_tax_total: z.string().nullable(),+ display_additional_tax_total: z.string().nullable(),+ total: z.string().nullable(),+ display_total: z.string().nullable(),+ gift_card_total: z.string().nullable(),+ display_gift_card_total: z.string().nullable(),+ amount_due: z.string().nullable(),+ display_amount_due: z.string().nullable(),+ delivery_total: z.string().nullable(),+ display_delivery_total: z.string().nullable(),+ store_credit_total: z.string().nullable(),+ display_store_credit_total: z.string().nullable(),covered_by_store_credit: z.boolean(),current_step: z.string(),completed_steps: z.array(z.string()),diff --git a/packages/sdk/src/zod/generated/Discount.ts b/packages/sdk/src/zod/generated/Discount.tsindex 556d8c3213..81fb762de7 100644--- a/packages/sdk/src/zod/generated/Discount.ts+++ b/packages/sdk/src/zod/generated/Discount.ts@@ -7,8 +7,8 @@ export const DiscountSchema = z.object({name: z.string(),description: z.string().nullable(),code: z.string().nullable(),- amount: z.string(),- display_amount: z.string(),+ amount: z.string().nullable(),+ display_amount: z.string().nullable(),});export type Discount = z.infer<typeof DiscountSchema>;diff --git a/packages/sdk/src/zod/generated/Fulfillment.ts b/packages/sdk/src/zod/generated/Fulfillment.tsindex 504352c8a7..768b74f158 100644--- a/packages/sdk/src/zod/generated/Fulfillment.ts+++ b/packages/sdk/src/zod/generated/Fulfillment.ts@@ -9,18 +9,18 @@ export const FulfillmentSchema = z.object({number: z.string(),tracking: z.string().nullable(),tracking_url: z.string().nullable(),- cost: z.string(),- display_cost: z.string(),- total: z.string(),- display_total: z.string(),- discount_total: z.string(),- display_discount_total: z.string(),- additional_tax_total: z.string(),- display_additional_tax_total: z.string(),- included_tax_total: z.string(),- display_included_tax_total: z.string(),- tax_total: z.string(),- display_tax_total: z.string(),+ cost: z.string().nullable(),+ display_cost: z.string().nullable(),+ total: z.string().nullable(),+ display_total: z.string().nullable(),+ discount_total: z.string().nullable(),+ display_discount_total: z.string().nullable(),+ additional_tax_total: z.string().nullable(),+ display_additional_tax_total: z.string().nullable(),+ included_tax_total: z.string().nullable(),+ display_included_tax_total: z.string().nullable(),+ tax_total: z.string().nullable(),+ display_tax_total: z.string().nullable(),status: z.string(),fulfillment_type: z.string(),fulfilled_at: z.string().nullable(),diff --git a/packages/sdk/src/zod/generated/GiftCard.ts b/packages/sdk/src/zod/generated/GiftCard.tsindex fcd91d7d12..69ffc41bb9 100644--- a/packages/sdk/src/zod/generated/GiftCard.ts+++ b/packages/sdk/src/zod/generated/GiftCard.ts@@ -6,13 +6,13 @@ export const GiftCardSchema = z.object({code: z.string(),status: z.string(),currency: z.string(),- amount: z.string(),- amount_used: z.string(),- amount_authorized: z.string(),- amount_remaining: z.string(),- display_amount: z.string(),- display_amount_used: z.string(),- display_amount_remaining: z.string(),+ amount: z.string().nullable(),+ amount_used: z.string().nullable(),+ amount_authorized: z.string().nullable(),+ amount_remaining: z.string().nullable(),+ display_amount: z.string().nullable(),+ display_amount_used: z.string().nullable(),+ display_amount_remaining: z.string().nullable(),expires_at: z.string().nullable(),redeemed_at: z.string().nullable(),expired: z.boolean(),diff --git a/packages/sdk/src/zod/generated/LineItem.ts b/packages/sdk/src/zod/generated/LineItem.tsindex b133902aa5..e6b45a301d 100644--- a/packages/sdk/src/zod/generated/LineItem.ts+++ b/packages/sdk/src/zod/generated/LineItem.ts@@ -11,22 +11,22 @@ export const LineItemSchema = z.object({name: z.string(),slug: z.string(),options_text: z.string(),- price: z.string(),- display_price: z.string(),- total: z.string(),- display_total: z.string(),- adjustment_total: z.string(),- display_adjustment_total: z.string(),- additional_tax_total: z.string(),- display_additional_tax_total: z.string(),- included_tax_total: z.string(),- display_included_tax_total: z.string(),- discount_total: z.string(),- display_discount_total: z.string(),- pre_tax_amount: z.string(),- display_pre_tax_amount: z.string(),- discounted_amount: z.string(),- display_discounted_amount: z.string(),+ price: z.string().nullable(),+ display_price: z.string().nullable(),+ total: z.string().nullable(),+ display_total: z.string().nullable(),+ adjustment_total: z.string().nullable(),+ display_adjustment_total: z.string().nullable(),+ additional_tax_total: z.string().nullable(),+ display_additional_tax_total: z.string().nullable(),+ included_tax_total: z.string().nullable(),+ display_included_tax_total: z.string().nullable(),+ discount_total: z.string().nullable(),+ display_discount_total: z.string().nullable(),+ pre_tax_amount: z.string().nullable(),+ display_pre_tax_amount: z.string().nullable(),+ discounted_amount: z.string().nullable(),+ display_discounted_amount: z.string().nullable(),display_compare_at_amount: z.string().nullable(),compare_at_amount: z.string().nullable(),thumbnail_url: z.string().nullable(),diff --git a/packages/sdk/src/zod/generated/Order.ts b/packages/sdk/src/zod/generated/Order.tsindex e24d616bde..dcf8001003 100644--- a/packages/sdk/src/zod/generated/Order.ts+++ b/packages/sdk/src/zod/generated/Order.ts@@ -18,31 +18,31 @@ export const OrderSchema = z.object({currency: z.string(),locale: z.string().nullable(),total_quantity: z.number(),- item_total: z.string(),- display_item_total: z.string(),- adjustment_total: z.string(),- display_adjustment_total: z.string(),- discount_total: z.string(),- display_discount_total: z.string(),- tax_total: z.string(),- display_tax_total: z.string(),- included_tax_total: z.string(),- display_included_tax_total: z.string(),- additional_tax_total: z.string(),- display_additional_tax_total: z.string(),- total: z.string(),- display_total: z.string(),- gift_card_total: z.string(),- display_gift_card_total: z.string(),- amount_due: z.string(),- display_amount_due: z.string(),- delivery_total: z.string(),- display_delivery_total: z.string(),fulfillment_status: z.string().nullable(),payment_status: z.string().nullable(),completed_at: z.string().nullable(),- store_credit_total: z.string(),- display_store_credit_total: z.string(),+ item_total: z.string().nullable(),+ display_item_total: z.string().nullable(),+ adjustment_total: z.string().nullable(),+ display_adjustment_total: z.string().nullable(),+ discount_total: z.string().nullable(),+ display_discount_total: z.string().nullable(),+ tax_total: z.string().nullable(),+ display_tax_total: z.string().nullable(),+ included_tax_total: z.string().nullable(),+ display_included_tax_total: z.string().nullable(),+ additional_tax_total: z.string().nullable(),+ display_additional_tax_total: z.string().nullable(),+ total: z.string().nullable(),+ display_total: z.string().nullable(),+ gift_card_total: z.string().nullable(),+ display_gift_card_total: z.string().nullable(),+ amount_due: z.string().nullable(),+ display_amount_due: z.string().nullable(),+ delivery_total: z.string().nullable(),+ display_delivery_total: z.string().nullable(),+ store_credit_total: z.string().nullable(),+ display_store_credit_total: z.string().nullable(),covered_by_store_credit: z.boolean(),discounts: z.array(DiscountSchema),items: z.array(LineItemSchema),diff --git a/packages/sdk/src/zod/generated/Payment.ts b/packages/sdk/src/zod/generated/Payment.tsindex 9aa60bcc4a..a1cad13b31 100644--- a/packages/sdk/src/zod/generated/Payment.ts+++ b/packages/sdk/src/zod/generated/Payment.ts@@ -7,8 +7,8 @@ export const PaymentSchema = z.object({payment_method_id: z.string(),response_code: z.string().nullable(),number: z.string(),- amount: z.string(),- display_amount: z.string(),+ amount: z.string().nullable(),+ display_amount: z.string().nullable(),status: z.string(),source_type: z.string().nullable(),source_id: z.string().nullable(),diff --git a/spree/api/app/serializers/spree/api/v3/admin/discount_serializer.rb b/spree/api/app/serializers/spree/api/v3/admin/discount_serializer.rbindex 795a5c65b7..f78410fb21 100644--- a/spree/api/app/serializers/spree/api/v3/admin/discount_serializer.rb+++ b/spree/api/app/serializers/spree/api/v3/admin/discount_serializer.rb@@ -3,6 +3,10 @@ module Spreemodule V3module Adminclass DiscountSerializer < V3::DiscountSerializer+ # The Admin API has no guest gating — money fields inherited from the+ # store serializer are always present, so override their nullability.+ typelize amount: [:string, nullable: false], display_amount: [:string, nullable: false]+attributes created_at: :iso8601, updated_at: :iso8601endenddiff --git a/spree/api/app/serializers/spree/api/v3/admin/fulfillment_serializer.rb b/spree/api/app/serializers/spree/api/v3/admin/fulfillment_serializer.rbindex cbe3f67df1..89ce047b78 100644--- a/spree/api/app/serializers/spree/api/v3/admin/fulfillment_serializer.rb+++ b/spree/api/app/serializers/spree/api/v3/admin/fulfillment_serializer.rb@@ -3,6 +3,15 @@ module Spreemodule V3module Adminclass FulfillmentSerializer < V3::FulfillmentSerializer+ # The Admin API has no guest gating — money fields inherited from the+ # store serializer are always present, so override their nullability.+ typelize cost: [:string, nullable: false], display_cost: [:string, nullable: false],+ total: [:string, nullable: false], display_total: [:string, nullable: false],+ discount_total: [:string, nullable: false], display_discount_total: [:string, nullable: false],+ additional_tax_total: [:string, nullable: false], display_additional_tax_total: [:string, nullable: false],+ included_tax_total: [:string, nullable: false], display_included_tax_total: [:string, nullable: false],+ tax_total: [:string, nullable: false], display_tax_total: [:string, nullable: false]+typelize metadata: 'Record<string, unknown>',order_id: [:string, nullable: true],stock_location_id: [:string, nullable: true],diff --git a/spree/api/app/serializers/spree/api/v3/admin/gift_card_serializer.rb b/spree/api/app/serializers/spree/api/v3/admin/gift_card_serializer.rbindex 1ae035520f..ceda1d5a08 100644--- a/spree/api/app/serializers/spree/api/v3/admin/gift_card_serializer.rb+++ b/spree/api/app/serializers/spree/api/v3/admin/gift_card_serializer.rb@@ -6,6 +6,13 @@ module Spree# context the admin UI needs: who the card was issued to (customer),# who issued it (admin), and the orders that consumed it.class GiftCardSerializer < V3::GiftCardSerializer+ # The Admin API has no guest gating — money fields inherited from the+ # store serializer are always present, so override their nullability.+ typelize amount: [:string, nullable: false], amount_used: [:string, nullable: false],+ amount_authorized: [:string, nullable: false], amount_remaining: [:string, nullable: false],+ display_amount: [:string, nullable: false], display_amount_used: [:string, nullable: false],+ display_amount_remaining: [:string, nullable: false]+typelize customer_id: [:string, nullable: true],created_by_id: [:string, nullable: true]diff --git a/spree/api/app/serializers/spree/api/v3/admin/line_item_serializer.rb b/spree/api/app/serializers/spree/api/v3/admin/line_item_serializer.rbindex 35faee9724..07a7e8db3b 100644--- a/spree/api/app/serializers/spree/api/v3/admin/line_item_serializer.rb+++ b/spree/api/app/serializers/spree/api/v3/admin/line_item_serializer.rb@@ -5,6 +5,17 @@ module Spree# Admin API Line Item Serializer# Extends the store serializer with metadata visibilityclass LineItemSerializer < V3::LineItemSerializer+ # The Admin API has no guest gating — money fields inherited from the+ # store serializer are always present, so override their nullability.+ typelize price: [:string, nullable: false], display_price: [:string, nullable: false],+ total: [:string, nullable: false], display_total: [:string, nullable: false],+ adjustment_total: [:string, nullable: false], display_adjustment_total: [:string, nullable: false],+ additional_tax_total: [:string, nullable: false], display_additional_tax_total: [:string, nullable: false],+ included_tax_total: [:string, nullable: false], display_included_tax_total: [:string, nullable: false],+ discount_total: [:string, nullable: false], display_discount_total: [:string, nullable: false],+ pre_tax_amount: [:string, nullable: false], display_pre_tax_amount: [:string, nullable: false],+ discounted_amount: [:string, nullable: false], display_discounted_amount: [:string, nullable: false]+typelize metadata: 'Record<string, unknown>',cost_price: [:string, nullable: true],tax_category_id: [:string, nullable: true]diff --git a/spree/api/app/serializers/spree/api/v3/admin/order_serializer.rb b/spree/api/app/serializers/spree/api/v3/admin/order_serializer.rbindex 5e067f7034..fd4baeef73 100644--- a/spree/api/app/serializers/spree/api/v3/admin/order_serializer.rb+++ b/spree/api/app/serializers/spree/api/v3/admin/order_serializer.rb@@ -6,6 +6,20 @@ module Spree# Full order data including admin-only fieldsclass OrderSerializer < V3::OrderSerializer+ # The Admin API has no guest gating — money fields inherited from the+ # store serializer are always present, so override their nullability.+ typelize item_total: [:string, nullable: false], display_item_total: [:string, nullable: false],+ delivery_total: [:string, nullable: false], display_delivery_total: [:string, nullable: false],+ adjustment_total: [:string, nullable: false], display_adjustment_total: [:string, nullable: false],+ discount_total: [:string, nullable: false], display_discount_total: [:string, nullable: false],+ tax_total: [:string, nullable: false], display_tax_total: [:string, nullable: false],+ included_tax_total: [:string, nullable: false], display_included_tax_total: [:string, nullable: false],+ additional_tax_total: [:string, nullable: false], display_additional_tax_total: [:string, nullable: false],+ store_credit_total: [:string, nullable: false], display_store_credit_total: [:string, nullable: false],+ gift_card_total: [:string, nullable: false], display_gift_card_total: [:string, nullable: false],+ total: [:string, nullable: false], display_total: [:string, nullable: false],+ amount_due: [:string, nullable: false], display_amount_due: [:string, nullable: false]+typelize status: :string,last_ip_address: [:string, nullable: true],considered_risky: :boolean, confirmation_delivered: :boolean,diff --git a/spree/api/app/serializers/spree/api/v3/admin/payment_serializer.rb b/spree/api/app/serializers/spree/api/v3/admin/payment_serializer.rbindex af30468074..d4994f1196 100644--- a/spree/api/app/serializers/spree/api/v3/admin/payment_serializer.rb+++ b/spree/api/app/serializers/spree/api/v3/admin/payment_serializer.rb@@ -3,6 +3,10 @@ module Spreemodule V3module Adminclass PaymentSerializer < V3::PaymentSerializer+ # The Admin API has no guest gating — money fields inherited from the+ # store serializer are always present, so override their nullability.+ typelize amount: [:string, nullable: false], display_amount: [:string, nullable: false]+typelize metadata: 'Record<string, unknown>',captured_amount: :string,order_id: [:string, nullable: true],diff --git a/spree/api/app/serializers/spree/api/v3/cart_serializer.rb b/spree/api/app/serializers/spree/api/v3/cart_serializer.rbindex 6c9396348b..6fc6a05e7e 100644--- a/spree/api/app/serializers/spree/api/v3/cart_serializer.rb+++ b/spree/api/app/serializers/spree/api/v3/cart_serializer.rb@@ -8,18 +8,18 @@ module Spreecustomer_note: [:string, nullable: true], market_id: [:string, nullable: true],currency: :string, locale: [:string, nullable: true], total_quantity: :number,requirements: 'Array<{step: string, field: string, message: string}>',- item_total: :string, display_item_total: :string,- delivery_total: :string, display_delivery_total: :string,- adjustment_total: :string, display_adjustment_total: :string,- discount_total: :string, display_discount_total: :string,- tax_total: :string, display_tax_total: :string,- included_tax_total: :string, display_included_tax_total: :string,- additional_tax_total: :string, display_additional_tax_total: :string,- store_credit_total: :string, display_store_credit_total: :string,- gift_card_total: :string, display_gift_card_total: :string,+ item_total: [:string, nullable: true], display_item_total: [:string, nullable: true],+ delivery_total: [:string, nullable: true], display_delivery_total: [:string, nullable: true],+ adjustment_total: [:string, nullable: true], display_adjustment_total: [:string, nullable: true],+ discount_total: [:string, nullable: true], display_discount_total: [:string, nullable: true],+ tax_total: [:string, nullable: true], display_tax_total: [:string, nullable: true],+ included_tax_total: [:string, nullable: true], display_included_tax_total: [:string, nullable: true],+ additional_tax_total: [:string, nullable: true], display_additional_tax_total: [:string, nullable: true],+ store_credit_total: [:string, nullable: true], display_store_credit_total: [:string, nullable: true],+ gift_card_total: [:string, nullable: true], display_gift_card_total: [:string, nullable: true],covered_by_store_credit: :boolean,- total: :string, display_total: :string,- amount_due: :string, display_amount_due: :string,+ total: [:string, nullable: true], display_total: [:string, nullable: true],+ amount_due: [:string, nullable: true], display_amount_due: [:string, nullable: true],shipping_eq_billing_address: :boolean,warnings: 'Array<{code: string, message: string, line_item_id?: string, variant_id?: string}>',billing_address: { nullable: true }, shipping_address: { nullable: true },diff --git a/spree/api/app/serializers/spree/api/v3/discount_serializer.rb b/spree/api/app/serializers/spree/api/v3/discount_serializer.rbindex a9ac036275..090a8e970c 100644--- a/spree/api/app/serializers/spree/api/v3/discount_serializer.rb+++ b/spree/api/app/serializers/spree/api/v3/discount_serializer.rb@@ -5,13 +5,17 @@ module Spree# Replaces CartPromotionSerializer and OrderPromotionSerializer.class DiscountSerializer < BaseSerializertypelize name: :string, description: [:string, nullable: true], code: [:string, nullable: true],- amount: :string, display_amount: :string, promotion_id: :string+ amount: [:string, nullable: true], display_amount: [:string, nullable: true], promotion_id: :stringattribute :promotion_id do |record|record.promotion&.prefixed_idend- attributes :name, :description, :code, :amount, :display_amount+ attributes :name, :description, :code++ # Nulled for gated (prices_hidden) guests so an applied discount can't+ # leak the amount the cart/order totals already withhold.+ money_attributes :amount, :display_amountendendenddiff --git a/spree/api/app/serializers/spree/api/v3/fulfillment_serializer.rb b/spree/api/app/serializers/spree/api/v3/fulfillment_serializer.rbindex 9d47d3e750..37d1ecda05 100644--- a/spree/api/app/serializers/spree/api/v3/fulfillment_serializer.rb+++ b/spree/api/app/serializers/spree/api/v3/fulfillment_serializer.rb@@ -5,21 +5,24 @@ module Spreetypelize number: :string, status: :string, fulfillment_type: :string,tracking: [:string, nullable: true],tracking_url: [:string, nullable: true], fulfilled_at: [:string, nullable: true],- cost: :string, display_cost: :string,- total: :string, display_total: :string,- discount_total: :string, display_discount_total: :string,- additional_tax_total: :string, display_additional_tax_total: :string,- included_tax_total: :string, display_included_tax_total: :string,- tax_total: :string, display_tax_total: :string,+ cost: [:string, nullable: true], display_cost: [:string, nullable: true],+ total: [:string, nullable: true], display_total: [:string, nullable: true],+ discount_total: [:string, nullable: true], display_discount_total: [:string, nullable: true],+ additional_tax_total: [:string, nullable: true], display_additional_tax_total: [:string, nullable: true],+ included_tax_total: [:string, nullable: true], display_included_tax_total: [:string, nullable: true],+ tax_total: [:string, nullable: true], display_tax_total: [:string, nullable: true],items: 'Array<{ item_id: string; variant_id: string; quantity: number }>'- attributes :number, :tracking, :tracking_url,- :cost, :display_cost,- :total, :display_total,- :discount_total, :display_discount_total,- :additional_tax_total, :display_additional_tax_total,- :included_tax_total, :display_included_tax_total,- :tax_total, :display_tax_total+ attributes :number, :tracking, :tracking_url++ # Nulled for gated (prices_hidden) guests so a fulfillment can't leak the+ # shipping/tax amounts the cart/order totals already withhold.+ money_attributes :cost, :display_cost,+ :total, :display_total,+ :discount_total, :display_discount_total,+ :additional_tax_total, :display_additional_tax_total,+ :included_tax_total, :display_included_tax_total,+ :tax_total, :display_tax_totalattribute :status do |shipment|shipment.statediff --git a/spree/api/app/serializers/spree/api/v3/gift_card_serializer.rb b/spree/api/app/serializers/spree/api/v3/gift_card_serializer.rbindex 20b1cea8c2..e12223163c 100644--- a/spree/api/app/serializers/spree/api/v3/gift_card_serializer.rb+++ b/spree/api/app/serializers/spree/api/v3/gift_card_serializer.rb@@ -4,13 +4,13 @@ module Spreeclass GiftCardSerializer < BaseSerializertypelize code: :string,status: :string,- amount: :string,- amount_used: :string,- amount_authorized: :string,- amount_remaining: :string,- display_amount: :string,- display_amount_used: :string,- display_amount_remaining: :string,+ amount: [:string, nullable: true],+ amount_used: [:string, nullable: true],+ amount_authorized: [:string, nullable: true],+ amount_remaining: [:string, nullable: true],+ display_amount: [:string, nullable: true],+ display_amount_used: [:string, nullable: true],+ display_amount_remaining: [:string, nullable: true],currency: :string,expires_at: [:string, nullable: true],redeemed_at: [:string, nullable: true],@@ -25,18 +25,22 @@ module Spreegift_card.display_stateend- attributes :currency, :amount, :amount_used, :amount_authorized, :amount_remaining+ attributes :currency++ # Nulled for gated (prices_hidden) guests so a gift card applied to a+ # cart can't leak balances the cart/order totals already withhold.+ money_attributes :amount, :amount_used, :amount_authorized, :amount_remainingattribute :display_amount do |gift_card|- gift_card.display_amount.to_s+ gift_card.display_amount.to_s unless params[:hide_prices]endattribute :display_amount_used do |gift_card|- gift_card.display_amount_used.to_s+ gift_card.display_amount_used.to_s unless params[:hide_prices]endattribute :display_amount_remaining do |gift_card|- gift_card.display_amount_remaining.to_s+ gift_card.display_amount_remaining.to_s unless params[:hide_prices]endattribute :expires_at do |gift_card|diff --git a/spree/api/app/serializers/spree/api/v3/line_item_serializer.rb b/spree/api/app/serializers/spree/api/v3/line_item_serializer.rbindex 81d9580c5b..52757a5c0e 100644--- a/spree/api/app/serializers/spree/api/v3/line_item_serializer.rb+++ b/spree/api/app/serializers/spree/api/v3/line_item_serializer.rb@@ -4,13 +4,14 @@ module Spreeclass LineItemSerializer < BaseSerializertypelize variant_id: :string, quantity: :number, currency: :string,name: :string, slug: :string, options_text: :string,- price: :string, display_price: :string, total: :string, display_total: :string,- adjustment_total: :string, display_adjustment_total: :string,- additional_tax_total: :string, display_additional_tax_total: :string,- included_tax_total: :string, display_included_tax_total: :string,- discount_total: :string, display_discount_total: :string,- pre_tax_amount: :string, display_pre_tax_amount: :string,- discounted_amount: :string, display_discounted_amount: :string,+ price: [:string, nullable: true], display_price: [:string, nullable: true],+ total: [:string, nullable: true], display_total: [:string, nullable: true],+ adjustment_total: [:string, nullable: true], display_adjustment_total: [:string, nullable: true],+ additional_tax_total: [:string, nullable: true], display_additional_tax_total: [:string, nullable: true],+ included_tax_total: [:string, nullable: true], display_included_tax_total: [:string, nullable: true],+ discount_total: [:string, nullable: true], display_discount_total: [:string, nullable: true],+ pre_tax_amount: [:string, nullable: true], display_pre_tax_amount: [:string, nullable: true],+ discounted_amount: [:string, nullable: true], display_discounted_amount: [:string, nullable: true],compare_at_amount: [:string, nullable: true], display_compare_at_amount: [:string, nullable: true],thumbnail_url: [:string, nullable: true]diff --git a/spree/api/app/serializers/spree/api/v3/order_serializer.rb b/spree/api/app/serializers/spree/api/v3/order_serializer.rbindex 77db526eeb..2fd10ab79f 100644--- a/spree/api/app/serializers/spree/api/v3/order_serializer.rb+++ b/spree/api/app/serializers/spree/api/v3/order_serializer.rb@@ -9,18 +9,18 @@ module Spreemarket_id: [:string, nullable: true], channel_id: [:string, nullable: true],currency: :string, locale: [:string, nullable: true], total_quantity: :number,fulfillment_status: [:string, nullable: true], payment_status: [:string, nullable: true],- item_total: :string, display_item_total: :string,- delivery_total: :string, display_delivery_total: :string,- adjustment_total: :string, display_adjustment_total: :string,- discount_total: :string, display_discount_total: :string,- tax_total: :string, display_tax_total: :string,- included_tax_total: :string, display_included_tax_total: :string,- additional_tax_total: :string, display_additional_tax_total: :string,- store_credit_total: :string, display_store_credit_total: :string,- gift_card_total: :string, display_gift_card_total: :string,+ item_total: [:string, nullable: true], display_item_total: [:string, nullable: true],+ delivery_total: [:string, nullable: true], display_delivery_total: [:string, nullable: true],+ adjustment_total: [:string, nullable: true], display_adjustment_total: [:string, nullable: true],+ discount_total: [:string, nullable: true], display_discount_total: [:string, nullable: true],+ tax_total: [:string, nullable: true], display_tax_total: [:string, nullable: true],+ included_tax_total: [:string, nullable: true], display_included_tax_total: [:string, nullable: true],+ additional_tax_total: [:string, nullable: true], display_additional_tax_total: [:string, nullable: true],+ store_credit_total: [:string, nullable: true], display_store_credit_total: [:string, nullable: true],+ gift_card_total: [:string, nullable: true], display_gift_card_total: [:string, nullable: true],covered_by_store_credit: :boolean,- total: :string, display_total: :string,- amount_due: :string, display_amount_due: :string,+ total: [:string, nullable: true], display_total: [:string, nullable: true],+ amount_due: [:string, nullable: true], display_amount_due: [:string, nullable: true],completed_at: [:string, nullable: true],billing_address: { nullable: true }, shipping_address: { nullable: true },gift_card: { nullable: true }, market: { nullable: true }diff --git a/spree/api/app/serializers/spree/api/v3/payment_serializer.rb b/spree/api/app/serializers/spree/api/v3/payment_serializer.rbindex 3c000b3059..79c4d34ee4 100644--- a/spree/api/app/serializers/spree/api/v3/payment_serializer.rb+++ b/spree/api/app/serializers/spree/api/v3/payment_serializer.rb@@ -3,7 +3,7 @@ module Spreemodule V3class PaymentSerializer < BaseSerializertypelize status: :string, payment_method_id: :string, response_code: [:string, nullable: true],- number: :string, amount: :string, display_amount: :string,+ number: :string, amount: [:string, nullable: true], display_amount: [:string, nullable: true],source_type: [:string, nullable: true, enum: %w[credit_card store_credit payment_source]],source_id: [:string, nullable: true],source: 'CreditCard | StoreCredit | PaymentSource | null'@@ -12,7 +12,11 @@ module Spreepayment.payment_method&.prefixed_idend- attributes :response_code, :number, :amount, :display_amount+ attributes :response_code, :number++ # Nulled for gated (prices_hidden) guests so a payment can't leak the+ # amount the cart/order totals already withhold.+ money_attributes :amount, :display_amountattribute :status do |payment|payment.statediff --git a/spree/api/config/initializers/typelizer.rb b/spree/api/config/initializers/typelizer.rbindex 306b662aa6..be279f8550 100644--- a/spree/api/config/initializers/typelizer.rb+++ b/spree/api/config/initializers/typelizer.rb@@ -10,6 +10,16 @@ Rails.application.config.after_initialize doconfig.comments = trueconfig.listen = false+ # Teach typelizer's Alba plugin about custom Alba types (see alba.rb);+ # unmapped typed attributes crash generation.+ config.plugin_configs = {+ alba: {+ ts_mapper: Typelizer::SerializerPlugins::Alba::ALBA_TS_MAPPER.merge(+ 'iso8601' => { type: :string }+ )+ }+ }+# Serializers that exist only for Admin API or events — no Store API controllerstore_excluded = %w[Asset CartPromotion OrderPromotiondiff --git a/spree/api/spec/serializers/spree/api/v3/price_gating_spec.rb b/spree/api/spec/serializers/spree/api/v3/price_gating_spec.rbindex 05470feb9d..9ef0ac0663 100644--- a/spree/api/spec/serializers/spree/api/v3/price_gating_spec.rb+++ b/spree/api/spec/serializers/spree/api/v3/price_gating_spec.rb@@ -1,15 +1,19 @@require 'spec_helper'# The prices_hidden gate injects a +hide_prices+ serializer param. These specs-# guard that the cart / order / line-item money surface honors it — so a guest-# can't recover a hidden catalog price via the cart or order.+# guard that the cart / order / line-item money surface — and every nested+# record embedded in it — honors it, so a guest can't recover a hidden catalog+# price through the cart, order, or any of their nested serializers.RSpec.describe 'v3 Store serializer price gating' dolet(:store) { @default_store || create(:store, default: true) }let(:order) { create(:order_with_line_items, store: store, line_items_count: 1) }- def serialize(serializer, hide:)+ # Derives the currency from the record so nested-serializer examples don't+ # have to build the (expensive) order fixture just to read its currency.+ def serialize(serializer, record = order, hide:)+ currency = record.respond_to?(:currency) ? record.currency : store.default_currencyJSON.parse(- serializer.new(order, params: { store: store, currency: order.currency, hide_prices: hide }).to_h.to_json+ serializer.new(record, params: { store: store, currency: currency, hide_prices: hide }).to_h.to_json)end@@ -37,11 +41,95 @@ RSpec.describe 'v3 Store serializer price gating' doenddescribe Spree::Api::V3::OrderSerializer do- it 'nulls totals for gated guests' do+ it 'nulls totals and store credit for gated guests' dohash = serialize(described_class, hide: true)expect(hash['total']).to be_nilexpect(hash['display_total']).to be_nil+ expect(hash['store_credit_total']).to be_nil+ expect(hash['display_store_credit_total']).to be_nil+ end++ it 'serializes totals when not gated' do+ expect(serialize(described_class, hide: false)['total']).to be_present+ end+ end++ # Nested records embedded in a cart/order must honor hide_prices too, so a+ # gated guest can't recover amounts through discounts, payments, fulfillments,+ # or an applied gift card.+ describe 'nested cart/order serializers' do+ describe Spree::Api::V3::PaymentSerializer do+ let(:payment) { create(:payment) }++ it 'nulls the amount for gated guests' do+ hash = serialize(described_class, payment, hide: true)++ expect(hash['amount']).to be_nil+ expect(hash['display_amount']).to be_nil+ end++ it 'serializes the amount when not gated' do+ expect(serialize(described_class, payment, hide: false)['amount']).to be_present+ end+ end++ describe Spree::Api::V3::FulfillmentSerializer do+ let(:shipment) { create(:shipment) }++ it 'nulls every money field for gated guests' do+ hash = serialize(described_class, shipment, hide: true)++ %w[cost display_cost total display_total+ discount_total display_discount_total+ additional_tax_total display_additional_tax_total+ included_tax_total display_included_tax_total+ tax_total display_tax_total].each do |field|+ expect(hash[field]).to be_nil, "expected #{field} to be nil"+ end+ end++ it 'serializes the cost when not gated' do+ expect(serialize(described_class, shipment, hide: false)['cost']).to be_present+ end+ end++ describe Spree::Api::V3::GiftCardSerializer do+ let(:gift_card) { create(:gift_card) }++ it 'nulls every balance field for gated guests' do+ hash = serialize(described_class, gift_card, hide: true)++ %w[amount amount_used amount_authorized amount_remaining+ display_amount display_amount_used display_amount_remaining].each do |field|+ expect(hash[field]).to be_nil, "expected #{field} to be nil"+ end+ end++ it 'serializes balances when not gated' do+ expect(serialize(described_class, gift_card, hide: false)['amount']).to be_present+ end+ end++ describe Spree::Api::V3::DiscountSerializer do+ # The record is a lightweight applied-discount presenter responding to the+ # money methods; a struct keeps the gating assertion factory-free.+ let(:discount) do+ Struct.new(:name, :description, :code, :amount, :display_amount, :promotion, keyword_init: true).new(+ name: 'Promo', description: nil, code: 'SAVE10', amount: '5.0', display_amount: '$5.00', promotion: nil+ )+ end++ it 'nulls the amount for gated guests' do+ hash = serialize(described_class, discount, hide: true)++ expect(hash['amount']).to be_nil+ expect(hash['display_amount']).to be_nil+ end++ it 'serializes the amount when not gated' do+ expect(serialize(described_class, discount, hide: false)['amount']).to be_present+ endendendend