Updating the payment method of a subscription contract

Hello.

We have a custom-made shopify app that is integrated into our store.

Our custom app, allows customers to enter their new credit card details, from which we create a payment method on stripe and then attempt to associate that stripe payment method to the shopify subscription contract. We have some customers that haven’t been able to switch their payment method because of the error “Payment method token is invalid”, and we’re unsure what is happening.

I’ll try to summarize everything we’re doing up until that error is caught:

  1. A customer interacts with our store, and performs a checkout, buying product(s) that require recurring payments. By this point, we are still using the shopify payments connector, so everything works fine here.
  2. The customer now wishes to update their payment method. For example, the old credit card has expired / has no funds, so they need to update. They interact with our custom app, where they have a form where they can enter the new card details (number, CCV, etc).
  3. When this happens, our custom app does the following:
    3.1. Create a new token on stripe using the stripe js library (Stripe JS Reference)
    3.2. Create a new customer on stripe (Create a customer | Stripe API Reference)
    3.3. Create a new payment method on shopify using the graphql API customerPaymentMethodRemoteCreate. The input payload is:
{
  "customerId": <shopify customer id>,
  "remoteReference": {
      "stripePaymentMethod": {
         "customerId": <customer id from stripe that was created on step 3.2>,
         "paymentMethodId": <card id that was created on step 3.1>
       }
   }
}

3.4. Associate the payment method to the shopify subscription contract with the graphql API subscriptionDraftUpdate. The input payload for this one is:

{
  paymentMethodId: <shopify payment method id from step 3.3>
}

For some customers, step 3.4 is throwing the error “Payment method token is invalid”.

I’ve already reached out to stripe support which told that our store is using the “Legacy connector” with stripe, but I’m not really sure what this means.

What can we do here?


Also, is this the correct way to update payment methods on a subscription contract to a shopify payment?

I see that shopify also has the mutation customerPaymentMethodCreditCardCreate, but I have no idea how do we get the param “sessionId”, nor what does it represent.

Any help here would be seriously appreciated.

I would ignore Stripe on the legacy connector piece. Stripe sent out an email to all Shopify merchants a month ago saying that they needed to upgrade their connector from the legacy one but that completely broke ShopifyPayments for subscription customers. They later sent out a retraction to merchants using subscriptions. I would contact Shopify and be really sure before you do that.

I believe Shopify is planning on getting rid of the customerPaymentMethodCreditCardCreate so I wouldn’t spend much time on that either. I believe the docs on creating a session have been removed.

The original way for a customer to update their payment method is to send the update link from Shopify: customerPaymentMethodSendUpdateEmail - GraphQL Admin

Hello @Brian_Singer

Appreciate the response!

Our subscriptions are all managed on shopify (using the subscriptionContract APIs), we don’t use stripe subscriptions. We only use stripe to create new payment methods.

When customers initially checkout on our store, the payment gateway is always the shopify payment gateway. If customers want to change their payment method later, we use stripe to create that new payment method and then attempt to connect that stripe payment method to the subscription.

As mentioned, this works in some cases and doesn’t in others (with the error mentioned above).