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

要するに、ラッシュは便利に作られています。:)

于 2012-09-24T12:03:27.293 に答える