Reputation: 823
I want to update a customer with a declined card for testing purposes.
But if I do:
Stripe.customers.update(stripeCustomer.id, {
source: 'tok_chargeDeclined', // Token provided by stripe of a declined card
});
I get an exception:
Exception while invoking method 'stripe.test' { Error: Your card was declined.
What I am missing?
Upvotes: 0
Views: 346
Reputation: 7198
When you attach a card to a customer(for example with that update call), Stripe makes a temporary $0 charge against the card, to validate it and ensure you can charge the customer successfully later. This is mentioned at https://stripe.com/docs/saving-cards#saving-credit-card-details-for-later.
When you attach tok_chargeDeclined
, this charge is declined and the card is not added to the customer. To test the case where a card can be successfully added to a customer, but declined later(i.e. if it later expires or has no funds), you can use the tok_chargeCustomerFail
card from https://stripe.com/docs/testing#cards-responses
Upvotes: 1