How do I show the card decline messages using Braintree in rails application

338 Views Asked by At

I am using the Braintree for transaction in my rails application but i am not able to show the decline message like: 2004: Expired Card 2012: Processor Declined - Possible Lost Card 2013: Processor Declined - Possible Stolen Card 2014: Processor Declined - Fraud Suspected 2010: Card Issuer Declined CVV
where i specify this in my application.

1

There are 1 best solutions below

0
On

I work as a developer at Braintree. The processor response codes can be accessed directly on the transaction object.

result = Braintree::Transaction.sale(
  :amount => '100.00',
  :payment_method_nonce => 'nonce-from-the-client',
  :options => {
    :submit_for_settlement => true
  }
)

puts result.transaction.processor_response_code

Note that if the transaction fails before getting to the processor (e.g. if the error is "gateway rejected"), the transaction object will not contain a processor response code.

Also, we recommend for security reasons that merchants do not expose the specific decline reason to the customer.