There’s currently no way to find out what each payment method name
and id
will be returned by Shopify functions during checkout, unless you have a store with an activated payment provider in the target country, which is impossible if you work with multiple countries.
For example we have a user that wants to run a function if the payment method “credit card” is activated, we have to guess which one of the 100+ payment providers in Shopify he’s using.
If you try to match “credit card” or the translation “tarjeta de crédito” , it won’t match the name returned by Shopify, which can be anything from “Shopify payments” to “Mercado Pago Checkout Pro” or event “Checkout .com”
I’ve tried using this query in Shopify admin (this query is not even available to apps), but it seems it returns something different for every store based on region or other conditions:
fetch(`/api/shopify/${window.location.pathname.split("/")[2]}`, {
method: "POST",
credentials: "include",
headers: {
Accept: "application/json",
"content-type": "application/json",
"x-csrf-token": "REDACTED",
},
body: '{"operationName":"AdditionalPaymentProvidersUplift","variables":{},"query":"query AdditionalPaymentProvidersUplift {\\n paymentProviders(first: 250, ) {\\n edges {\\n node {\\n id\\n name\\n url\\n applicationUrl\\n apiClientId\\n countries\\n transactionFee\\n deprecationStatusV2\\n preferred\\n paymentMethods {\\n name\\n type\\n __typename\\n }\\n configuration {\\n id\\n enabled\\n __typename\\n }\\n __typename\\n }\\n __typename\\n }\\n __typename\\n }\\n}\\n"}',
});
It’s also not clear if the returned data matches the checkout names, for example if the user wants to match the payment provider “Mercado Pago” for credit cards, there seems to be 3 payment methods that could possible match it from this query in Brazil:
-
Mercado Pago Cartões
-
Mercado Pago Checkout Pro
-
Mercado Pago Pix
However only two of them actually have credit cards, and I’m not even sure if they will be named “Cartão de crédito” or “Mercado Pago” or “Mercado Pago Pro”
We thought also about just logging the input to get the payment names, but you can’t have access to logs unless the merchant shares it, and throwing errors makes the function slower and provides a bad experience.