Skip to main content
Version: 1.28 (Current)

Create Subscription

Audience: Low-code Engineers, Software Developers

Skill Prerequisites: Actions, Tokens, Authorize.Net

Creates a recurring subscription in Authorize.Net, using its Automated Recurring Billing (ARB) service. You give it a credit card, a billing name, an amount and a schedule, and Authorize.Net charges the card on that schedule.

The first charge happens on the start date, which is always the day after the action runs. Nothing is charged when the action runs. The action returns the new subscription ID, which you need to change the subscription later with Update Subscription.

It can also run actions when Authorize.Net sends a webhook notification about the subscription, for example when it's suspended or cancelled.

note

This action requires the Authorize.Net feature (AUTHORIZE) to be licensed. Authorize.Net support is a separate add-on package (DnnSharp.Authorize.Net). If you don't see the Authorize.Net actions, the add-on isn't installed.

Typical Use Cases​

  • Start a monthly or yearly membership from a sign-up form
  • Offer a trial period at a lower price, then bill the regular amount
  • Bill a fixed number of installments, for example 6 monthly payments
  • Save the subscription ID with the user's record, so you can update the subscription later
  • React to Authorize.Net notifications, for example suspend a member's access when their subscription is suspended

Don't use it to​

Action NameDescription
Update SubscriptionChanges the amount, card, billing details or number of payments of a subscription.
Make a Payment with Credit CardCharges a card once through Authorize.Net.
Make a Payment with Electronic CheckCharges a bank account once through Authorize.Net.
Add a Simple Checkout to a ButtonSends the user to a payment page hosted by Authorize.Net.
Refund a TransactionRefunds an Authorize.Net transaction.
Stripe Create SubscriptionCreates a recurring subscription in Stripe instead.
Run SQL QuerySaves the subscription ID in your database.

Input Parameter Reference​

ParameterDescriptionSupports TokensDefaultRequired
API Login IDThe API Login ID of your Authorize.Net account. Use the sandbox account's ID while testing.Yesempty stringYes
Transaction KeyThe Transaction Key that goes with the API Login ID. It's masked in the action editor.Yesempty stringYes
Go LiveWhen checked, the request goes to the Authorize.Net production environment and real cards are billed. When unchecked, it goes to the sandbox.NofalseNo
Card NumberThe credit card number. Spaces and dashes are removed before it's sent.Yesempty stringYes
Card CCVThe card's security code.Yesempty stringYes
Subscription NameA name for the subscription, shown in the Authorize.Net Merchant Interface, for example Gold Membership.Yesempty stringNo
Subscription AmountThe amount billed for each regular payment, with a decimal point and no currency symbol, for example 8.95. It must include tax, shipping and any other charges.Yes0Yes
Subscription Trial AmountThe amount billed for each trial payment. It's only sent when Trial Occurrences is set and the amount is above 0.Yes0No
Expiration MonthThe card's expiration month, for example 7 or 07. A one-digit month gets a leading zero.Yesempty stringYes
Expiration YearThe card's expiration year, for example 30 or 2030. Only the last two digits are sent.Yesempty stringYes
Interval LengthHow many days or months between payments. Authorize.Net accepts 7 to 365 days or 1 to 12 months. It must be at least 1, or the action fails.Yesempty stringYes
Interval UnitDays or Months. Can be set with an expression that returns 0 (Days) or 1 (Months).YesDaysYes
Total OccurrencesThe total number of payments, including trial payments. Use 9999 for a subscription with no end date. It must be at least 1, or the action fails.Yesempty stringYes
Trial OccurrencesHow many of the first payments are billed at the trial amount. It's ignored when Total Occurrences is 9999.Yes0No
First NameThe billing first name.Yesempty stringYes
Last NameThe billing last name.Yesempty stringYes
CountryThe billing country.Yesempty stringNo
StateThe billing state or province.Yesempty stringNo
CityThe billing city.Yesempty stringNo
AddressThe billing street address.Yesempty stringNo
Postal CodeThe billing postal or ZIP code.Yesempty stringNo
CompanyThe billing company name.Yesempty stringNo
Response Result Code TokenNameThe name of a token to store the result code in. See Output Parameters Reference.Noempty stringNo
Response Message TokenNameThe name of a token to store the response message in.Noempty stringNo
Response SubscriptionId TokenNameThe name of a token to store the new subscription ID in.Noempty stringNo
Response Customer ProfileId TokenNameThe name of a token to store the customer profile ID in.Noempty stringNo
Response Customer PaymentProfileId TokenNameThe name of a token to store the customer payment profile ID in.Noempty stringNo
Response Customer Address Id TokenNameThe name of a token to store the customer address ID in.Noempty stringNo
Response Ref Id TokenNameThe name of a token to store the reference ID in.Noempty stringNo
Response SessionToken TokenNameThe name of a token to store the session token in.Noempty stringNo
On SuccessActions that run when Authorize.Net creates the subscription.Noempty listNo
On ErrorActions that run when Authorize.Net rejects the request.Noempty listNo
On Subscription Payment CreatedActions that run when Authorize.Net notifies you that the subscription was created. See Webhook notifications.Noempty listNo
On Subscription Payment UpdatedActions that run when Authorize.Net notifies you that the subscription was updated.Noempty listNo
On Subscription Payment SuspendedActions that run when Authorize.Net notifies you that the subscription was suspended.Noempty listNo
On Subscription Payment TerminatedActions that run when Authorize.Net notifies you that the subscription was terminated.Noempty listNo
On Subscription Payment CancelledActions that run when Authorize.Net notifies you that the subscription was cancelled.Noempty listNo
On Subscription Payment ExpiringActions that run when Authorize.Net notifies you that the subscription has only one payment left.Noempty listNo

