我正在使用 Braintree 进行付款处理,并且我正在尝试获取处理器响应代码 https://www.braintreepayments.com/docs/ruby/reference/processor_responses来自 Braintree 和 Ruby。
这是我的代码:
verification = result.credit_card_verification
response_code = verification.try(:processor_response_code)
即使出现错误,我也得到验证为零。
还有其他方法可以获取处理器响应代码吗?
我从这里得到了这个代码here https://www.braintreepayments.com/docs/ruby/card_verifications/overview
这是我的 result.errors :
: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: {}
I work at Braintree. If you'd like more help than you can get here on Stack Overflow, please reach out to our support team https://support.braintreepayments.com/.
处理Braintree 结果对象 https://www.braintreepayments.com/docs/ruby/transactions/result_handling是进步的。
If result.success?
is false
,然后你检查result.errors
,这代表验证错误 https://www.braintreepayments.com/docs/ruby/general/validation_errors.
If result.errors
is nil
,则请求有效。在这种情况下,您将有一个transaction
or verification
对象就像result.success?
was true
.
然后您可以查看result.verification
's status
, processor_response_code
, gateway_rejection_reason
, etc.
链接的文档提供了有关处理错误结果的更多详细信息。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)