我正在使用 braintree 进行支付处理,我正在尝试获取 Processor Response Codes来自 Braintree 和 Ruby。
这是我的代码:
verification = result.credit_card_verification
response_code = verification.try(:processor_response_code)
即使有错误,我也得到验证为 nil。
还有其他方法可以获取处理器响应代码吗?
我从 here 得到了这段代码
这是我的 result.erros :
: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: {}
最佳答案
我在布伦特里工作。如果您需要比 Stack Overflow 上更多的帮助,请联系 our support team。 .
处理 Braintree result objects是进步的。
如果 result.success?
为 false
,则检查 result.errors
,它表示 validation errors .
如果result.errors
为nil
,则请求有效。在这种情况下,您将拥有一个 transaction
或 verification
对象,就像 result.success?
是 true
一样。
然后您可以查看result.verification
的status
、processor_response_code
、gateway_rejection_reason
等。
链接的文档提供了有关处理错误结果的更多详细信息。
关于ruby-on-rails - result.credit_card_verification 即使在 braintree 出错时也返回 nil,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19413961/