Help using customerPaymentMethodRemoteCreditCardCreate

KTNinja
Tourist
16 0 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!

0 Likes
KTNinja
Tourist
16 0 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)

0 Likes
KTNinja
Tourist
16 0 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

0 Likes
Poulping
Shopify Staff
Shopify Staff
2 0 2

Hello 

 

KTNinja
Tourist
16 0 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

0 Likes
jbourassa
Shopify Staff
Shopify Staff
6 0 1

Hi KTNNinja,

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

Best,

KTNinja
Tourist
16 0 2

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

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

selina10261
Tourist
24 0 2

selina10261_0-1617956462520.png

???

0 Likes
jbourassa
Shopify Staff
Shopify Staff
6 0 1

Hey selina10261,

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

0 Likes
KTNinja
Tourist
16 0 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?

0 Likes