0

logger.info response.inspect

我得到:

#<ActiveMerchant::Billing::AdaptivePaymentResponse:0x0000000599dc48 @json="{\"responseEnvelope\":{\"timestamp\":\"2012-09-24T04:34:36.888-07:00\",\"ack\":\"Failure\",\"correlationId\":\"22d02b45ed143\",\"build\":\"3692562\"},\"error\":[{\"errorId\":\"540031\",\"domain\":\"PLATFORM\",\"subdomain\":\"Application\",\"severity\":\"Error\",\"category\":\"Application\",\"message\":\"You do not have permission to issue this refund\"}]}", @response=#<Hashie::Rash error=[#<Hashie::Rash category="Application" domain="PLATFORM" error_id="540031" message="You do not have permission to issue this refund" severity="Error" subdomain="Application">] response_envelope=#<Hashie::Rash ack="Failure" build="3692562" correlation_id="22d02b45ed143" timestamp="2012-09-24T04:34:36.888-07:00">>, @xml_request="<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<RefundRequest>\n  <requestEnvelope>\n    <detailLevel>ReturnAll</detailLevel>\n    <errorLanguage>en_US</errorLanguage>\n  </requestEnvelope>\n  <actionType>REFUND</actionType>\n  <payKey>AP-2JV97573KK140871P</payKey>\n  <currencyCode>USD</currencyCode>\n  <feesPayer>EACHRECEIVER</feesPayer>\n</RefundRequest>\n", @request={"RefundRequest"=>{"requestEnvelope"=>{"detailLevel"=>"ReturnAll", "errorLanguage"=>"en_US"}, "actionType"=>"REFUND", "payKey"=>"AP-2JV97573KK140871P", "currencyCode"=>"USD", "feesPayer"=>"EACHRECEIVER"}}, @action="Refund">

response.ack我得到"Failure"

如果我写logger.info response.error.inspect,我会得到:

[#<Hashie::Rash category="Application" domain="PLATFORM" error_id="540031" message="You do not have permission to issue this refund" severity="Error" subdomain="Application">]

例如,我如何访问或获得error_id价值?

谢谢!

4

2 回答 2

1

作为response.error一个数组,您必须对其进行迭代循环或简单地执行以下操作

response.error[0].error_id
于 2012-09-24T12:18:27.847 回答
0

只需通过以下代码:

response.error.error_id

作为参考,请看这里:github 上的 rash

简而言之,Rash 是为了方便而设计的。:)

于 2012-09-24T12:03:27.293 回答