【问题标题】:How do I retrieve payment information using Authorize.Net CIM如何使用 Authorize.Net CIM 检索付款信息
【发布时间】:2012-11-29 10:21:50
【问题描述】:

我正在尝试使用 GetCustomerPaymentProfile 通过 Authorize.Net CIM API 检索付款信息。特别是,我需要屏蔽的信用卡号和信用卡类型或屏蔽的支票帐号。我已阅读 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;
        }

【问题讨论】:

  • 能否显示您收到的代码和错误消息?

标签: c# authorize.net payment-processing


【解决方案1】:

我不知道 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>

【讨论】:

  • 很有意义,尤其是对于 XML 输出。不知何故信用卡不存在。我也在使用最新的 SDK。
  • 看看this Authnet community thread有没有帮助
猜你喜欢
  • 2012-11-02
  • 2014-01-06
  • 2011-04-24
  • 2014-03-03
  • 2012-02-11
  • 2013-03-17
  • 1970-01-01
  • 2012-01-04
  • 1970-01-01
相关资源
最近更新 更多