Build a payment script

In this tutorial, you’ll learn how to create a basic payment script and deploy it to a custom app.

What you'll learn

After you've finished this tutorial, you'll have accomplish the following:

  • Created a basic payment script using Shopify CLI
  • Deployed your script to the Shopify platform and associated it with a custom app
  • Enabled the script in a Shopify store
  • Placed a test order in your store to confirm your script is working as expected

The following diagram shows the steps you'll follow to complete the workflow:

A diagram showing the steps involved in building a payment script

Requirements

Step 1: Create the script

Using Shopify CLI, run the following command:

Update the payment script

Replace the contents of your payment script in src/script.ts with the code below. paymentMethodsHandler runs when a customer 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: Deploy the script

To deploy a script to the Shopify platform and associate it with a custom app, run the following command:

Step 3: Enable the script

By default, scripts are available to be used on a store with the app installed, but they aren't enabled. To alter the behavior of checkout, you need to enable the script:

  1. In your store's Shopify admin, click Settings.
  2. Click Payments.
  3. In the Payment method customizations section, click Create customization.
  4. Select the script to enable and update its status to On.
  5. Click Save.

Step 4: Place a test order

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

A screenshot showing the label 'Renamed by scripts' above the payment method

Next steps