2

我正在尝试使用 Authorize.Net CIM API 使用 GetCustomerPaymentProfile 检索付款信息。特别是,我需要屏蔽的信用卡号和信用卡类型或屏蔽的支票帐号。我已阅读 API 文档并遵循它,但没有智能感知,因此我的项目无法编译。

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;
        }
4

1 回答 1

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>
于 2012-12-11T20:01:10.717 回答