Output Parameters Reference​

Each token is only created if you enter a name for it. The tokens are set before On Success or On Error runs, so you can use them in both lists.

ParameterDescription
Response Result Code TokenNameOk if the subscription was created, Error if it wasn't.
Response Message TokenNameThe first message code and text from Authorize.Net, separated by two spaces, for example I00001 Successful. On an error, it tells you why, for example that the subscription is a duplicate.
Response SubscriptionId TokenNameThe ID of the new subscription. Save it, because Update Subscription needs it.
Response Customer ProfileId TokenNameThe ID of the customer profile Authorize.Net linked to the subscription, if it returned one.
Response Customer PaymentProfileId TokenNameThe ID of the customer payment profile, if Authorize.Net returned one.
Response Customer Address Id TokenNameThe ID of the customer address, if Authorize.Net returned one.
Response Ref Id TokenNameThe reference ID. The action doesn't send one, so it's normally empty.
Response SessionToken TokenNameThe session token Authorize.Net returned, normally empty.

What happens when it runs​

  1. The action checks that Interval Length and Total Occurrences are at least 1. If not, it fails with an error and nothing is sent.
  2. It sends the subscription to the sandbox or production environment, depending on Go Live. The start date is always tomorrow.
  3. It stores the output tokens you named.
  4. If the result is Ok, it saves the current tokens for webhook notifications (see below) and runs On Success.
  5. If the result is Error, for example because the card was rejected or a value is invalid, it runs On Error. The action doesn't raise an error in this case, so put your error handling in On Error.

If Authorize.Net doesn't answer at all, the action fails with an error. You can catch it with the On Error of an enclosing Execute Actions.

Webhook notifications​

The On Subscription Payment ... lists only run if you set up a webhook in the Authorize.Net Merchant Interface. Point it at this URL on your site, and select the subscription events you want:

{YourSiteUrl}/DesktopModules/DnnSharp/Common/WebHandlers/AuthorizeCreateSubscriptionHandler.ashx

See the Authorize.Net webhooks documentation for the setup steps.

Authorize.Net eventList that runs
net.authorize.customer.subscription.createdOn Subscription Payment Created
net.authorize.customer.subscription.updatedOn Subscription Payment Updated
net.authorize.customer.subscription.suspendedOn Subscription Payment Suspended
net.authorize.customer.subscription.terminatedOn Subscription Payment Terminated
net.authorize.customer.subscription.cancelledOn Subscription Payment Cancelled
net.authorize.customer.subscription.expiringOn Subscription Payment Expiring

When a notification arrives, the lists run with the tokens from the original run, for example the user's form values and the subscription ID token.

These tokens are kept for 7 days after the subscription is created. A notification that arrives later is ignored, and so is a notification for a subscription that wasn't created by this action. Other events, such as payment events, are ignored too.

Considerations​

  • Test in the sandbox first. Leave Go Live unchecked and use a sandbox account's API Login ID and Transaction Key. Authorize.Net's sandbox accepts test card numbers such as 4111111111111111. Check Go Live only with production credentials.
  • Keep credentials out of the action. Load the API Login ID and Transaction Key into tokens from a protected place, instead of typing them into each action.
  • Card data and PCI. Your site receives and passes on the full card number and security code, so your site is in scope for PCI DSS. Use HTTPS, don't save card fields to your database, and don't log them. On success, the action saves the current tokens for 7 days for webhook notifications, and these can include your form's card fields. If you'd rather not handle card data, use Add a Simple Checkout to a Button for one-time payments.
  • No payment happens now. The first payment is tomorrow. The card isn't charged when the subscription is created, so a bad card may only show up at the first payment, and a declined payment can suspend the subscription. If you need to charge the first period now, charge it with Make a Payment with Credit Card, and count that when you set Total Occurrences.
  • Trials. Total Occurrences includes the trial payments. For example, 1 trial month plus 12 regular months is 13. A trial isn't possible with 9999 occurrences, because the action ignores Trial Occurrences then. The trial amount is only sent when it's above 0, so test a free trial in the sandbox before you rely on it.
  • Check the interval. The default unit is Days, and Authorize.Net needs at least 7 days. Set Interval Unit to Months for monthly billing.
  • Save the subscription ID. Without it, you can't update the subscription from your application.
  • Duplicates. Authorize.Net rejects a subscription that duplicates an existing one, so a double submit usually ends in On Error.

