From 719e0db5ebc4227060e94a4f06b9c916951cdc5c Mon Sep 17 00:00:00 2001 From: Martin Gingras Date: Mon, 28 Apr 2025 15:35:47 -0400 Subject: [PATCH] Update Payment Customization function templates --- .../default/schema.graphql | 138 +++++++++++++++++- .../default/shopify.extension.toml.liquid | 8 +- ...ment_methods_transform_run.graphql.liquid} | 2 +- .../cart_payment_methods_transform_run.liquid | 45 ++++++ ...payment_methods_transform_run.test.liquid} | 16 +- .../default/src/index.liquid | 2 +- .../default/src/run.liquid | 45 ------ .../default/schema.graphql | 138 +++++++++++++++++- .../default/shopify.extension.toml.liquid | 8 +- ...ment_methods_transform_run.graphql.liquid} | 0 ... => cart_payment_methods_transform_run.rs} | 14 +- .../payment-customization/default/src/main.rs | 2 +- ...ment_methods_transform_run.graphql.liquid} | 0 .../default/schema.graphql | 138 +++++++++++++++++- .../default/shopify.extension.toml.liquid | 8 +- 15 files changed, 468 insertions(+), 96 deletions(-) rename checkout/javascript/payment-customization/default/src/{run.graphql.liquid => cart_payment_methods_transform_run.graphql.liquid} (78%) create mode 100644 checkout/javascript/payment-customization/default/src/cart_payment_methods_transform_run.liquid rename checkout/javascript/payment-customization/default/src/{run.test.liquid => cart_payment_methods_transform_run.test.liquid} (50%) delete mode 100644 checkout/javascript/payment-customization/default/src/run.liquid rename checkout/rust/payment-customization/default/src/{run.graphql.liquid => cart_payment_methods_transform_run.graphql.liquid} (100%) rename checkout/rust/payment-customization/default/src/{run.rs => cart_payment_methods_transform_run.rs} (64%) rename checkout/wasm/payment-customization/default/{run.graphql.liquid => cart_payment_methods_transform_run.graphql.liquid} (100%) diff --git a/checkout/javascript/payment-customization/default/schema.graphql b/checkout/javascript/payment-customization/default/schema.graphql index e4d87819..e5ed4b00 100644 --- a/checkout/javascript/payment-customization/default/schema.graphql +++ b/checkout/javascript/payment-customization/default/schema.graphql @@ -328,6 +328,17 @@ type CartLineCost { totalAmount: MoneyV2! } +""" +The `CartPaymentMethodsTransformRunResult` object is the output of the Function +run target. The object contains the operations to apply to payment methods in checkout. +""" +input CartPaymentMethodsTransformRunResult { + """ + The ordered list of operations to apply to the list of payment methods. + """ + operations: [Operation!]! +} + """ Whether the product is in the specified collection. @@ -2778,6 +2789,45 @@ enum DeliveryMethod { SHIPPING } +""" +An operation to apply to the list of payment methods. +""" +input DeprecatedOperation @oneOf { + """ + A request to hide a payment method during checkout. + + When your Function returns this operation, it removes the specified payment method + from the available options shown to customers during checkout. + + Use this operation when you want to conditionally hide payment methods based on + checkout attributes, customer data, or other business logic implemented in your Function. + """ + hide: HideOperation @deprecated(reason: "Use `paymentMethodHide` instead.") + + """ + A request to move a payment method to a new position in the checkout display order. + + When your Function returns this operation, it changes the display order of payment methods + by placing the specified payment method at the requested index position. + + Use this operation when you want to prioritize certain payment methods based on + checkout context, customer preferences, or other business logic implemented in your Function. + """ + move: MoveOperation @deprecated(reason: "Use `paymentMethodMove` instead.") + + """ + A request to change the displayed name of a payment method during checkout. + + When your Function returns this operation, it replaces the default name of the + specified payment method with the custom name that's provided in the request. + + Use this operation when you want to provide more context or clarity about + payment methods based on checkout details, locale, or other business logic + implemented in your Function. + """ + rename: RenameOperation @deprecated(reason: "Use `paymentMethodRename` instead.") +} + """ The output of the Function run target. The object contains the operations to apply to payment methods in checkout. In API versions 2023-10 and beyond, this @@ -2787,7 +2837,7 @@ input FunctionResult { """ The ordered list of operations to apply to the list of payment methods. """ - operations: [Operation!]! + operations: [DeprecatedOperation!]! } """ @@ -2797,7 +2847,7 @@ input FunctionRunResult { """ The ordered list of operations to apply to the list of payment methods. """ - operations: [Operation!]! + operations: [DeprecatedOperation!]! } """ @@ -3772,7 +3822,7 @@ type Localization { """ The market of the active localized experience. """ - market: Market! + market: Market! @deprecated(reason: "This `market` field will be removed in a future version of the API.") } """ @@ -4040,7 +4090,7 @@ type MailingAddress { """ The market of the address. """ - market: Market + market: Market @deprecated(reason: "This `market` field will be removed in a future version of the API.") """ The full name of the customer, based on firstName and lastName. @@ -4220,6 +4270,16 @@ input MoveOperation { The root mutation for the API. """ type MutationRoot { + """ + Handles the Function result for the cart.payment-methods.transform.run target. + """ + cartPaymentMethodsTransformRun( + """ + The result of the Function. + """ + result: CartPaymentMethodsTransformRunResult! + ): Void! + """ Handles the Function result. """ @@ -4254,7 +4314,7 @@ input Operation @oneOf { Use this operation when you want to conditionally hide payment methods based on checkout attributes, customer data, or other business logic implemented in your Function. """ - hide: HideOperation + paymentMethodHide: PaymentMethodHideOperation """ A request to move a payment method to a new position in the checkout display order. @@ -4265,7 +4325,7 @@ input Operation @oneOf { Use this operation when you want to prioritize certain payment methods based on checkout context, customer preferences, or other business logic implemented in your Function. """ - move: MoveOperation + paymentMethodMove: PaymentMethodMoveOperation """ A request to change the displayed name of a payment method during checkout. @@ -4277,7 +4337,7 @@ input Operation @oneOf { payment methods based on checkout details, locale, or other business logic implemented in your Function. """ - rename: RenameOperation + paymentMethodRename: PaymentMethodRenameOperation } """ @@ -4343,6 +4403,70 @@ enum PaymentCustomizationPaymentMethodPlacement { PAYMENT_METHOD } +""" +A request to hide a payment method during checkout. + +When your Function returns this operation, it removes the specified payment method +from the available options shown to customers during checkout. + +Use this operation when you want to conditionally hide payment methods based on +checkout attributes, customer data, or other business logic implemented in your Function. +""" +input PaymentMethodHideOperation { + """ + The identifier of the payment method to hide out. + """ + paymentMethodId: ID! + + """ + Placement types to hide. If not provided, all placements will be hidden. + """ + placements: [PaymentCustomizationPaymentMethodPlacement!] +} + +""" +A request to move a payment method to a new position in the checkout display order. + +When your Function returns this operation, it changes the display order of payment methods +by placing the specified payment method at the requested index position. + +Use this operation when you want to prioritize certain payment methods based on +checkout context, customer preferences, or other business logic implemented in your Function. +""" +input PaymentMethodMoveOperation { + """ + The index to move the payment method to. + """ + index: Int! + + """ + The identifier of the payment method to move. + """ + paymentMethodId: ID! +} + +""" +A request to change the displayed name of a payment method during checkout. + +When your Function returns this operation, it replaces the default name of the +specified payment method with the custom name that's provided in the request. + +Use this operation when you want to provide more context or clarity about +payment methods based on checkout details, locale, or other business logic +implemented in your Function. +""" +input PaymentMethodRenameOperation { + """ + The new name for the payment method. + """ + name: String! + + """ + The identifier of the payment method to rename. + """ + paymentMethodId: ID! +} + """ The goods and services that merchants offer to customers. Products can include details such as title, vendor, and custom data stored in [metafields](https://shopify.dev/docs/apps/build/custom-data). diff --git a/checkout/javascript/payment-customization/default/shopify.extension.toml.liquid b/checkout/javascript/payment-customization/default/shopify.extension.toml.liquid index 6edc9611..9c7b6440 100644 --- a/checkout/javascript/payment-customization/default/shopify.extension.toml.liquid +++ b/checkout/javascript/payment-customization/default/shopify.extension.toml.liquid @@ -1,4 +1,4 @@ -api_version = "2025-01" +api_version = "2025-07" [[extensions]] name = "t:name" @@ -8,9 +8,9 @@ type = "function" description = "t:description" [[extensions.targeting]] - target = "purchase.payment-customization.run" - input_query = "src/run.graphql" - export = "run" + target = "cart.payment-methods.transform.run" + input_query = "src/cart_payment_methods_transform_run.graphql" + export = "cart-payment-methods-transform-run" [extensions.build] command = "" diff --git a/checkout/javascript/payment-customization/default/src/run.graphql.liquid b/checkout/javascript/payment-customization/default/src/cart_payment_methods_transform_run.graphql.liquid similarity index 78% rename from checkout/javascript/payment-customization/default/src/run.graphql.liquid rename to checkout/javascript/payment-customization/default/src/cart_payment_methods_transform_run.graphql.liquid index 8628f963..0969f408 100644 --- a/checkout/javascript/payment-customization/default/src/run.graphql.liquid +++ b/checkout/javascript/payment-customization/default/src/cart_payment_methods_transform_run.graphql.liquid @@ -1,4 +1,4 @@ -query RunInput { +query CartPaymentMethodsTransformRunInput { paymentCustomization { metafield(namespace: "$app:{{handle | replace: " ", "-" | downcase}}", key: "function-configuration") { value diff --git a/checkout/javascript/payment-customization/default/src/cart_payment_methods_transform_run.liquid b/checkout/javascript/payment-customization/default/src/cart_payment_methods_transform_run.liquid new file mode 100644 index 00000000..01e5a642 --- /dev/null +++ b/checkout/javascript/payment-customization/default/src/cart_payment_methods_transform_run.liquid @@ -0,0 +1,45 @@ +{%- if flavor contains "vanilla-js" -%} +// @ts-check + +/** + * @typedef {import("../generated/api").CartPaymentMethodsTransformRunInput} CartPaymentMethodsTransformRunInput + * @typedef {import("../generated/api").CartPaymentMethodsTransformRunResult} CartPaymentMethodsTransformRunResult + */ + +/** + * @type {CartPaymentMethodsTransformRunResult} + */ +const NO_CHANGES = { + operations: [], +}; + +/** + * @param {CartPaymentMethodsTransformRunInput} input + * @returns {CartPaymentMethodsTransformRunResult} + */ +export function cartPaymentMethodsTransformRun(input) { + const configuration = JSON.parse( + input?.paymentCustomization?.metafield?.value ?? "{}" + ); + + return NO_CHANGES; +}; +{%- elsif flavor contains "typescript" -%} +import type { + CartPaymentMethodsTransformRunInput, + CartPaymentMethodsTransformRunResult, +} from "../generated/api"; + +const NO_CHANGES: CartPaymentMethodsTransformRunResult = { + operations: [], +}; + +type Configuration = {}; + +export function cartPaymentMethodsTransformRun(input: CartPaymentMethodsTransformRunInput): CartPaymentMethodsTransformRunResult { + const configuration: Configuration = JSON.parse( + input?.paymentCustomization?.metafield?.value ?? "{}" + ); + return NO_CHANGES; +}; +{%- endif -%} diff --git a/checkout/javascript/payment-customization/default/src/run.test.liquid b/checkout/javascript/payment-customization/default/src/cart_payment_methods_transform_run.test.liquid similarity index 50% rename from checkout/javascript/payment-customization/default/src/run.test.liquid rename to checkout/javascript/payment-customization/default/src/cart_payment_methods_transform_run.test.liquid index 894d036e..15e66eb0 100644 --- a/checkout/javascript/payment-customization/default/src/run.test.liquid +++ b/checkout/javascript/payment-customization/default/src/cart_payment_methods_transform_run.test.liquid @@ -1,36 +1,36 @@ {%- if flavor contains "vanilla-js" -%} import { describe, it, expect } from 'vitest'; -import { run } from './run'; +import { cartPaymentMethodsTransformRun } from './cart_payment_methods_transform_run'; /** - * @typedef {import("../generated/api").FunctionRunResult} FunctionRunResult + * @typedef {import("../generated/api").CartPaymentMethodsTransformRunResult} CartPaymentMethodsTransformRunResult */ describe('payment customization function', () => { it('returns no operations without configuration', () => { - const result = run({ + const result = cartPaymentMethodsTransformRun({ paymentCustomization: { metafield: null } }); - const expected = /** @type {FunctionRunResult} */ ({ operations: [] }); + const expected = /** @type {CartPaymentMethodsTransformRunResult} */ ({ operations: [] }); expect(result).toEqual(expected); }); }); {%- elsif flavor contains "typescript" -%} import { describe, it, expect } from 'vitest'; -import { run } from './run'; -import { FunctionRunResult } from '../generated/api'; +import { cartPaymentMethodsTransformRun } from './cart_payment_methods_transform_run'; +import { CartPaymentMethodsTransformRunResult } from '../generated/api'; describe('payment customization function', () => { it('returns no operations without configuration', () => { - const result = run({ + const result = cartPaymentMethodsTransformRun({ paymentCustomization: { metafield: null } }); - const expected: FunctionRunResult = { operations: [] }; + const expected: CartPaymentMethodsTransformRunResult = { operations: [] }; expect(result).toEqual(expected); }); diff --git a/checkout/javascript/payment-customization/default/src/index.liquid b/checkout/javascript/payment-customization/default/src/index.liquid index 2e6f9676..6da48efe 100644 --- a/checkout/javascript/payment-customization/default/src/index.liquid +++ b/checkout/javascript/payment-customization/default/src/index.liquid @@ -1 +1 @@ -export * from './run'; +export * from './cart_payment_methods_transform_run'; diff --git a/checkout/javascript/payment-customization/default/src/run.liquid b/checkout/javascript/payment-customization/default/src/run.liquid deleted file mode 100644 index 8c6d24ab..00000000 --- a/checkout/javascript/payment-customization/default/src/run.liquid +++ /dev/null @@ -1,45 +0,0 @@ -{%- if flavor contains "vanilla-js" -%} -// @ts-check - -/** - * @typedef {import("../generated/api").RunInput} RunInput - * @typedef {import("../generated/api").FunctionRunResult} FunctionRunResult - */ - -/** - * @type {FunctionRunResult} - */ -const NO_CHANGES = { - operations: [], -}; - -/** - * @param {RunInput} input - * @returns {FunctionRunResult} - */ -export function run(input) { - const configuration = JSON.parse( - input?.paymentCustomization?.metafield?.value ?? "{}" - ); - - return NO_CHANGES; -}; -{%- elsif flavor contains "typescript" -%} -import type { - RunInput, - FunctionRunResult, -} from "../generated/api"; - -const NO_CHANGES: FunctionRunResult = { - operations: [], -}; - -type Configuration = {}; - -export function run(input: RunInput): FunctionRunResult { - const configuration: Configuration = JSON.parse( - input?.paymentCustomization?.metafield?.value ?? "{}" - ); - return NO_CHANGES; -}; -{%- endif -%} diff --git a/checkout/rust/payment-customization/default/schema.graphql b/checkout/rust/payment-customization/default/schema.graphql index e4d87819..e5ed4b00 100644 --- a/checkout/rust/payment-customization/default/schema.graphql +++ b/checkout/rust/payment-customization/default/schema.graphql @@ -328,6 +328,17 @@ type CartLineCost { totalAmount: MoneyV2! } +""" +The `CartPaymentMethodsTransformRunResult` object is the output of the Function +run target. The object contains the operations to apply to payment methods in checkout. +""" +input CartPaymentMethodsTransformRunResult { + """ + The ordered list of operations to apply to the list of payment methods. + """ + operations: [Operation!]! +} + """ Whether the product is in the specified collection. @@ -2778,6 +2789,45 @@ enum DeliveryMethod { SHIPPING } +""" +An operation to apply to the list of payment methods. +""" +input DeprecatedOperation @oneOf { + """ + A request to hide a payment method during checkout. + + When your Function returns this operation, it removes the specified payment method + from the available options shown to customers during checkout. + + Use this operation when you want to conditionally hide payment methods based on + checkout attributes, customer data, or other business logic implemented in your Function. + """ + hide: HideOperation @deprecated(reason: "Use `paymentMethodHide` instead.") + + """ + A request to move a payment method to a new position in the checkout display order. + + When your Function returns this operation, it changes the display order of payment methods + by placing the specified payment method at the requested index position. + + Use this operation when you want to prioritize certain payment methods based on + checkout context, customer preferences, or other business logic implemented in your Function. + """ + move: MoveOperation @deprecated(reason: "Use `paymentMethodMove` instead.") + + """ + A request to change the displayed name of a payment method during checkout. + + When your Function returns this operation, it replaces the default name of the + specified payment method with the custom name that's provided in the request. + + Use this operation when you want to provide more context or clarity about + payment methods based on checkout details, locale, or other business logic + implemented in your Function. + """ + rename: RenameOperation @deprecated(reason: "Use `paymentMethodRename` instead.") +} + """ The output of the Function run target. The object contains the operations to apply to payment methods in checkout. In API versions 2023-10 and beyond, this @@ -2787,7 +2837,7 @@ input FunctionResult { """ The ordered list of operations to apply to the list of payment methods. """ - operations: [Operation!]! + operations: [DeprecatedOperation!]! } """ @@ -2797,7 +2847,7 @@ input FunctionRunResult { """ The ordered list of operations to apply to the list of payment methods. """ - operations: [Operation!]! + operations: [DeprecatedOperation!]! } """ @@ -3772,7 +3822,7 @@ type Localization { """ The market of the active localized experience. """ - market: Market! + market: Market! @deprecated(reason: "This `market` field will be removed in a future version of the API.") } """ @@ -4040,7 +4090,7 @@ type MailingAddress { """ The market of the address. """ - market: Market + market: Market @deprecated(reason: "This `market` field will be removed in a future version of the API.") """ The full name of the customer, based on firstName and lastName. @@ -4220,6 +4270,16 @@ input MoveOperation { The root mutation for the API. """ type MutationRoot { + """ + Handles the Function result for the cart.payment-methods.transform.run target. + """ + cartPaymentMethodsTransformRun( + """ + The result of the Function. + """ + result: CartPaymentMethodsTransformRunResult! + ): Void! + """ Handles the Function result. """ @@ -4254,7 +4314,7 @@ input Operation @oneOf { Use this operation when you want to conditionally hide payment methods based on checkout attributes, customer data, or other business logic implemented in your Function. """ - hide: HideOperation + paymentMethodHide: PaymentMethodHideOperation """ A request to move a payment method to a new position in the checkout display order. @@ -4265,7 +4325,7 @@ input Operation @oneOf { Use this operation when you want to prioritize certain payment methods based on checkout context, customer preferences, or other business logic implemented in your Function. """ - move: MoveOperation + paymentMethodMove: PaymentMethodMoveOperation """ A request to change the displayed name of a payment method during checkout. @@ -4277,7 +4337,7 @@ input Operation @oneOf { payment methods based on checkout details, locale, or other business logic implemented in your Function. """ - rename: RenameOperation + paymentMethodRename: PaymentMethodRenameOperation } """ @@ -4343,6 +4403,70 @@ enum PaymentCustomizationPaymentMethodPlacement { PAYMENT_METHOD } +""" +A request to hide a payment method during checkout. + +When your Function returns this operation, it removes the specified payment method +from the available options shown to customers during checkout. + +Use this operation when you want to conditionally hide payment methods based on +checkout attributes, customer data, or other business logic implemented in your Function. +""" +input PaymentMethodHideOperation { + """ + The identifier of the payment method to hide out. + """ + paymentMethodId: ID! + + """ + Placement types to hide. If not provided, all placements will be hidden. + """ + placements: [PaymentCustomizationPaymentMethodPlacement!] +} + +""" +A request to move a payment method to a new position in the checkout display order. + +When your Function returns this operation, it changes the display order of payment methods +by placing the specified payment method at the requested index position. + +Use this operation when you want to prioritize certain payment methods based on +checkout context, customer preferences, or other business logic implemented in your Function. +""" +input PaymentMethodMoveOperation { + """ + The index to move the payment method to. + """ + index: Int! + + """ + The identifier of the payment method to move. + """ + paymentMethodId: ID! +} + +""" +A request to change the displayed name of a payment method during checkout. + +When your Function returns this operation, it replaces the default name of the +specified payment method with the custom name that's provided in the request. + +Use this operation when you want to provide more context or clarity about +payment methods based on checkout details, locale, or other business logic +implemented in your Function. +""" +input PaymentMethodRenameOperation { + """ + The new name for the payment method. + """ + name: String! + + """ + The identifier of the payment method to rename. + """ + paymentMethodId: ID! +} + """ The goods and services that merchants offer to customers. Products can include details such as title, vendor, and custom data stored in [metafields](https://shopify.dev/docs/apps/build/custom-data). diff --git a/checkout/rust/payment-customization/default/shopify.extension.toml.liquid b/checkout/rust/payment-customization/default/shopify.extension.toml.liquid index ca3558e6..9ff28a45 100644 --- a/checkout/rust/payment-customization/default/shopify.extension.toml.liquid +++ b/checkout/rust/payment-customization/default/shopify.extension.toml.liquid @@ -1,4 +1,4 @@ -api_version = "2025-01" +api_version = "2025-07" [[extensions]] name = "t:name" @@ -8,9 +8,9 @@ type = "function" description = "t:description" [[extensions.targeting]] - target = "purchase.payment-customization.run" - input_query = "src/run.graphql" - export = "run" + target = "cart.payment-methods.transform.run" + input_query = "src/cart_payment_methods_transform_run.graphql" + export = "cart_payment_methods_transform_run" [extensions.build] command = "cargo build --target=wasm32-wasip1 --release" diff --git a/checkout/rust/payment-customization/default/src/run.graphql.liquid b/checkout/rust/payment-customization/default/src/cart_payment_methods_transform_run.graphql.liquid similarity index 100% rename from checkout/rust/payment-customization/default/src/run.graphql.liquid rename to checkout/rust/payment-customization/default/src/cart_payment_methods_transform_run.graphql.liquid diff --git a/checkout/rust/payment-customization/default/src/run.rs b/checkout/rust/payment-customization/default/src/cart_payment_methods_transform_run.rs similarity index 64% rename from checkout/rust/payment-customization/default/src/run.rs rename to checkout/rust/payment-customization/default/src/cart_payment_methods_transform_run.rs index b8d88f47..341c0971 100644 --- a/checkout/rust/payment-customization/default/src/run.rs +++ b/checkout/rust/payment-customization/default/src/cart_payment_methods_transform_run.rs @@ -13,9 +13,9 @@ impl Configuration { } } -#[shopify_function_target(query_path = "src/run.graphql", schema_path = "schema.graphql")] -fn run(input: input::ResponseData) -> Result { - let no_changes = output::FunctionRunResult { operations: vec![] }; +#[shopify_function_target(query_path = "src/cart_payment_methods_transform_run.graphql", schema_path = "schema.graphql")] +fn cart_payment_methods_transform_run(input: input::ResponseData) -> Result { + let no_changes = output::CartPaymentMethodsTransformRunResult { operations: vec![] }; let _config = match input.payment_customization.metafield { Some(input::InputPaymentCustomizationMetafield { value }) => { @@ -24,7 +24,7 @@ fn run(input: input::ResponseData) -> Result { None => return Ok(no_changes), }; - Ok(output::FunctionRunResult { operations: vec![] }) + Ok(output::CartPaymentMethodsTransformRunResult { operations: vec![] }) } #[cfg(test)] @@ -34,10 +34,10 @@ mod tests { #[test] fn test_result_contains_no_operations() -> Result<()> { - use run::output::*; + use cart_payment_methods_transform_run::output::*; let result = run_function_with_input( - run, + cart_payment_methods_transform_run, r#" { "paymentCustomization": { @@ -46,7 +46,7 @@ mod tests { } "#, )?; - let expected = FunctionRunResult { operations: vec![] }; + let expected = CartPaymentMethodsTransformRunResult { operations: vec![] }; assert_eq!(result, expected); Ok(()) diff --git a/checkout/rust/payment-customization/default/src/main.rs b/checkout/rust/payment-customization/default/src/main.rs index 9272b027..fcdbf85e 100644 --- a/checkout/rust/payment-customization/default/src/main.rs +++ b/checkout/rust/payment-customization/default/src/main.rs @@ -1,5 +1,5 @@ use std::process; -pub mod run; +pub mod cart_payment_methods_transform_run; fn main() { eprintln!("Please invoke a named export."); diff --git a/checkout/wasm/payment-customization/default/run.graphql.liquid b/checkout/wasm/payment-customization/default/cart_payment_methods_transform_run.graphql.liquid similarity index 100% rename from checkout/wasm/payment-customization/default/run.graphql.liquid rename to checkout/wasm/payment-customization/default/cart_payment_methods_transform_run.graphql.liquid diff --git a/checkout/wasm/payment-customization/default/schema.graphql b/checkout/wasm/payment-customization/default/schema.graphql index e4d87819..e5ed4b00 100644 --- a/checkout/wasm/payment-customization/default/schema.graphql +++ b/checkout/wasm/payment-customization/default/schema.graphql @@ -328,6 +328,17 @@ type CartLineCost { totalAmount: MoneyV2! } +""" +The `CartPaymentMethodsTransformRunResult` object is the output of the Function +run target. The object contains the operations to apply to payment methods in checkout. +""" +input CartPaymentMethodsTransformRunResult { + """ + The ordered list of operations to apply to the list of payment methods. + """ + operations: [Operation!]! +} + """ Whether the product is in the specified collection. @@ -2778,6 +2789,45 @@ enum DeliveryMethod { SHIPPING } +""" +An operation to apply to the list of payment methods. +""" +input DeprecatedOperation @oneOf { + """ + A request to hide a payment method during checkout. + + When your Function returns this operation, it removes the specified payment method + from the available options shown to customers during checkout. + + Use this operation when you want to conditionally hide payment methods based on + checkout attributes, customer data, or other business logic implemented in your Function. + """ + hide: HideOperation @deprecated(reason: "Use `paymentMethodHide` instead.") + + """ + A request to move a payment method to a new position in the checkout display order. + + When your Function returns this operation, it changes the display order of payment methods + by placing the specified payment method at the requested index position. + + Use this operation when you want to prioritize certain payment methods based on + checkout context, customer preferences, or other business logic implemented in your Function. + """ + move: MoveOperation @deprecated(reason: "Use `paymentMethodMove` instead.") + + """ + A request to change the displayed name of a payment method during checkout. + + When your Function returns this operation, it replaces the default name of the + specified payment method with the custom name that's provided in the request. + + Use this operation when you want to provide more context or clarity about + payment methods based on checkout details, locale, or other business logic + implemented in your Function. + """ + rename: RenameOperation @deprecated(reason: "Use `paymentMethodRename` instead.") +} + """ The output of the Function run target. The object contains the operations to apply to payment methods in checkout. In API versions 2023-10 and beyond, this @@ -2787,7 +2837,7 @@ input FunctionResult { """ The ordered list of operations to apply to the list of payment methods. """ - operations: [Operation!]! + operations: [DeprecatedOperation!]! } """ @@ -2797,7 +2847,7 @@ input FunctionRunResult { """ The ordered list of operations to apply to the list of payment methods. """ - operations: [Operation!]! + operations: [DeprecatedOperation!]! } """ @@ -3772,7 +3822,7 @@ type Localization { """ The market of the active localized experience. """ - market: Market! + market: Market! @deprecated(reason: "This `market` field will be removed in a future version of the API.") } """ @@ -4040,7 +4090,7 @@ type MailingAddress { """ The market of the address. """ - market: Market + market: Market @deprecated(reason: "This `market` field will be removed in a future version of the API.") """ The full name of the customer, based on firstName and lastName. @@ -4220,6 +4270,16 @@ input MoveOperation { The root mutation for the API. """ type MutationRoot { + """ + Handles the Function result for the cart.payment-methods.transform.run target. + """ + cartPaymentMethodsTransformRun( + """ + The result of the Function. + """ + result: CartPaymentMethodsTransformRunResult! + ): Void! + """ Handles the Function result. """ @@ -4254,7 +4314,7 @@ input Operation @oneOf { Use this operation when you want to conditionally hide payment methods based on checkout attributes, customer data, or other business logic implemented in your Function. """ - hide: HideOperation + paymentMethodHide: PaymentMethodHideOperation """ A request to move a payment method to a new position in the checkout display order. @@ -4265,7 +4325,7 @@ input Operation @oneOf { Use this operation when you want to prioritize certain payment methods based on checkout context, customer preferences, or other business logic implemented in your Function. """ - move: MoveOperation + paymentMethodMove: PaymentMethodMoveOperation """ A request to change the displayed name of a payment method during checkout. @@ -4277,7 +4337,7 @@ input Operation @oneOf { payment methods based on checkout details, locale, or other business logic implemented in your Function. """ - rename: RenameOperation + paymentMethodRename: PaymentMethodRenameOperation } """ @@ -4343,6 +4403,70 @@ enum PaymentCustomizationPaymentMethodPlacement { PAYMENT_METHOD } +""" +A request to hide a payment method during checkout. + +When your Function returns this operation, it removes the specified payment method +from the available options shown to customers during checkout. + +Use this operation when you want to conditionally hide payment methods based on +checkout attributes, customer data, or other business logic implemented in your Function. +""" +input PaymentMethodHideOperation { + """ + The identifier of the payment method to hide out. + """ + paymentMethodId: ID! + + """ + Placement types to hide. If not provided, all placements will be hidden. + """ + placements: [PaymentCustomizationPaymentMethodPlacement!] +} + +""" +A request to move a payment method to a new position in the checkout display order. + +When your Function returns this operation, it changes the display order of payment methods +by placing the specified payment method at the requested index position. + +Use this operation when you want to prioritize certain payment methods based on +checkout context, customer preferences, or other business logic implemented in your Function. +""" +input PaymentMethodMoveOperation { + """ + The index to move the payment method to. + """ + index: Int! + + """ + The identifier of the payment method to move. + """ + paymentMethodId: ID! +} + +""" +A request to change the displayed name of a payment method during checkout. + +When your Function returns this operation, it replaces the default name of the +specified payment method with the custom name that's provided in the request. + +Use this operation when you want to provide more context or clarity about +payment methods based on checkout details, locale, or other business logic +implemented in your Function. +""" +input PaymentMethodRenameOperation { + """ + The new name for the payment method. + """ + name: String! + + """ + The identifier of the payment method to rename. + """ + paymentMethodId: ID! +} + """ The goods and services that merchants offer to customers. Products can include details such as title, vendor, and custom data stored in [metafields](https://shopify.dev/docs/apps/build/custom-data). diff --git a/checkout/wasm/payment-customization/default/shopify.extension.toml.liquid b/checkout/wasm/payment-customization/default/shopify.extension.toml.liquid index a97837c9..4125f154 100644 --- a/checkout/wasm/payment-customization/default/shopify.extension.toml.liquid +++ b/checkout/wasm/payment-customization/default/shopify.extension.toml.liquid @@ -1,4 +1,4 @@ -api_version = "2025-01" +api_version = "2025-07" [[extensions]] name = "t:name" @@ -8,9 +8,9 @@ type = "function" description = "t:description" [[extensions.targeting]] - target = "purchase.payment-customization.run" - input_query = "run.graphql" - export = "run" + target = "cart.payment-methods.transform.run" + input_query = "cart_payment_methods_transform_run.graphql" + export = "cart_payment_methods_transform_run" [extensions.build] command = "echo 'build the wasm'"