2012-12-11 101 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? –

相关问题