即使在braintree中出错,result.credit_card_verification仍返回nil

时间:2013-10-16 21:10:30

标签: ruby-on-rails ruby ruby-on-rails-3 payment-processing braintree

我正在使用braintree进行付款处理,而我正试图通过Ruby从Braintree获取Processor Response Codes

这是我的代码:

 verification = result.credit_card_verification
 response_code = verification.try(:processor_response_code)

即使出现错误,我的验证也是零。

还有其他东西可以获得处理器响应代码吗?

我从here

获得了此代码

这是我的结果.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: {}

1 个答案:

答案 0 :(得分:4)

我在Braintree工作。如果您需要更多帮助,请访问Stack Overflow,请联系our support team

处理Braintree result objects是渐进式的。

如果result.success?false,那么请检查代表validation errorsresult.errors

如果result.errorsnil,则请求有效。在这种情况下,您将拥有transactionverification对象,就像result.success?true一样。

然后,您可以查看result.verification的{​​{1}},statusprocessor_response_code等。

链接文档提供了有关处理错误结果的更多详细信息。