简体   繁体   English

使用 Authorize.Net 进行定期付款

[英]Recurring Payment With Authorize.Net

I am trying to implement Authorize.Net in an ASP.NET web form app and as I am new to it, was going through its official website and few other random sites to learn about it.我正在尝试在ASP.NET web 表单应用程序中实现Authorize.Net ,由于我是新手,因此正在通过其官方网站和其他一些随机网站了解它。 The following links helped me a bit:以下链接对我有所帮助:

Recurring Bill 经常性账单

Recurring Bill Code Sample 经常性账单代码示例

So far, the following code snippet seems ok to implement as it has few configurations to set up and created a sandbox account to get it done:到目前为止,以下代码片段似乎可以实现,因为它需要设置的配置很少,并创建了一个沙盒帐户来完成它:

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

I've a tricky requirement and one thing to confirm here.我有一个棘手的要求,还有一件事要在这里确认。 In the web app, if a user signs up in the website, then an amount of $1 will be charged with Authorize.Net api and if the user uses the website for more than three days after sign up, then it'll automatically redirect the user to a monthly subscription (So another fee will be charged here).在 web 应用程序中,如果用户在网站上注册,则将向Authorize.Net api 收取 1 美元的费用,如果用户在注册后使用该网站超过三天,则会自动重定向用户每月订阅(因此这里将收取另一笔费用)。

Is it something that can be handled with Authorize.Net and for recurring bill, do I require to save user credit card details in the website's database or something similar?是否可以使用Authorize.Net处理,对于经常性账单,我是否需要将用户信用卡详细信息保存在网站的数据库或类似的东西中?

What you would want to do is:你想做的是:

  1. Create a customer payment profile (this allows you to collect their credit card information only once so you can use it again if you reach step 3)创建客户付款资料(这允许您只收集一次他们的信用卡信息,以便在您到达第 3 步时再次使用它)
  2. Using that payment profile, charge your initial $1.00 amount 使用该付款资料,收取您的初始 1.00 美元金额
  3. If they do not cancel after three days, using that payment profile, charge their first month's subscription payment.如果他们在三天后没有取消, 使用该付款资料,收取他们第一个月的订阅费用。 You do this as a "regular" transactions because subscriptions do not begin immediately.您将此作为“常规”交易进行,因为订阅不会立即开始。
  4. Create a subscription using their payment profile ID (so you do not have to store their credit card details yourself) with the start date set to 30 days out. 使用他们的付款资料 ID 创建订阅(因此您不必自己存储他们的信用卡详细信息),开始日期设置为 30 天后。

Be sure to store their profile ID and payment profile ID for later reference.请务必存储他们的个人资料 ID 和付款资料 ID 以供日后参考。 You will need it to charge their first subscription payment and to create their subscription (you will need to trigger these from your website, most likely through an automated process).您将需要它来收取他们的第一笔订阅费用并创建他们的订阅(您需要从您的网站触发这些,很可能是通过自动化过程)。 At some point you will also need to update their credit card information once it expires.在某些时候,您还需要在到期后更新他们的信用卡信息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM