Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.fluveo.com/llms.txt

Use this file to discover all available pages before exploring further.

When a payment fails due to a card issue, the error response includes a decline_code field inside the payment_error type. Use this code to determine why a card was declined and display an appropriate message to your customer.

Decline error response

{
  "error": {
    "type": "payment_error",
    "code": "card_declined",
    "message": "Your card was declined.",
    "decline_code": "insufficient_funds",
    "param": null,
    "doc_url": "https://docs.leanrails.com/errors/decline-codes"
  }
}

Decline codes

CodeDescriptionSuggested Customer Message
generic_declineThe card was declined for an unspecified reason.Your card was declined. Please try a different payment method.
insufficient_fundsThe card has insufficient funds to complete the purchase.Your card has insufficient funds. Please try a different card.
lost_cardThe card has been reported lost.Your card was declined. Please contact your card issuer.
stolen_cardThe card has been reported stolen.Your card was declined. Please contact your card issuer.
expired_cardThe card has expired.Your card has expired. Please update your card details.
incorrect_cvcThe CVC number is incorrect.The CVC code is incorrect. Please check and try again.
processing_errorAn error occurred while processing the card.An error occurred processing your card. Please try again.
do_not_honorThe card issuer declined the transaction.Your card was declined. Please contact your card issuer.

Testing declines

Use the pm_card_declined payment method in test mode to simulate a card decline:
curl -X POST https://api.leanrails.com/v1/payment_intents \
  -u "sk_test_xxx:" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
    "amount": 2000,
    "currency": "usd",
    "payment_method": "pm_card_declined"
  }'

Handling declines

Check the decline_code field in the error response and map it to a customer-friendly message:
decline_codeSuggested message
insufficient_fundsYour card has insufficient funds.
expired_cardYour card has expired. Please update your card.
incorrect_cvcThe CVC code is incorrect. Please try again.
generic_declineYour card was declined. Please try another card.
do_not_honorYour card was declined. Please contact your card issuer.