Examples​

tip

To understand how to use the below examples, please see Running Examples.

The examples assume that earlier actions put the API credentials in the [AnetLoginId] and [AnetTransactionKey] tokens, and that the form has CardNumber, CardCode, ExpMonth, ExpYear, FirstName, LastName and PostalCode fields.

1. Monthly membership with no end date​

This action creates a monthly subscription of 19.95 in the sandbox. On success, it saves the subscription ID with the user's record. On error, it shows the reason.

{
"Title": "Create Subscription",
"ActionType": "CreateSubscription",
"Description": "Start the monthly membership",
"Parameters": {
"AuthorizeNetAPILoginID": "[AnetLoginId]",
"AuthorizeNetTransactionKey": "[AnetTransactionKey]",
"AuthorizeNetLiveMode": false,
"AuthorizeNetCardNumber": "[CardNumber]",
"AuthorizeNetCCV": "[CardCode]",
"AuthorizeNetSubscriptionName": "Monthly Membership",
"AuthorizeNetAmount": "19.95",
"AuthorizeNetExpirationMonth": "[ExpMonth]",
"AuthorizeNetExpirationYear": "[ExpYear]",
"AuthorizeNetIntervalLength": "1",
"AuthorizeNetIntervalUnit": "1",
"TotalOccurrences": "9999",
"AuthorizeNetFirstName": "[FirstName]",
"AuthorizeNetLastName": "[LastName]",
"AuthorizeNetPostalCode": "[PostalCode]",
"AuthorizeNetResponseResultCodeTokenName": "AnetResult",
"AuthorizeNetResponseMessageTokenName": "AnetMessage",
"AuthorizeNetResponseSubscriptionIdTokenName": "SubscriptionId",
"OnSuccess": [
{
"Title": "Run SQL Query",
"ActionType": "RunSql",
"Parameters": {
"ConnectionString": "",
"QueryTimeout": "",
"SqlQuery": "UPDATE dbo.Members SET SubscriptionId = '[SubscriptionId]' WHERE UserId = [User:UserId]",
"BindTokens": "",
"OutputTokenName": "",
"ExtractColumns": "",
"OnError": [],
"ShowErrors": false
}
},
{
"Title": "Display Message",
"ActionType": "ShowMessage",
"Parameters": {
"Message": "<p>Your membership is active. Your first payment will be taken tomorrow.</p>"
}
}
],
"OnError": [
{
"Title": "Display Error Message",
"ActionType": "ShowError",
"Parameters": {
"Message": "<p>We couldn't start your membership: [AnetMessage]</p>"
}
}
]
}
}

2. Trial month, then 12 regular months​

This action bills 1.00 for the first month and 29.00 for the next 12 months, so Total Occurrences is 13. When Authorize.Net later notifies you that the subscription was suspended, for example after a declined payment, it logs the subscription ID. That only works within 7 days of creating the subscription, and only if the webhook is set up.

{
"Title": "Create Subscription",
"ActionType": "CreateSubscription",
"Description": "Start the plan with a trial month",
"Parameters": {
"AuthorizeNetAPILoginID": "[AnetLoginId]",
"AuthorizeNetTransactionKey": "[AnetTransactionKey]",
"AuthorizeNetLiveMode": false,
"AuthorizeNetCardNumber": "[CardNumber]",
"AuthorizeNetCCV": "[CardCode]",
"AuthorizeNetSubscriptionName": "Pro Plan",
"AuthorizeNetAmount": "29.00",
"AuthorizeNetTrialAmount": "1.00",
"AuthorizeNetExpirationMonth": "[ExpMonth]",
"AuthorizeNetExpirationYear": "[ExpYear]",
"AuthorizeNetIntervalLength": "1",
"AuthorizeNetIntervalUnit": "1",
"TotalOccurrences": "13",
"TrialOccurrences": "1",
"AuthorizeNetFirstName": "[FirstName]",
"AuthorizeNetLastName": "[LastName]",
"AuthorizeNetResponseResultCodeTokenName": "AnetResult",
"AuthorizeNetResponseMessageTokenName": "AnetMessage",
"AuthorizeNetResponseSubscriptionIdTokenName": "SubscriptionId",
"OnError": [
{
"Title": "Display Error Message",
"ActionType": "ShowError",
"Parameters": {
"Message": "<p>We couldn't start your plan: [AnetMessage]</p>"
}
}
],
"OnSubscriptionPaymentSuspended": [
{
"Title": "Log Error",
"ActionType": "LogError",
"Parameters": {
"Message": "Authorize.Net subscription [SubscriptionId] was suspended."
}
}
]
}
}

Revised 09/27/2026