I’ve tried @ChrisF2132 's method and can confirm it is no longer working as of now (27 Jan 2023). I am not comfortable with using my own credit card like @devsmk suggested. I finally figured out a way:
- Check out a subscription product using a Stripe test card, remember what type of card you are using for this checkout, ie. is it a Mastercard or Visa or Amex, etc.
- Then go onto Stripe Admin → Settings (bottom left) → Payments → disable the type of card you used earlier → Save.
- Configure a something to listen to the Webhook of type SUBSCRIPTION_BILLING_ATTEMPTS_FAILURE
- Then trigger a billingAttempt from your app, you should see a Failed billing attempt comes through. I used Google pub/sub, my webhook payload look like below:
{
“id”: 454765668,
“admin_graphql_api_id”: “gid://shopify/SubscriptionBillingAttempt/111823452346”,
“idempotency_key”: “whatever-unique-key”,
“order_id”: null,
“admin_graphql_api_order_id”: null,
“subscription_contract_id”:2353425623,
“admin_graphql_api_subscription_contract_id”: “gid://shopify/SubscriptionContract/2353425623”,
“ready”: true,
“error_message”: “Credit card brand is not accepted for payment”,
“error_code”: “unexpected_error”
}
This is a full list of error codes for a billingAttempt https://shopify.dev/api/admin-graphql/2023-01/enums/subscriptionbillingattempterrorcode , maybe you can simulate more scenarios such as Invalid Address, PAYMENT_METHOD_INCOMPATIBLE_WITH_GATEWAY_CONFIG, etc.
I hope that helps.