Hi Martin,
failure_code and failure_message on the charge object mirror the
values that we returned in our original response to you when you
created the charge.
So, if when creating a charge you received a 402 response with contents:
{
'type': 'card_error',
'code': 'card_declined'
'message': 'Your card was declined.'
'charge': 'ch_foo'
}
Then, when fetching 'ch_foo' from the API, you would see
failure_code='card_decline' and failure_message='Your card was
declined.'.
Unfortunately, in the majority of cases we do not have more
interesting information to offer than simply "Your card was declined."
When a card is declined, in the majority of cases the card networks /
the customer's bank simply say "decline" without providing any further
color around what happened.
In general, code/failure_code will adhere to the published list of
codes at
https://stripe.com/docs/api#errors, and
message/failure_message will be a human-readable string suitable for
display to the end user.
"Further" is probably the wrong word to use there to describe what
we're getting at, because there isn't really a case where the
failure_message will provide strictly more information than the
failure_code, just a longer and more human-readable way of saying it.
For instance, when code is invalid_expiry_year, message will be "Your
card's expiration year is invalid.". No new information, just the
human-readable explanation of the code.
Hope this helps! Sorry for the confusing diction in the docs.
Cheers,
Jim