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. The following links helped me a bit:
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).
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?
What you would want to do is:
Be sure to store their profile ID and payment profile ID for later reference. 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.