2012-12-11 35 views
2

我試圖使用Authorize.Net CIM API使用GetCustomerPaymentProfile檢索支付信息。特別是,我需要隱藏的信用卡號碼和信用卡類型或屏蔽檢查帳號。我已閱讀API文檔並遵循它,但沒有智能感知,所以我的項目無法編譯。如何使用Authorize.Net CIM獲取支付信息

var data = Service.GetCustomerPaymentProfile(MerchantAuthentication, profileId, customerPaymentProfileId); 

var creditCard = data.creditCard... (nothing here) 

使用C#,我該怎麼做?編輯: 看起來支付對象是一個動態。這是我最終使用的代碼。謝謝您的幫助!

 if (data.paymentProfile.payment.Item.GetType() == typeof(CreditCardMaskedType)) 
     { 
      var obj = (CreditCardMaskedType) data.paymentProfile.payment.Item; 
      retval.CreditCardNumber = obj.cardNumber; 
      retval.CreditCardType = obj.cardType; 
     } 

     if (data.paymentProfile.payment.Item.GetType() == typeof(BankAccountMaskedType)) 
     { 
      var obj = (BankAccountMaskedType)data.paymentProfile.payment.Item; 
      retval.BankAccountNumber = obj.accountNumber; 
      retval.BankRoutingNumber = obj.routingNumber; 
     } 
+0

可能你會顯示你的代碼和錯誤信息嗎? –

+0

添加代碼示例。 –

回答

2

我不知道C#,但如果它的語義跟隨其他語言中,這應該工作:

var creditCard = data.paymentProfile.payment.creditCard.cardNumber; 

下面是一個示例XML輸出,可以對您有所幫助:

<?xml version="1.0" encoding="utf-8"?> 
<getCustomerPaymentProfileResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd"> 
    <messages> 
    <resultCode>Ok</resultCode> 
    <message> 
     <code>I00001</code> 
     <text>Successful.</text> 
    </message> 
    </messages> 
    <paymentProfile> 
    <billTo> 
     <firstName>John</firstName> 
     <lastName>Smith</lastName> 
     <address>123 Main Street</address> 
     <city>Townsville</city> 
     <state>NJ</state> 
     <zip>12345</zip> 
     <phoneNumber>800-555-1234</phoneNumber> 
    </billTo> 
    <customerPaymentProfileId>4796541</customerPaymentProfileId> 
    <payment> 
     <creditCard> 
     <cardNumber>XXXX1111</cardNumber> 
     <expirationDate>XXXX</expirationDate> 
     </creditCard> 
    </payment> 
    </paymentProfile> 
</getCustomerPaymentProfileResponse> 
+0

有意義,尤其是XML輸出。不知何故,信用卡不在那裏。我也使用最新的SDK。 –

+0

看看[這Authnet社區線程](http://community.developer.authorize.net/t5/Integration-and-Testing/C-CIM-GetCustomerPaymentProfile-Assistance/mp/8678/highlight/true#M5864)是有幫助的 –

+0

是否嘗試使用CreditCard而不是CreditCard? –

相關問題