Personalized checkout and custom promotions with Shopify Scripts
There is bug in Shopify script editor for Payments script.
I wanted to change name of payment gateway. My script is working correctly for 1st payment gateway name, BUT.. I want to change name of 3rd gateway. It is not working.
Below is actual order of payment gateway :
CHANGE_GATEWAYS_NAME = [
{
gateway_match_type: :exact,
gateway_names: ["Merchant Warrior Card Payments"],
newname: "Secure Card Payments"
},
]
# ================================ Script Code (do not edit) ================================
# ================================================================
# GatewayNameSelector
#
# Finds whether the supplied gateway name matches any of the
# entered names.
# ================================================================
class GatewayNameSelector
def initialize(match_type, gateway_names)
@comparator = match_type == :exact ? '==' : 'include?'
@gateway_names = gateway_names.map { |name| name.downcase.strip }
end
def match?(payment_gateway)
@gateway_names.any? { |name| payment_gateway.name.downcase.strip.send(@comparator, name) }
end
end
# ================================================================
# ChangeNameGatewaysCampaign
# ================================================================
class ChangeNameGatewaysCampaign
def initialize(campaigns)
@campaigns = campaigns
end
def run(cart, payment_gateways)
@campaigns.each do |campaign|
gateway_name_selector = GatewayNameSelector.new(
campaign[:gateway_match_type],
campaign[:gateway_names],
)
payment_gateways.each do |payment_gateway|
if gateway_name_selector.match?(payment_gateway)
payment_gateway.change_name(campaign[:newname])
end
end
end
end
end
CAMPAIGNS = [
ChangeNameGatewaysCampaign.new(CHANGE_GATEWAYS_NAME),
]
CAMPAIGNS.each do |campaign|
campaign.run(Input.cart, Input.payment_gateways)
end
Output.payment_gateways = Input.payment_gateways
hi
I have the same problem, Plus Support told me the following:
If you have tried renaming the payment gateway and it revert back to its original name, then it is likely something potentially contractual with the payment gateway which is preventing the gateway from being renamed. And this is an expected behaviour which Shopify does not have control over. If you'd like to clarify this, you may reach out to the payment gateway provider to see if they can confirm that for you.
Thank you @m8th . Yes I got similar answer from support.
I posted this question before receiving their reply.
Problem was that, SAME code was working for SAME gateway before that day. Never mind.
I believe, Shopify should have mention this kind of behavior/conditional things on their help page.
On this page https://help.shopify.com/en/manual/checkout-settings/script-editor/examples/payment-gateway-scripts they say it's possible.
Hi,
As per the same exploration on our side, this might be connected to some restrictions for the new integration type - via the new Payment API. Same sample script isn't working with our payment application as well.
Hope this helps a bit to clarify.
Thanks and regards,
Nikita
Hello Sanket, have you found a solution to this problem? If so, can you share?
@MarianaZ No. there is no solution.
I used JavaScript and did that after page load. Not a good or suggestion but..my client wanted anyhow and it does not have any side effects. So I did.
Hey Community! As we jump into 2025, we want to give a big shout-out to all of you wh...
By JasonH Jan 7, 2025Hey Community! As the holiday season unfolds, we want to extend heartfelt thanks to a...
By JasonH Dec 6, 2024Dropshipping, a high-growth, $226 billion-dollar industry, remains a highly dynamic bus...
By JasonH Nov 27, 2024