使用 Authorize.Net 定期付款

问题描述

我正在尝试在 Authorize.Net 网络表单应用程序中实现 ASP.NET,因为我是新手,正在浏览其官方网站和其他几个随机网站以了解它。以下链接我有所帮助:

Recurring Bill

Recurring Bill Code Sample

到目前为止,以下代码片段似乎可以实现,因为它需要设置和创建沙箱帐户来完成它的配置很少:

 ApiOperationBase<ANetApiRequest,ANetApiResponse>.MerchantAuthentication = new merchantAuthenticationType()
 {
      name            = ApiLoginID,ItemElementName = ItemChoiceType.transactionKey,Item            = ApiTransactionKey,};

 paymentScheduleTypeInterval interval = new paymentScheduleTypeInterval();

 interval.length = intervalLength;                        // months can be indicated between 1 and 12
 interval.unit   = ARBSubscriptionUnitEnum.days;

 paymentScheduleType schedule = new paymentScheduleType
 {
     interval            = interval,startDate           = DateTime.Now.AddDays(1),// start date should be tomorrow
     totalOccurrences    = 9999,// 999 indicates no end date
     trialOccurrences     = 3
 };

 #region Payment information
 var creditCard = new creditCardType
 {
     cardNumber      = "4111111111111111",expirationDate  = "1028"
 };

我有一个棘手的要求,需要在这里确认一件事。在网络应用程序中,如果用户在网站上注册,则将向Authorize.Net api收取1美元的费用,如果用户注册后使用该网站超过三天,则它会自动用户重定向到按月订阅(因此此处将收取另一笔费用)。

是否可以使用 Authorize.Net 处理,对于经常性账单,我是否需要将用户信用卡详细信息保存在网站的数据库或类似内容中?

解决方法

您想要做的是:

  1. 创建一个customer payment profile(这允许您只收集一次他们的信用卡信息,以便您在到达第 3 步时可以再次使用)
  2. Using that payment profile,charge 您最初的 $1.00 金额
  3. 如果三天后他们没有取消,using that payment profile,charge他们第一个月的订阅费用。您以“常规”交易方式执行此操作,因为订阅不会立即开始。
  4. Create a subscription using their payment profile ID(这样您就不必自己存储他们的信用卡详细信息)并将开始日期设置为 30 天后。

请务必存储他们的个人资料 ID 和付款资料 ID,以供日后参考。您将需要它来收取他们的第一笔订阅费用并创建他们的订阅(您需要从您的网站触发这些,很可能是通过一个自动化过程)。在某些时候,您还需要在过期后update their credit card information