Checkout API + Stripe error: "You can not create a testmode source with a livemode token."

Solved

Checkout API + Stripe error: "You can not create a testmode source with a livemode token."

hdpe
Visitor
2 1 0

Hi,

 

Our sales channel app has recently passed review and I've been trying to put an order through on production to verify the Stripe integration.

 

This worked fine with our preproduction environments but I can't seem to get a payment to go through using non-test payments.

 

The POST to /checkouts/{checkoutId}/payments.json is returning normally but with the field:

 

 

 

{
  ...
  "payment_processing_error_message": "You can not create a testmode source with a livemode token."
}

 

 

 

I am struggling to understand what this means - as far as I can see, I am in Stripe 'livemode' everywhere, and I'm using real, non-test payment cards and have tried this with real, production Shopify stores. I can't see anywhere where we're attempting test transactions.

 

The "source" as I understand it is a pre-created Stripe Customer in livemode with a card tokenized correctly - I can see it as such in the Stripe UI. Then we generate a token from this and the shopify_payments_account_id, and this is passed as a stripe_vault_token to the Shopify create payments API, and that call generates this error.

 

Our workflow is pretty much as described in the Shopify sales channel Stripe integration docs at https://shopify.dev/apps/channels/complete-payment#complete-a-payment-using-stripe , with the note in step 2 implemented (pre-tokenization of the card, creation of Stripe customer and sending this customer ID to the Stripe create token endpoint).

 

* create a Stripe customer
* create a Shopify checkout with billing and shipping names and addresses, selected shipping rate following polling etc.
* create a Stripe payment intent with total and customer to give client secret
* use this client secret together with Stripe Elements card widget to tokenize user's card
* update Stripe customer with this card token as its source
* create a Stripe token from this customer and with the account as the shopify_payments_account_id for the merchant
* create a Shopify payment with this token as a stripe_vault_token, i.e.

 

POST /checkouts/{checkoutId}/payments.json

 

 

 

{
  amount: 'foo',
  unique_token: 'bar',
  payment_token: {
    payment_data: STRIPE_TOKEN,
    type: 'stripe_vault_token'
  },
  request_details: {
    ip_address: ...,
    accept_language: ...,
    user_agent: ...
  }
}

 

 

 

always returns successfully, but with

 

 

 

{
  ...
  "payment_processing_error_message": "You can not create a testmode source with a livemode token."
}

 

 

 

We are using API version 2022-01.

 

Any advice on what could be causing this error or how to resolve would be greatly appreciated!

Accepted Solution (1)

hdpe
Visitor
2 1 0

This is an accepted solution.

So the answer turned out to be simply that the "real, production Shopify stores" I was testing this with all actually had Shopify Payments enabled in test mode.

View solution in original post

Reply 1 (1)

hdpe
Visitor
2 1 0

This is an accepted solution.

So the answer turned out to be simply that the "real, production Shopify stores" I was testing this with all actually had Shopify Payments enabled in test mode.