There doesn't seem to be a way to test a failed transaction.

eat_to_evolve
Excursionist
18 0 7

If we are using Shopify Payments in test mode, it doesn't allow you to put in an invalid credit card number from https://help.shopify.com/en/manual/payments/shopify-payments/testing-shopify-payments#simulate-faile.... When you try to checkout, it fails. If you try to update your payment method to one of those, it just says 'Failed to update payment method'.  So this means the payment method on a subscription is always valid in test mode, since we can't add non valid ones.

any ideas?

Replies 6 (6)
simplee_chris
Shopify Partner
39 2 6

I agree, this is very important to test our failed credit card flows. Would revoking a customer's payment method lead to a failed billing attempt?

There needs to be a way to add an invalid credit card number or to invalidate a credit card using test mode.

matart
Shopify Staff
Shopify Staff
13 1 3

Hey eat_to_evolve!

Currently there isn't a way to test a card that succeeds initially and then fails for the reasons that you mentioned. The best way right now is to look at the error code[1] that will be returned when a billing attempt fails.

 

References:

1. https://shopify.dev/docs/admin-api/graphql/reference/orders/subscriptionbillingattempterrorcode

matart
Shopify Staff
Shopify Staff
13 1 3

Hey  chris_mctavish!

 

I believe revoking a customer payment method will give you an error code but it won't be the same as if a card was declined, or another error. 

 

Here is a current list of error codes that can be returned: https://shopify.dev/docs/admin-api/graphql/reference/orders/subscriptionbillingattempterrorcode 

eat_to_evolve
Excursionist
18 0 7

Hey @matart , I understand we can look at the error code, but the issue is I cannot actually make sure a transaction fails so I can test my flow properly with retries. Is there any plans to allow us to enter invalid card numbers?

matart
Shopify Staff
Shopify Staff
13 1 3

Hey @eat_to_evolve!

I wish I had better news, this issue is on our radar but there currently isn't a timeline for implementing it.

ChrisF2132
Shopify Partner
1 0 0

I ended up finding a way to make this work by checking out a subscription with the normal test card, and then using the sendCustomerPaymentMethodUpdateEmail mutation to receive and email to update my card.

 

I then updated the customer's payment method to Stripe's "Decline after attaching" card:

4000 0000 0000 0341

(https://stripe.com/docs/testing#declined-payments)

And then tried to create a billing attempt. It then fired the "billingAttemptFailed" webhook and I was able to test my flow.

I also tried getting the update payment url and revoking the payment method via mutations both threw me respective errors:

Payment method instrument not supported for this mutation
Failed to delete customer payment method due to presence of valid subscription.