ошибка синтаксического анализа xml activemerchant CyberSource

Я не могу заставить CyberSource работать с activemerchant. Activemerchant отлично работает с авторизацией.net и PayPal. Я пытаюсь протестировать его с консоли, так как он не работает на сайте.

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=>"[email protected]")

Это ошибка, которую я возвращаю:

#<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>

Любой совет здесь будет оценен!!!

Спасибо,

Роб.

------- вот поддельная копия информации ------

credit_card = ActiveMerchant::Billing::CreditCard.new(  
  :type               => "visa",  
  :number             => "4111111111111111",  
  :verification_value => "123",  
  :month              => 1,  
  :year               => 2020,  
  :first_name         => "First",  
  :last_name          => "Last"  
)

Также вот сгенерированный XML: (отредактирована личная информация)

<?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>[email protected]</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 (с правильным идентификатором продавца и т. д.) и использую curl для его обработки через производственный шлюз, я получу следующее:

Roberts-MacBook-Air:documents rlittle$ curl --header "тип контента: application/soap+xml" --data @testxml2.xml https://ics2ws.ic3.com/commerce/1.x/transactionProcessor

<?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>

Так что это должна быть проблема синтаксического анализа xml в драгоценном камне???


person Rob Little    schedule 10.07.2013    source источник
comment
Я также сталкиваюсь с подобной проблемой. Я не понимаю, почему CYbersource отправляет 500 вместо чего-то более значимого. Можете ли вы опубликовать код, который вы используете для создания кредитной карты.? Это может помочь в некоторой отладке.   -  person Nerve    schedule 11.07.2013
comment
Кроме того, в поле пароля вам нужно использовать ключ транзакции.   -  person Nerve    schedule 11.07.2013
comment
Да, я использую ключ транзакции, а также идентификатор продавца Cyberspace, спасибо.   -  person Rob Little    schedule 12.07.2013


Ответы (2)


Я точно не знаю, в чем проблема, но я расскажу вам, как я наконец заставил ее работать.

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: "[email protected]")

Помните: логин — это НЕ имя пользователя, а идентификатор продавца Cyberspace.

person Nerve    schedule 11.07.2013
comment
Да, я знаю об идентификаторе продавца в киберпространстве. Моя проблема, похоже, заключается в разборе. Все еще не работает для меня. - person Rob Little; 12.07.2013

Спасибо за помощь.

Я связался с Cybersource (они были очень полезны).

Сегодня вечером он только начал работать, так что я думаю, они что-то починили со своей стороны.

person Rob Little    schedule 12.07.2013