Building a payment script

In this tutorial, you’ll learn how to create a basic example of a payment script.

Step 1: Create the script

In the Shopify CLI enter:

Start by replacing the contents of your payment script src/script.ts with the code below. paymentMethodsHandler runs when a buyer reaches the payment page of checkout. The results of this function are the sort order, payment methods to remove, or payment methods to rename.

Step 2: Push script to Shopify

Because scripts are hosted on Shopify, you'll need to push the script to Shopify and associate it with an app the first time.

In Shopify CLI enter:

Step 3: Enable in your store

By default scripts are available to be used on a store with the app installed, but are not enabled. In order to alter the behavior of checkout you must enable it.

In Shopify CLI enter:

Step 4: Test the script

Place a test order in your dev store, and go through the checkout steps. The payment methods shown at the payment step should show Renamed by scripts.

Next steps