Re: Help using customerPaymentMethodRemoteCreditCardCreate

Help using customerPaymentMethodRemoteCreditCardCreate

KTNinja
Shopify Partner
19 1 2

Hey,

I'm following these steps: https://shopify.dev/tutorials/migrate-existing-subscription-contracts-to-shopify

When I execute the mutation giving the (Shopify) CustomerId, stripeCustomerId and stripePaymentMethodId, I get back a PaymentMethod object so I thought it worked. But when I try to query the same customer for their paymentMethods, I don't get any Payment Methods back

Any help on this will be great, thanks!

Replies 15 (15)

KTNinja
Shopify Partner
19 1 2

Update: I changed up my mutation and now I'm getting an internal error, this is the mutation and the Request ID:

Mutation:

mutation customerPaymentMethodRemoteCreditCardCreate($customerId: ID!, $stripeCustomerId: String!, $stripePaymentMethodId: String) {
    customerPaymentMethodRemoteCreditCardCreate(
        customerId: $customerId,
        stripeCustomerId: $stripeCustomerId,
        stripePaymentMethodId: $stripePaymentMethodId
    ) {
        customerPaymentMethod {
            id
            instrument {
                ... on CustomerCreditCard {
                    billingAddress {
                        address1
                        city
                        country
                        countryCode
                        province
                        provinceCode
                        zip
                    }
                    brand
                    expiresSoon
                    expiryMonth
                    expiryYear
                    firstDigits
                    isRevocable
                    lastDigits
                    maskedNumber
                    name
                }
            }
        }
        userErrors {
            code
            field
            message
        }
    }
}

 

 

Request ID: 8949ed40-6b4b-45bc-9f51-f02428f0c1bc (include this in support requests)

KTNinja
Shopify Partner
19 1 2

For context in the above update, the mutation was executed on a development store using Shopify Payments in test mode and used Stripe's test mode customer source (which referenced a test card from Stripe).

 

Update 2:

I changed the mutation to match the one from the link above:

Mutation:

mutation customerPaymentMethodRemoteCreditCardCreate($customerId: ID!, $stripeCustomerId: String!, $stripePaymentMethodId: String) {
    customerPaymentMethodRemoteCreditCardCreate(
        customerId: $customerId,
        stripeCustomerId: $stripeCustomerId,
        stripePaymentMethodId: $stripePaymentMethodId
    ) {
        customerPaymentMethod {
            id
            instrument {
                ... on CustomerCreditCard {
                    brand
                    lastDigits
                }
            }
        }
        userErrors {
            code
            field
            message
        }
    }
}

 

This time I used a real card and was able to see the payment method on Shopify Admin, but when trying to query for the customer's payment methods, I get an internal error:

Query:

query getCustomerPaymentMethods($customerId: ID!) {
    customer(id: $customerId) {
        paymentMethods(first: 1) {
            edges {
                node {
                    id
                    instrument {
                        ... on CustomerPaymentInstrument {
                            ... on CustomerCreditCard {
                                billingAddress {
                                    address1
                                    city
                                    country
                                    countryCode
                                    province
                                    provinceCode
                                    zip
                                }
                                brand
                                expiresSoon
                                expiryMonth
                                expiryYear
                                firstDigits
                                isRevocable
                                lastDigits
                                maskedNumber
                                name
                            }
                        }
                    }
                    revokedAt
                }
            }
        }
    }
}

Request Id: a3f50964-7ee5-496f-86fd-28fabc8a955b

Poulping
Shopify Staff
29 4 4

Hello 

 

To learn more visit the Shopify Help Center or the Community Blog.

KTNinja
Shopify Partner
19 1 2

Hey @Poulping,

Thanks for the quick response!

I tried again in a production environment and turning off test mode for Shopify Payments, and used a real credit card from Stripe (using its Stripe payment method id). I still get the same behaviour as before where I can see the card in Admin but get an internal error when trying to query the customer's payment methods.

Request ID: e4b1ba6c-bd0d-4946-853f-afeeca124566

jbourassa
Shopify Staff (Retired)
11 2 2

Hi KTNNinja,

Thanks for reporting the error. We're rolling out a fix and this should be fixed within a couple of minutes.

Best,

To learn more visit the Shopify Help Center or the Community Blog.

KTNinja
Shopify Partner
19 1 2

To update, tested it now and it's working!

Thanks @Poulping and @jbourassa for the help and looking into this!

jbourassa
Shopify Staff (Retired)
11 2 2

Hey selina10261,

I don't understand what your question is, please elaborate.

To learn more visit the Shopify Help Center or the Community Blog.

KTNinja
Shopify Partner
19 1 2

Hey @jbourassa,

To follow up on the fix, I'm running into a case where I have a card on Stripe with a Billing Address where city is misspelled and country is "USA" vs "US" for example. After executing the mutation, I get a Shopify payment method with a Billing Address with the same misspelled city, country: "USA", countryCode: "ZZ" (in this case, not sure if it varies), province: "NY" and provinceCode: None.

Another case where the billing address is spelled correctly and country is "US", I get a Billing Address for the Shopify Payment Method where (to match the above) country: "United States", countryCode: "US", province: "New York", and provinceCode: "NY".

Since Stripe passed these inputs, was wondering if this can be adjusted to catch these or if I would need to address these myself?

jbourassa
Shopify Staff (Retired)
11 2 2

Unfortunately, we don't support editing these details on the customer payment method through the API at the moment. One potential workaround is to fix these in Stripe, revoke the previous payment method, and re-import.

To learn more visit the Shopify Help Center or the Community Blog.

KTNinja
Shopify Partner
19 1 2

@jbourassa Ah I see, would this also explain why when I try to update the card through the link sent from admin's "send link to update card" (card is created from Stripe) and change/update the billing address, an error page pops up as a result after clicking the update/confirm button? It works when updating Shopify test cards

jbourassa
Shopify Staff (Retired)
11 2 2
Hey KTNinja, care to share the exact error you're getting? I'm not sure
that's actually related. If you can also include a request id, that would
be great. You can get the request id by looking at the `x-request-id`
response HTTP header from the browser's dev tool.

To learn more visit the Shopify Help Center or the Community Blog.

KTNinja
Shopify Partner
19 1 2

Hey @jbourassa, this is the `x-request-id`: 14eaa2f1-396b-4b1e-957b-654cbb1b2086

And for more context, this is what I see after clicking "update":

Screen Shot 2021-04-12 at 5.31.29 PM.png

jbourassa
Shopify Staff (Retired)
11 2 2
Thanks for all the details, I was able to investigate. We don't currently
support updating the address on an imported card, hence the error you are
seeing. That being said, it should not result in an error page. I added an
entry to our backlog to look into that, but unfortunately I don't have an
ETA.

To learn more visit the Shopify Help Center or the Community Blog.

KTNinja
Shopify Partner
19 1 2

Thanks @jbourassa for looking into this, helps a lot!

jbourassa
Shopify Staff (Retired)
11 2 2

@KTNinja this should have been fixed, address can now be updated through the update card flow.

Thanks again for reporting the issue.

To learn more visit the Shopify Help Center or the Community Blog.