diff --git a/platforms/android/lib/src/test/java/com/shopify/checkoutkit/CheckoutProtocolTest.kt b/platforms/android/lib/src/test/java/com/shopify/checkoutkit/CheckoutProtocolTest.kt index e838aa1f..029754d0 100644 --- a/platforms/android/lib/src/test/java/com/shopify/checkoutkit/CheckoutProtocolTest.kt +++ b/platforms/android/lib/src/test/java/com/shopify/checkoutkit/CheckoutProtocolTest.kt @@ -60,6 +60,7 @@ class CheckoutProtocolTest { @Test fun `supported protocol methods exclude internal or unsupported methods`() { assertThat(CheckoutProtocol.supportedProtocolMethods).doesNotContain( + "ec.buyer.change", "ec.payment.credential_request", "ep.cart.ready", ) diff --git a/platforms/web/README.md b/platforms/web/README.md index 2a7b41f0..7c903639 100644 --- a/platforms/web/README.md +++ b/platforms/web/README.md @@ -395,7 +395,6 @@ exactly the fields relevant to that moment. | `checkout:close` | _(none)_ | The popup was dismissed (by the buyer, by `close()`, or by `focus` loss). | | `checkout:error` | `{error}` | Session-level fatal error — tear down the embedded context. | | `checkout:lineItemsChange` | `{checkout, lineItems}` | The cart's line items changed (item added/removed/quantity updated). | -| `checkout:buyerChange` | `{checkout, buyer}` | The buyer's information changed (email, address, etc.). | | `checkout:totalsChange` | `{checkout, totals}` | The cart totals changed (subtotal, tax, shipping, discounts, total). | | `checkout:messagesChange` | `{checkout, messages}` | Checkout-level warnings/errors/info shown inside the checkout changed. | diff --git a/platforms/web/sample/main.ts b/platforms/web/sample/main.ts index aefb005f..23779858 100644 --- a/platforms/web/sample/main.ts +++ b/platforms/web/sample/main.ts @@ -134,7 +134,6 @@ const EVENT_TYPES = [ "checkout:close", "checkout:error", "checkout:lineItemsChange", - "checkout:buyerChange", "checkout:totalsChange", "checkout:messagesChange", ] as const; diff --git a/platforms/web/src/checkout.test.ts b/platforms/web/src/checkout.test.ts index 5bd4a53a..dd457b62 100644 --- a/platforms/web/src/checkout.test.ts +++ b/platforms/web/src/checkout.test.ts @@ -821,21 +821,24 @@ describe("", () => { expect(mockCheckoutWindow.postMessage).not.toHaveBeenCalled(); }); - it("ignores unsupported notifications", () => { - const { checkout, mockCheckoutWindow } = openPopupCheckout(); + it.each(["customMethod", "ec.buyer.change"])( + "ignores unsupported notification %s", + (method) => { + const { checkout, mockCheckoutWindow } = openPopupCheckout(); - simulateRawMessageEvent( - checkout, - { - jsonrpc: "2.0", - method: "customMethod", - params: {}, - }, - { source: mockCheckoutWindow }, - ); + simulateRawMessageEvent( + checkout, + { + jsonrpc: "2.0", + method, + params: {}, + }, + { source: mockCheckoutWindow }, + ); - expect(mockCheckoutWindow.postMessage).not.toHaveBeenCalled(); - }); + expect(mockCheckoutWindow.postMessage).not.toHaveBeenCalled(); + }, + ); }); describe("checkout:start", () => { @@ -971,23 +974,6 @@ describe("", () => { }); }); - describe("checkout:buyerChange", () => { - it("updates the checkout property and dispatches an ec:buyerChange event", async () => { - const { checkout, mockCheckoutWindow } = openPopupCheckout(); - const onBuyerChangeSpy = vi.fn(); - const listenForEvent = waitForEvent(checkout, "checkout:buyerChange", onBuyerChangeSpy); - - const payload = makeCheckoutPayload(); - simulateProtocolMessageEvent(checkout, "ec.buyer.change", payload, { - source: mockCheckoutWindow, - }); - await listenForEvent; - - expect(checkout.checkout).toBe(payload.checkout); - expect(onBuyerChangeSpy).toHaveBeenCalledOnce(); - }); - }); - describe("checkout:totalsChange", () => { it("updates the checkout property and dispatches an ec:totalsChange event", async () => { const { checkout, mockCheckoutWindow } = openPopupCheckout(); @@ -1092,22 +1078,6 @@ describe("", () => { expect(event.detail.checkout).toBe(payload.checkout); }); - it("checkout:buyerChange carries {buyer, checkout}", async () => { - const { checkout, mockCheckoutWindow } = openPopupCheckout(); - const spy = vi.fn(); - const wait = waitForEvent(checkout, "checkout:buyerChange", spy); - - const payload = makeCheckoutPayload(); - simulateProtocolMessageEvent(checkout, "ec.buyer.change", payload, { - source: mockCheckoutWindow, - }); - await wait; - - const event = spy.mock.calls[0]![0] as CustomEvent; - expect(event.detail.buyer).toBe(payload.checkout.buyer); - expect(event.detail.checkout).toBe(payload.checkout); - }); - it("checkout:totalsChange carries {totals, checkout}", async () => { const { checkout, mockCheckoutWindow } = openPopupCheckout(); const spy = vi.fn(); diff --git a/platforms/web/src/checkout.ts b/platforms/web/src/checkout.ts index 1cbc2094..39a62145 100644 --- a/platforms/web/src/checkout.ts +++ b/platforms/web/src/checkout.ts @@ -11,7 +11,6 @@ import type { CheckoutLineItem, CheckoutMessage, Total, - Buyer, OrderConfirmation, UcpErrorResponse, } from "./checkout.types"; @@ -66,7 +65,6 @@ const SHADOW_TEMPLATE = createTemplate(html` * @event checkout:complete - Dispatched when the checkout was successfully completed * @event checkout:error - Dispatched on a session-level fatal error * @event checkout:lineItemsChange - Dispatched when cart line items change - * @event checkout:buyerChange - Dispatched when buyer information changes * @event checkout:totalsChange - Dispatched when totals change * @event checkout:messagesChange - Dispatched when checkout messages change * @event checkout:close - Dispatched when the checkout overlay is closed (synthetic, not part of ECP) @@ -580,16 +578,6 @@ export class ShopifyCheckout ); break; } - case "ec.buyer.change": { - const checkout = (message.body as CheckoutProtocolMessageMap["ec.buyer.change"]).checkout; - this.dispatchEvent( - new ShopifyCheckoutBuyerChangeEvent({ - checkout, - buyer: checkout.buyer, - }), - ); - break; - } case "ec.totals.change": { const checkout = (message.body as CheckoutProtocolMessageMap["ec.totals.change"]).checkout; this.dispatchEvent( @@ -761,12 +749,6 @@ export class ShopifyCheckout options?: boolean | AddEventListenerOptions, ): void; - override addEventListener( - type: "checkout:buyerChange", - listener: TypedEventListener | null, - options?: boolean | AddEventListenerOptions, - ): void; - override addEventListener( type: "checkout:totalsChange", listener: TypedEventListener | null, @@ -818,13 +800,6 @@ export interface ShopifyCheckoutLineItemsChangeEventDetail { checkout: Checkout; } -export interface ShopifyCheckoutBuyerChangeEventDetail { - /** Updated buyer (may be undefined when buyer information is cleared). */ - buyer: Buyer | undefined; - /** Full checkout snapshot for handlers that want broader context. */ - checkout: Checkout; -} - export interface ShopifyCheckoutTotalsChangeEventDetail { /** Updated totals. */ totals: readonly Total[]; @@ -884,14 +859,6 @@ export class ShopifyCheckoutLineItemsChangeEvent extends CustomEvent { - declare type: "checkout:buyerChange"; - - constructor(detail: ShopifyCheckoutBuyerChangeEventDetail) { - super("checkout:buyerChange", { detail, bubbles: true }); - } -} - export class ShopifyCheckoutTotalsChangeEvent extends CustomEvent { declare type: "checkout:totalsChange"; @@ -918,7 +885,6 @@ const CHECKOUT_PROTOCOL_MESSAGES: (keyof CheckoutProtocolMessageMap)[] = [ "ec.complete", "ec.error", "ec.line_items.change", - "ec.buyer.change", "ec.totals.change", "ec.messages.change", "ec.window.open_request", diff --git a/platforms/web/src/checkout.types.ts b/platforms/web/src/checkout.types.ts index 14dc32ad..3ae49ee0 100644 --- a/platforms/web/src/checkout.types.ts +++ b/platforms/web/src/checkout.types.ts @@ -2,7 +2,6 @@ // checkout protocol. Embed payload shapes live in `./ucp-embed-types.ts`. import type { - Buyer, Checkout, CheckoutLineItem, CheckoutMessage, @@ -118,11 +117,6 @@ export interface CheckoutEvents { */ "checkout:lineItemsChange": CheckoutLineItemsChangeEvent; - /** - * Dispatched when the buyer information changes. - */ - "checkout:buyerChange": CheckoutBuyerChangeEvent; - /** * Dispatched when the totals change. */ @@ -175,16 +169,6 @@ export interface CheckoutLineItemsChangeEvent { }; } -export interface CheckoutBuyerChangeEvent { - type: "checkout:buyerChange"; - detail: { - /** Updated buyer (may be undefined when buyer information is cleared). */ - buyer: Buyer | undefined; - /** Full checkout snapshot for handlers that want broader context. */ - checkout: Checkout; - }; -} - export interface CheckoutTotalsChangeEvent { type: "checkout:totalsChange"; detail: { @@ -252,7 +236,6 @@ export interface CheckoutProtocolMessageMap { "ec.complete": CheckoutPayload; "ec.error": EcErrorParams; "ec.line_items.change": CheckoutPayload; - "ec.buyer.change": CheckoutPayload; "ec.totals.change": CheckoutPayload; "ec.messages.change": CheckoutPayload; "ec.window.open_request": { url: string }; diff --git a/platforms/web/src/index.test.ts b/platforms/web/src/index.test.ts index 2665145e..15eb1f4d 100644 --- a/platforms/web/src/index.test.ts +++ b/platforms/web/src/index.test.ts @@ -15,7 +15,6 @@ describe("@shopify/checkout-kit public entry", () => { pkg.ShopifyCheckoutCloseEvent, pkg.ShopifyCheckoutErrorEvent, pkg.ShopifyCheckoutLineItemsChangeEvent, - pkg.ShopifyCheckoutBuyerChangeEvent, pkg.ShopifyCheckoutTotalsChangeEvent, pkg.ShopifyCheckoutMessagesChangeEvent, ]; diff --git a/platforms/web/src/index.ts b/platforms/web/src/index.ts index 729eb3e3..88db6e15 100644 --- a/platforms/web/src/index.ts +++ b/platforms/web/src/index.ts @@ -11,7 +11,6 @@ export { ShopifyCheckoutCloseEvent, ShopifyCheckoutErrorEvent, ShopifyCheckoutLineItemsChangeEvent, - ShopifyCheckoutBuyerChangeEvent, ShopifyCheckoutTotalsChangeEvent, ShopifyCheckoutMessagesChangeEvent, } from "./checkout"; @@ -22,7 +21,6 @@ export type { ShopifyCheckoutCompleteEventDetail, ShopifyCheckoutErrorEventDetail, ShopifyCheckoutLineItemsChangeEventDetail, - ShopifyCheckoutBuyerChangeEventDetail, ShopifyCheckoutTotalsChangeEventDetail, ShopifyCheckoutMessagesChangeEventDetail, } from "./checkout"; diff --git a/protocol/languages/swift/Tests/ShopifyCheckoutProtocolTests/DescriptorTests.swift b/protocol/languages/swift/Tests/ShopifyCheckoutProtocolTests/DescriptorTests.swift index bada7607..dc981217 100644 --- a/protocol/languages/swift/Tests/ShopifyCheckoutProtocolTests/DescriptorTests.swift +++ b/protocol/languages/swift/Tests/ShopifyCheckoutProtocolTests/DescriptorTests.swift @@ -54,6 +54,7 @@ struct DescriptorTests { } @Test func excludesInternalOrUnsupportedMethods() { + #expect(!CheckoutProtocol.supportedProtocolMethods.contains("ec.buyer.change")) #expect(!CheckoutProtocol.supportedProtocolMethods.contains("ec.payment.credential_request")) #expect(!CheckoutProtocol.supportedProtocolMethods.contains("ep.cart.ready")) }