【发布时间】:2013-10-25 04:33:29
【问题描述】:
我正在使用 Braintree 进行支付处理,并且我正在尝试使用 Ruby 从 Braintree 获取 Processor Response Codes。
这是我的代码:
verification = result.credit_card_verification
response_code = verification.try(:processor_response_code)
即使出现错误,我的验证也为零。
还有其他东西可以获取处理器响应代码吗?
我从here得到这个代码
这是我的结果。错误:
:errors: !ruby/object:Braintree::Errors
errors: !ruby/object:Braintree::ValidationErrorCollection
errors: []
nested:
:customer: !ruby/object:Braintree::ValidationErrorCollection
errors: []
nested:
:credit_card: !ruby/object:Braintree::ValidationErrorCollection
errors:
- !ruby/object:Braintree::ValidationError
code: '81707'
attribute: cvv
message: CVV must be 4 digits for American Express and 3 digits for
other card types.
- !ruby/object:Braintree::ValidationError
code: '81713'
attribute: expiration_year
message: Expiration year is invalid.
- !ruby/object:Braintree::ValidationError
code: '81703'
attribute: number
message: Credit card type is not accepted by this merchant account.
- !ruby/object:Braintree::ValidationError
code: '81715'
attribute: number
message: Credit card number is invalid.
nested:
:billing_address: !ruby/object:Braintree::ValidationErrorCollection
errors: []
nested: {}
【问题讨论】:
-
我在布伦特里工作。如果您有验证错误,则不会进行验证。
result.errors长什么样子? -
@agf 我已经更新了我的问题。实际上,我想处理所有错误并根据处理器响应代码中列出的错误类型显示一些通用消息。顺便说一句,是否必须先显示此验证错误,然后再管理处理器响应代码?(或者您可以说最佳实践)
标签: ruby-on-rails ruby ruby-on-rails-3 payment-processing braintree