- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
在玩弄了Authorize.Net CIM XML API C# sample code之后, 我开始使用 Authorize.Net C# SDK .我能够使用 CIM XML API 示例代码将信用卡和银行帐户添加到客户资料中。不过,我不知道如何使用 SDK 添加银行账户。
使用 CIM XML API 添加银行账户:
...
customerPaymentProfileType new_payment_profile = new customerPaymentProfileType();
paymentType new_payment = new paymentType();
bankAccountType new_bank = new bankAccountType();
new_bank.nameOnAccount = "xyz";
new_bank.accountNumber = "4111111";
new_bank.routingNumber = "325070760";
new_payment.Item = new_bank;
new_payment_profile.payment = new_payment;
createCustomerPaymentProfileRequest request = new createCustomerPaymentProfileRequest();
XmlAPIUtilities.PopulateMerchantAuthentication((ANetApiRequest)request);
request.customerProfileId = profile_id.ToString();
request.paymentProfile = new_payment_profile;
request.validationMode = validationModeEnum.testMode;
...
使用 SDK 我只看到 .AddCreditCard()
方法,但无法添加银行帐户。当我遍历所有 PaymentProfiles
时,它也会在遇到银行账户时抛出异常:
CustomerGateway cg = new CustomerGateway("xxx", "yyy");
foreach (string cid in cg.GetCustomerIDs())
{
Customer c = cg.GetCustomer(cid);
foreach (PaymentProfile pp in c.PaymentProfiles)
{
Console.WriteLine(pp.ToString());
}
}
异常(exception):
Unable to cast object of type 'AuthorizeNet.APICore.bankAccountMaskedType' to type 'AuthorizeNet.APICore.creditCardMaskedType'.
如何使用 Authorize.Net C# SDK 将银行账户添加到 CIM 配置文件?
更新:
CIM 可以存储银行账户信息的证明:
最佳答案
以下内容经过测试,但仅限于原始问题提出的内容(为我测试更多?),我使用提供的 XML 示例并通过复制 AddCreditCard 代码的代码来编写它。
当你全部完成更新后,下面的代码就可以工作了:
var cg = new CustomerGateway("login", "transkey", ServiceMode.Test);
var c = cg.CreateCustomer("peter@example.com", "test customer");
//just to show that we didn't break CC
cg.AddCreditCard(c.ProfileID, "cc#", 07, 2011);
cg.AddBankAccount(c.ProfileID, "Peter", "bankaccoung#", "routing#");
//tostring doesn't actually do much... but if you break on it you can see the details for both the CC and the bank info.
foreach (PaymentProfile pp in cg.GetCustomer(c.ProfileID).PaymentProfiles)
{
Console.WriteLine(pp.ToString());
}
首先,从 http://developer.authorize.net/downloads/ 下载 API 的 C# 源代码.
在查看代码时,我可以看到 4 个使用“creditCardType”的文件,它们是 SubscriptionRequest.cs、CustomerGateway.cs、PaymentProfile.cs 和 AnetApiSchema.cs(最后一个我们不必触及)。我们还需要注意在 PaymentProfile.cs、Transaction.cs 和 AnetApiSchema.cs 中使用的“creditCardMaskedType”。这些文件出现的任何地方我们都需要确保我们也支持 bankAccount 等价物。
打开 AuthorizeNET 解决方案。我们将跳过上面列出的文件。
在 CustomerGateway.cs 中添加以下代码块:
/// <summary>
/// Adds a bank account profile to the user and returns the profile ID
/// </summary>
/// <returns></returns>
public string AddBankAccount(string profileID, string nameOnAccount, string accountNumber, string routingNumber)
{
var req = new createCustomerPaymentProfileRequest();
req.customerProfileId = profileID;
req.paymentProfile = new customerPaymentProfileType();
req.paymentProfile.payment = new paymentType();
bankAccountType new_bank = new bankAccountType();
new_bank.nameOnAccount = nameOnAccount;
new_bank.accountNumber = accountNumber;
new_bank.routingNumber = routingNumber;
req.paymentProfile.payment.Item = new_bank;
var response = (createCustomerPaymentProfileResponse)_gateway.Send(req);
return response.customerPaymentProfileId;
}
在 PaymentProfile.cs 中添加一些公共(public)属性
public string BankNameOnAccount {get; set; }
public string BankAccountNumber { get; set; }
public string BankRoutingNumber { get; set; }
修改 PaymentProfile(customerPaymentProfileMaskedType apiType)
构造函数的以下 block :
if (apiType.payment != null) {
if(apiType.payment.Item is bankAccountMaskedType) {
var bankAccount = (bankAccountMaskedType)apiType.payment.Item;
this.BankNameOnAccount = bankAccount.nameOnAccount;
this.BankAccountNumber = bankAccount.accountNumber;
this.BankRoutingNumber = bankAccount.routingNumber;
}
else if (apiType.payment.Item is creditCardMaskedType)
{
var card = (creditCardMaskedType)apiType.payment.Item;
this.CardType = card.cardType;
this.CardNumber = card.cardNumber;
this.CardExpiration = card.expirationDate;
}
}
将此 block 添加到 PaymentProfile.ToAPI()
方法:
if (!string.IsNullOrEmpty(this.BankAccountNumber))
{
bankAccountType new_bank = new bankAccountType();
new_bank.nameOnAccount = BankNameOnAccount;
new_bank.accountNumber = BankAccountNumber;
new_bank.routingNumber = BankRoutingNumber;
result.payment.Item = new_bank;
}
将以下公共(public)属性添加到 SubscriptionRequest.cs > SubscriptionRequest 类(第 187 行左右)
public string BankNameOnAccount {get; set; }
public string BankAccountNumber { get; set; }
public string BankRoutingNumber { get; set; }
将以下 else if block TWICE 添加到 SubscriptionRequest。第一次是在 ToAPI 方法中,第二次是在 ToUpdateableAPI 方法中,在这两种情况下,它都在 CC 号码空检查之后。
else if (!String.IsNullOrEmpty(this.BankAccountNumber))
{
bankAccountType new_bank = new bankAccountType();
new_bank.nameOnAccount = BankNameOnAccount;
new_bank.accountNumber = BankAccountNumber;
new_bank.routingNumber = BankRoutingNumber;
sub.payment = new paymentType();
sub.payment.Item = new_bank;
}
将以下公共(public)属性添加到 Transaction.cs
public string BankNameOnAccount { get; set; }
public string BankAccountNumber { get; set; }
public string BankRoutingNumber { get; set; }
在静态 NewFromResponse(transactionDetailsType trans) 方法中的 Transaction.cs 中,找到检查 trans.payment != null
的 block 并进行调整,如下所示:
if (trans.payment != null) {
if (trans.payment.Item.GetType() == typeof(creditCardMaskedType))
{
var cc = (creditCardMaskedType)trans.payment.Item;
result.CardNumber = cc.cardNumber;
result.CardExpiration = cc.expirationDate;
result.CardType = cc.cardType;
}
else if (trans.payment.Item.GetType() == typeof(bankAccountMaskedType))
{
var bankAccount = (bankAccountMaskedType)trans.payment.Item;
result.BankNameOnAccount = bankAccount.nameOnAccount;
result.BankAccountNumber = bankAccount.accountNumber;
result.BankRoutingNumber = bankAccount.routingNumber;
}
}
关于c# - 通过 Authorize.Net C# SDK 使用银行账户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10981540/
我正在细读 http://www.khronos.org/网站,只找到了 OpenCL 的头文件(不是我不关心的 OpenGL)。如何获取 OpenCL SDK? 最佳答案 AMD 的 ATI Str
Android 项目中最低(最低 sdk)和最高(目标 sdk)级别是否有任何影响。这些东西是否会影响项目的可靠性和效率。 最佳答案 没有影响,如果您以 SDK 级别 8 为目标,那么您的应用将以 9
“min sdk version/target sdk version”和“compile sdk version”有什么区别?我知道 min 和 target sdk 是什么意思,但是 compil
我正在尝试运行 Dji Mobile-Sdk-Android:https://github.com/dji-sdk/Mobile-SDK-Android使用 dji 网站上的说明:https://de
我目前正在向我的 iPhone 应用程序添加新的 Facebook iOS sdk 3.1.1。我看到 sdk 有重大变化。例如。我的旧 sdk 创建一个 Facebook 对象并从 FBReques
我最近刚刚下载了 Xcode 4.6 with mac 10.8.4 with iOS 6.0 SDK package,我立即注意到我无法使用我的 iPhone 3Gs with iOS 4.6 进行
我尝试下载 OpenCL SDK。但是没办法。我有一个 AMD GPU,所以我在谷歌上搜索了 AMD SDK,但是来自谷歌的所有链接和一些教程都被破坏了,不可能通过 AMD 开发者网站找到 sdk。
安装 Google Cloud SDK 后,当我运行时 gcloud 授权登录 我收到一条错误消息: Your browser has been opened to visit: https://a
我一直在 nvidia 网站上搜索 GPU 计算 SDK,因为我正在尝试构建具有 cuda 支持的点云库 (PCL)。但是,在 nvidia 网站上,我只能找到工具包的链接,而不是 SDK 的单个下载
Closed. This question needs to be more focused。它当前不接受答案。 想改善这个问题吗?更新问题,使其仅关注editing this post一个问题。 2
当我打开 Android SDK 管理器时,会出现一个屏幕“选择要安装的包”。它列出了一堆带有绿色复选标记(已经安装)的软件包,还有一些带有 x's 的软件包,它们没有安装。如果我选择“全部接受”,它
在开发过程中,我发布了 SDK 21 Lollipop,但我无法在我的 KitKat 设备上使用它。应用程序非常简单,我只将 SDK 用于动画和 Material 设计,但是当我尝试对 Play 商店
enter image description here friend 们好 在使用 Linux、jenkins 和 docker 探索 dotnet 核心时,我遇到了构建问题,该问题在标题“/usr
关闭。这个问题需要debugging details .它目前不接受答案。 编辑问题以包含 desired behavior, a specific problem or error, and th
我创建了一个flutter项目,运行flutter packages get,输出如下:【二】flutter包搞定等待另一个 flutter 命令释放启动锁...第二次运行“flutter packa
这个问题在这里已经有了答案: What are the Android SDK build-tools, platform-tools and tools? And which version sh
我使用 Corona SDK 已经快一年了,并且开发了几个简单的游戏。我现在正在寻找的是在 Corona SDK 中创建 3D 幻觉的某种方法。如果有人有 Corona 3D 方面的经验,我将不胜感激
我有一个CLDC 1.1 / MIDP 2.0项目,可以使用Java ME SDK 3.2很好地进行编译。 最近,我已将Java SE升级到8,结果Java ME SDK开始在Windows启动时显示
有没有办法以编程方式控制连接到华擎主板的 RGB 照明?我知道华硕有一个 Aura SDK,但华擎是否也有一个用于他们的硬件? 如果是,我在哪里可以找到它? 最佳答案 没有用于华擎多彩的 sdk。但是
如何使用 crm 2011 sdk 和 XrmServiceContext 创建事务? 在下一个示例中,'new_brand' 是一些自定义实体。我想创建三个品牌。第三个拥有错误的 OwnerID g
我是一名优秀的程序员,十分优秀!