You can use payment customizations to hide, reorder, and rename the payment options that are available to buyers during checkout. In this tutorial, you'll use Shopify Functions to hide a payment option offered to customers at checkout, based on the total value of their cart.
## What you'll learn
In this tutorial, you’ll learn how to do the following tasks:
- Generate starter code for Shopify Functions.
- Use GraphQL to define the input of your function.
- Deploy functions to the Shopify platform.
- Review logs for your function.

## Requirements
- You've created a [Partner account](https://www.shopify.com/partners).
- You've created a [development store](/docs/api/development-stores#create-a-development-store-to-test-your-app).
- You've [created an app that uses Shopify CLI 3.49.5 or higher](/docs/apps/build/scaffold-app). If you previously installed Shopify CLI, then make sure that you're using the [latest version](/docs/api/shopify-cli#upgrade).
If you plan to create a UI for your extension, then start with the [Remix app template](/docs/api#app-templates).
- You've installed [Node.js](https://nodejs.org/en/download) 16 or higher.
- You've [installed your app](/docs/apps/build/scaffold-app#step-3-install-your-app-on-your-development-store) on the development store.
### Rust-specific requirements
The following requirements are specific to Rust-based development with Shopify Functions.
- You've installed [Rust](https://www.rust-lang.org/tools/install).
On Windows, Rust requires the [Microsoft C++ Build Tools](https://docs.microsoft.com/en-us/windows/dev-environment/rust/setup). Make sure to select the **Desktop development with C++** workload when installing the tools.
- You've installed the [`wasm32-wasip1` target](https://doc.rust-lang.org/rustc/platform-support/wasm32-wasip1.html):
## Limitations and considerations
- Plan and geographical restrictions apply. [Learn more](https://help.shopify.com/en/manual/checkout-settings/checkout-customization#understanding-payment-method-customizations)
- When the Payment Customization API usage is restricted, the function [input](/docs/api/functions/reference/payment-customization/graphql/input) will still contain all payment methods, however [output](/docs/api/functions/reference/payment-customization/graphql/functionrunresult) [operations](/docs/api/functions/reference/payment-customization/graphql/common-objects/operation) that target restricted payment methods will not take effect on the checkout.
- You can't rename payment methods that have logos as a name, such as **Shop Pay**, **Apple Pay** and **Google Pay**. This also includes all wallets and the Shopify native gift card field.
- In Point of Sale, Payment Customization Functions don't currently run, and operations aren't applied.
- In Shop Pay, payment customization functions do not apply operations on any payment methods except the native gift card field.
- You can remove wallets from the **Express** or payment method section of checkout, but you can't reorder them.
- You can install a maximum of five payment customization functions on each store.
## Step 1: Create the payment customization function
To create your payment customization function, you can use Shopify CLI to [generate](/docs/api/shopify-cli/app/app-generate-extension) a starter function, specify the inputs for your function using an [input query](/docs/apps/build/functions/input-output/metafields-for-input-queries), and implement your function logic using JavaScript or Rust.
1. Navigate to your app directory:
1. Run the following command to create a new payment customization extension:
1. Choose the language that you want to use. For this tutorial, you should select either **Rust** or **JavaScript**.
Shopify defaults to Rust as the most performant and recommended language choice to stay within the platform limits. For more information, refer to [language considerations](/docs/apps/build/functions/programming-languages).
1. Navigate to `extensions/payment-customization`:
1. Replace the contents of `src/run.graphql` file with the following code.
`run.graphql` defines the input for the function. You need the cart total and the available checkout payment methods.
The query differs slightly in Rust and JavaScript due to code generation requirements.
1. If you're using JavaScript, then run the following command to regenerate types based on your input query:
1. Replace the `src/run.rs` or `src/run.js` file with the following code.
This function logic will hide a payment method with a name containing `Cash on Delivery` when the cart total purchase amount is above `100`.
> Tip:
> If you're selling to multiple markets, then you might need to update this logic to include conversion to the store's default currency. Refer to [function development practices for money](/docs/apps/build/functions/localization-practices-shopify-functions#converting-money-values) for more information.
## Step 2: Preview the function on a development store
To test your function, you need to make it available to your development store.
1. If you're developing a function in a language other than JavaScript or TypeScript, ensure you have configured `build.watch` in your [function extension configuration](/docs/api/functions/configuration#properties).
1. Navigate back to your app root:
1. Use the Shopify CLI [`dev` command](/docs/api/shopify-cli/app/app-dev) to start app preview:
You can keep the preview running as you work on your function. When you make changes to a watched file, Shopify CLI rebuilds your function and updates the function extension's drafts, so you can immediately test your changes.
1. Follow the CLI prompts to preview your app, and install it on your development store.
## Step 3: Create the payment customization with GraphiQL
To activate your function, you must create a payment customization on the store where you installed your app. You can do this using the [`paymentCustomizationCreate`](/docs/api/admin-graphql/current/mutations/paymentCustomizationCreate) GraphQL mutation.
In subsequent tutorials, you'll use metafields on this payment customization to configure your function, and create a user interface so merchants can configure the function themselves.
1. Install the [Shopify GraphiQL app](https://shopify-graphiql-app.shopifycloud.com/) on your store. If you've already installed GraphiQL, then you should do so again to select the necessary access scopes for payment customizations.
> Note:
> Make sure to select the `read_payment_customizations` and `write_payment_customizations` access scopes for the Admin API.
1. In the GraphiQL app, in the **API Version** field, select the **2023-07** version.
1. Find the ID of your function by executing the following query:
The result contains a node with your function's ID:
1. Execute the following mutation and replace `YOUR_FUNCTION_ID_HERE` with the ID of your function:
You should receive a GraphQL response that includes the ID of the created payment customization. If the response includes any messages under `userErrors`, then review the errors, check that your mutation and `functionId` are correct, and try the request again.
> Tip:
> If you receive a `Could not find Function` error, then confirm the following:
>
> - The function ID is correct.
> - You've installed the app on your development store.
> - [Development store preview](#step-2-preview-the-function-on-a-development-store) is enabled.
## Step 4: Test the payment customization
1. From the Shopify admin, go to **Settings** > **Payments**.
1. Check the **Payment customizations** section. You should find the **Hide payment method by cart total** payment customization that you created with GraphiQL.
1. From the **Manual payment methods** section, click **Add manual payment method** and then click **Cash on Delivery (COD)**.
1. Click **Activate**.
1. Open your development store and build a cart with a total (including shipping and tax) under 100. The **Cash on Delivery** payment method should display in checkout.
1. Add additional items to your cart to raise the total over 100. Your payment function should now hide the **Cash on Delivery** payment option.
1. Open your terminal where `shopify app dev` is running, and review your function executions.
When [testing functions on development stores](/docs/apps/build/functions/test-debug-functions#test-your-function-on-a-development-store), the output of `dev` includes executions of your functions, any debug logging you have added to them, and a link to a local file with the full function execution details.
1. In a new terminal window, use the Shopify CLI [`app function replay`](/docs/api/shopify-cli/app/app-function-replay) command to [replay a function execution locally](/docs/apps/build/functions/test-debug-functions#execute-the-function-locally-using-shopify-cli), and debug your function without the need to re-trigger the function execution on Shopify.
1. Select the function execution from the top of the list. Press `q` to quit when you are finished debugging.
## Next steps
- [Add configuration](/docs/apps/build/checkout/payments/add-configuration) to your payment customization using metafields.