首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >activemerchant cybersource xml解析错误

activemerchant cybersource xml解析错误
EN

Stack Overflow用户
提问于 2013-07-11 03:14:46
回答 2查看 1.6K关注 0票数 0

我不能让cybersource与activemerchant一起工作。Activemerchant在authorize.net和paypal上运行良好。我正在尝试从控制台测试它,因为它在网站上失败了。

代码语言:javascript
复制
gateway = ActiveMerchant::Billing::CyberSourceGateway.new(   
      :login => "CybersourceUserID",
      :password => "CybersourceKey",
      :nexus => "NJ",
      :vat_reg_number =>""
    )


response = gateway.authorize(1000, credit_card, :ip => "127.0.0.1", :order_id=>"23434", :email=>"little@mac.com")

这是我要返回的错误:

代码语言:javascript
复制
#<Net::HTTPInternalServerError:0x1113f0838>
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
   <soap:Body>
     <soap:Fault xmlns:wsse="http://schemas.xmlsoap.org/ws/2002/04/secext" xmlns:c="urn:schemas-cybersource-com:transaction-data-1.0">
       <faultcode>soap:Client</faultcode>
       <faultstring>
          XML parse error.
          PI with the name 'xml' can occur only in the beginning of the document.
        </faultstring>
     </soap:Fault>
    </soap:Body>
</soap:Envelope>

这里的任何建议都将不胜感激!

谢谢,

罗伯。

-这里是假抄送信息

代码语言:javascript
复制
credit_card = ActiveMerchant::Billing::CreditCard.new(  
  :type               => "visa",  
  :number             => "4111111111111111",  
  :verification_value => "123",  
  :month              => 1,  
  :year               => 2020,  
  :first_name         => "First",  
  :last_name          => "Last"  
)

下面是生成的XML:(编辑掉了私有信息)

代码语言:javascript
复制
<?xml version="1.0" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
  <s:Header>
    <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" s:mustUnderstand="1">
      <wsse:UsernameToken>
        <wsse:Username>CybersourceUserID</wsse:Username>
        <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">CybersourceKey</wsse:Password>
      </wsse:UsernameToken>
    </wsse:Security>
  </s:Header>
  <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <requestMessage xmlns="urn:schemas-cybersource-com:transaction-data-1.69">
      <merchantID>CybersourceUserID</merchantID>
      <merchantReferenceCode>23434</merchantReferenceCode>
      <clientLibrary>Ruby Active Merchant</clientLibrary>
      <clientLibraryVersion>1.34.1</clientLibraryVersion>
      <clientEnvironment>i686-darwin12.2.0</clientEnvironment>
<billTo>
  <firstName>First</firstName>
  <lastName>Last</lastName>
  <street1></street1>
  <city></city>
  <state></state>
  <postalCode></postalCode>
  <country></country>
  <email>little@mac.com</email>
</billTo>
<purchaseTotals>
  <currency>USD</currency>
  <grandTotalAmount>10.00</grandTotalAmount>
</purchaseTotals>
<card>
  <accountNumber>4111111111111111</accountNumber>
  <expirationMonth>01</expirationMonth>
  <expirationYear>2020</expirationYear>
  <cvNumber>123</cvNumber>
  <cardType>001</cardType>
</card>
<ccAuthService run="true"/>
<businessRules>
</businessRules>
    </requestMessage>
  </s:Body>
</s:Envelope>

新信息:

有趣的是,如果我使用上面的XML (具有正确的商家ID等),并使用curl通过生产网关处理它,我会得到如下结果:

Roberts-MacBook-Air:文档rlittle$ curl --header "content-type: application/soap+xml“-- https://ics2ws.ic3.com/commerce/1.x/transactionProcessor @testxml2.xml

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8"?>
   <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
      <soap:Header>
         <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
            <wsu:Timestamp xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="Timestamp-1851182716">
               <wsu:Created>2013-07-12T03:32:05.030Z</wsu:Created>
            </wsu:Timestamp>
         </wsse:Security>
   </soap:Header>
   <soap:Body>
       <c:replyMessage xmlns:c="urn:schemas-cybersource-com:transaction-data-1.69">   
            <c:merchantReferenceCode>
              23434
            </c:merchantReferenceCode>
            <c:requestID>
                3735999249970176056695
            </c:requestID>
            <c:decision>
                 REJECT
            </c:decision>
            <c:reasonCode>
                 101
            </c:reasonCode>
            <c:missingField>
                c:billTo/c:country
           </c:missingField>
            <c:missingField>
                c:billTo/c:city
            </c:missingField>
            <c:missingField> 
                 c:billTo/c:street1
            </c:missingField>    
            <c:requestToken>
             (a token)
            </c:requestToken>
            <c:ccAuthReply>
               <c:reasonCode>
                  101
               </c:reasonCode>
            </c:ccAuthReply>
        </c:replyMessage>
    </soap:Body>
</soap:Envelope>

所以一定是gem中的xml解析问题?

EN

回答 2

Stack Overflow用户

发布于 2013-07-12 03:31:08

我不知道确切的问题是什么,但我会告诉你我是如何最终让它工作的。

代码语言:javascript
复制
ActiveMerchant::Billing::Base.mode = :test
ActiveMerchant::Billing::CyberSourceGateway::TEST_URL = 'https://ics2wstest.ic3.com/commerce/1.x/transactionProcessor'
gateway = ActiveMerchant::Billing::CyberSourceGateway.new(
  login: "<Cyber source Merchant ID>",
  password: '<Transaction key>',
  test: true,
  ignore_avs: true
)

credit_card = ActiveMerchant::Billing::CreditCard.new(
  :type               => "visa",
  :number             => "4111111111111111",
  :verification_value => "123",
  :month              => 1,
  :year               => Time.now.year+1,
  :first_name         => "Test",
  :last_name          => "Test1"
)
response = gateway.authorize(1000, credit_card, :ip => "127.0.0.1", order_id: "jdgjsahgd", email: "test.test@test.com")

记住:登录不是用户名,而是网络空间商家的id。

票数 0
EN

Stack Overflow用户

发布于 2013-07-12 12:26:04

谢谢你的帮助。

我联系了cybersource (他们非常有帮助)。

今晚它才刚刚开始工作,所以我猜他们在这一端修复了一些东西。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/17579103

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档