2015-11-03 56 views
3

我一直在使用Authorize.NET的GetCustomerProfile多年,今天突然響應未返回付款資料。它只是返回一組配置文件,但所有重要的字段(如payment)都爲空。Authorize.NET GetCustomerProfile不返回數據

(這是他們的CIM特徵,其中一個「模糊」的付款資料傳回並應該像XXXX1234的一部分)

我使用Visual Studio中生成的代理網址https://api.authorize.net/soap/v1/Service.asmx?WSDL(生成一個參考.cs文件)

+0

你在沙箱裏試過了嗎?它會給你同樣的結果嗎? –

+0

其實是的,它的確如此 - 我想出了這個問題,我即將作出迴應 - 希望它可以幫助其他人(並希望他們不會像這樣再次破壞它)...... –

回答

1

你好,西蒙! 它看起來像Authorize.NET更新他們的服務與新領域,但忘了將它們添加到WSDL。

這是我送的示例請求(截獲使用Fiddler):

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> 
    <s:Header> 
     <VsDebuggerCausalityData xmlns="http://schemas.microsoft.com/vstudio/diagnostics/servicemodelsink">uIDPo3vYq2eC/5VIuiUcm2hEtw8AABBBJr/dLQF7z02Y7UKwphq24W1n9j0XlQ1MiAlOjy5fO14ACQAA</VsDebuggerCausalityData> 
    </s:Header> 
    <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 
     <GetCustomerProfile xmlns="https://api.authorize.net/soap/v1/"> 
      <merchantAuthentication> 
       <name>95U6bwXXXXX</name> 
       <transactionKey>8tf62gV7XXXXXX</transactionKey> 
      </merchantAuthentication> 
      <customerProfileId>37745529</customerProfileId> 
     </GetCustomerProfile> 
    </s:Body> 
</s:Envelope> 

這是響應:這裏

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 
    <soap:Body> 
     <GetCustomerProfileResponse xmlns="https://api.authorize.net/soap/v1/"> 
      <GetCustomerProfileResult> 
       <resultCode>Ok</resultCode> 
       <messages> 
        <MessagesTypeMessage> 
         <code>I00001</code> 
         <text>Successful.</text> 
        </MessagesTypeMessage> 
       </messages> 
       <profile> 
        <merchantCustomerId>33938</merchantCustomerId> 
        <email>[email protected]</email> 
        <customerProfileId>37745529</customerProfileId> 
        <paymentProfiles> 
         <CustomerPaymentProfileMaskedType> 
          <billTo> 
           <firstName>TEST</firstName> 
           <lastName>USER</lastName> 
           <company>Defender Razor</company> 
           <address>1 RODEO DRIVE</address> 
           <city>BEVERLY HILLS</city> 
           <state>CA</state> 
           <zip>90210</zip> 
           <country>UNITED STATES</country> 
          </billTo> 
          <customerProfileId>0</customerProfileId> 
          <customerPaymentProfileId>34313485</customerPaymentProfileId> 
          <payment> 
           <creditCard> 
            <cardNumber>XXXX5108</cardNumber> 
            <expirationDate>XXXX</expirationDate> 
           </creditCard> 
          </payment> 
         </CustomerPaymentProfileMaskedType> 
        </paymentProfiles> 
       </profile> 
      </GetCustomerProfileResult> 
     </GetCustomerProfileResponse> 
    </soap:Body> 
</soap:Envelope> 

一切是正確的 - 因爲你可以看到payment節點正確發送。

然而 - 與.NET反序列化屬性事項的順序 - 爲所生成的References.cs文件中指定。

[System.Xml.Serialization.XmlElementAttribute(Order=0)] 

事實證明,兩個新字段添加到響應billTocustomerProfileId,但他們並沒有加入到WSDL。

所以,當試圖反序列化領域billTo被發現,但不是什麼預期 - 所以一切都結束了空。

如果加上這兩行(並謹慎地補充他們的正是這種類型),那麼你可以重新生成references.cs文件(通過在服務引用右擊並重新生成文件)。

