We have developed an application that is based on the Payment Customization Function API, which allows for conditional operations on shipping payments:
- Sorting payment method names
- Hiding/showing selected payment methods
- Changing the position of a payment method (e.g., setting it to the first position)
The application is functional, we have installations, however, we encounter some challenges that may cause it to appear as if the application is not functioning correctly for sellers.
The entire source of the problems stems from the data sent in the Input function, specifically the PaymentCustomizationPaymentMethod field. Sample data sent in this API:
"paymentMethods": [
{
"id": "gid://shopify/PaymentCustomizationPaymentMethod/0",
"name": "(for testing) Bogus Gateway"
},
{
"id": "gid://shopify/PaymentCustomizationPaymentMethod/1",
"name": "PayPal Express Checkout"
},
{
"id": "gid://shopify/PaymentCustomizationPaymentMethod/2",
"name": "Deferred"
},
{
"id": "gid://shopify/PaymentCustomizationPaymentMethod/3",
"name": "Cash on Delivery (COD)"
}
]
And a preview in the checkout looks like what’s shown on the screen.
It can be seen that what we receive in our function is different from what we see in the checkout. This generates a whole host of problems for customers. In the client’s intention, they have no idea what is being sent to us in the background, so they simply copy the name from the checkout and use it:
- They see Credit card, but in reality, it is (for testing) Bogus Gateway.
- They see PayPal , but in reality, it is PayPal Express Checkout.
- Deferred appears out of nowhere, and it is unclear what it is.
Manually added payment methods such as Cash on Delivery (COD) work correctly.
Example scenarios where a customer configures rules:
- The customer wants to hide Credit card for specific conditions. They enter such a value in the application’s configuration, and it doesn’t work. From the script’s perspective, there is no payment named Credit card.
- The customer wants to alphabetically sort payment methods and is unable to achieve it.
- The customer wants to move a selected shipping method to a specific position (e.g., they want to move Credit card to the last position).
In the case of PayPal, you can use a mechanism to check if the phrase contains a string, but in the context of Credit card, this would not work.
