gpt4 book ai didi

c# - 如何使用 Authorize.Net CIM 检索付款信息

转载 作者:太空宇宙 更新时间:2023-11-03 11:11:36 25 4
gpt4 key购买 nike

我正在尝试使用 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;
}

最佳答案

我不懂 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>

关于c# - 如何使用 Authorize.Net CIM 检索付款信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13827471/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com