如果您是通過網址https://api.authorize.net/soap/v1/Service.asmx?WSDL生成代理,那麼您需要在本地下載此文件作爲Service.wsdl並從那裏生成代理。

<s:element minOccurs="1" maxOccurs="1" name="billTo" type="tns:CustomerAddressType"/> 
    <s:element minOccurs="1" maxOccurs="1" name="customerProfileId" type="s:long" /> 

<s:complexType name="CustomerPaymentProfileMaskedType"> 
    <s:complexContent mixed="false"> 
     <s:extension base="tns:CustomerPaymentProfileBaseType"> 
     <s:sequence> 
      <s:element minOccurs="1" maxOccurs="1" name="billTo" type="tns:CustomerAddressType"/> 
      <s:element minOccurs="1" maxOccurs="1" name="customerProfileId" type="s:long" /> 
      <s:element minOccurs="1" maxOccurs="1" name="customerPaymentProfileId" type="s:long" /> 
      <s:element minOccurs="0" maxOccurs="1" name="payment" type="tns:PaymentMaskedType" /> 
      <s:element minOccurs="0" maxOccurs="1" name="driversLicense" type="tns:DriversLicenseMaskedType" /> 
      <s:element minOccurs="0" maxOccurs="1" name="taxId" type="s:string" /> 
     </s:sequence> 
     </s:extension> 
    </s:complexContent> 
    </s:complexType> 

在檢測到之前,我損失了12個小時的付款。幸運的是我有客戶的電子郵件,但這非常糟糕。您不能只將字段添加到訂單重要的響應中。甚至更糟糕的是,你不能忘記將它們添加到WSDL中。

這對我來說是速戰速決。我可能會轉而在某個時候使用適當的API--我已經向Authorize.net報告了這一點,希望他們也能做出迴應。

這是References.cs後,我做了我的變化的差異。正如你所看到的Order財產已經增加:

enter image description here

3

我不得不對CreateCustomerPaymentProfile SOAP調用一個類似的問題(通過.NET自動生成的代理)剛剛起步昨天,2015年11月3日,儘管我們已經成功連接了SOAP CIM多年。

我能夠通過在Visual Studio中執行「更新服務參考」來「修復」問題,以基於其最新的WSDL重新生成代理類。 WSDL發生了一些變化。

具體來說,在我的結尾,看起來好像響應沒有在customerPaymentProfileId成功創建後包含它們的值。事實上,他們實際上仍然在發送這個值,但是在XML響應中有一個新的字段,customerProfileId。正如Simon_Weaver在他的回答中所提到的那樣,由Visual Studio生成的代理類具有正確反序列化所需的字段的明確排序。在已知字段上方添加以前的「未知」字段會導致它破壞我的代碼。

幸運的是,這個新的customerProfileId包含在他們最新的WSDL中,因此「更新服務參考」並重新編譯解決了我的問題。

我非常詳細地通知了我的問題的Authorize.net支持,並告訴他們他們需要在WSDL文檔的「序列」末尾包含任何新字段,以便不中斷客戶端並使用舊版本的WSDL。到目前爲止,我還沒有收到他們的回覆,但我會鼓勵任何遇到此問題的人,即使您已經制定了解決方案,也可以通過[email protected]向他們報告,以免意外再做一次。

+1

我確實聽到了授權。網絡支持今天,他們指出我這個論壇:https://community.developer.authorize.net/t5/Integration-and-Testing/CIM-WSDL-Breaking-Change-on-11-3/td-p/ 52828其他人在11/3報告完全相同的問題。現在我們中的許多人已經解決了這個問題,如果他們決定回滾更改,他們將再次破壞我們的界面! –

+0

絕對應該可以使用Update引用來修復它,但問題是他們的WSDL甚至不包含'CustomerPaymentProfileBaseType'下的字段'billTo',我甚至不知道這是可能的。所以我也必須添加它。 –

+0

他們回信給我說,'我們很抱歉給您造成的任何不便,儘管我可以建議這些更改將保持最新。「很明顯,它並沒有讓開發者接受 - 但他們必須有很多人解決這個問題 –