Getting started with payment methods scripts
In this tutorial, you’ll learn how to create a payment methods 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 payment methods 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:
Step 1: Create the script
Using Shopify CLI, run the following:
Update the payment methods script
Replace the contents of your payment methods script with the code below. This script renames the first payment method to
Renamed by scripts if there are one or more payment methods.
The script runs when a customer reaches the payment page of checkout. The results of the script are the sort order, payment methods to remove, and payment methods to rename.
Step 2: Deploy the script
To connect a script to a Shopify Partner organization and custom app, run the following command:
connect command can also be used to connect to a script that was previously deployed to an app. If any scripts were previously deployed to the app, then you can choose if you want to replace them. If you don't want to replace any scripts, then a new script is created when you deploy.
To deploy a script to the Shopify platform, 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:
- In your store's Shopify admin, click Settings.
- Click Payments.
- In the Payment method customizations section, click Create customization.
- Select the script to enable and update its status to On.
- 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: