Create Subscription
Audience:
Low-code Engineers,Software DevelopersSkill 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.
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
- Charge a one-time payment, or charge the first period right away. Use Make a Payment with Credit Card.
- Bill a bank account. This action only accepts a credit card. For a one-time bank payment, use Make a Payment with Electronic Check.
- Change an existing subscription. Use Update Subscription.
- Cancel a subscription. There's no action for this. Cancel it in the Authorize.Net Merchant Interface.
- Refund a subscription payment. Use Refund a Transaction.
Related Actions
| Action Name | Description |
|---|---|
| Update Subscription | Changes the amount, card, billing details or number of payments of a subscription. |
| Make a Payment with Credit Card | Charges a card once through Authorize.Net. |
| Make a Payment with Electronic Check | Charges a bank account once through Authorize.Net. |
| Add a Simple Checkout to a Button | Sends the user to a payment page hosted by Authorize.Net. |
| Refund a Transaction | Refunds an Authorize.Net transaction. |
| Stripe Create Subscription | Creates a recurring subscription in Stripe instead. |
| Run SQL Query | Saves the subscription ID in your database. |
Input Parameter Reference
| Parameter | Description | Supports Tokens | Default | Required |
|---|---|---|---|---|
| API Login ID | The API Login ID of your Authorize.Net account. Use the sandbox account's ID while testing. | Yes | empty string | Yes |
| Transaction Key | The Transaction Key that goes with the API Login ID. It's masked in the action editor. | Yes | empty string | Yes |
| Go Live | When checked, the request goes to the Authorize.Net production environment and real cards are billed. When unchecked, it goes to the sandbox. | No | false | No |
| Card Number | The credit card number. Spaces and dashes are removed before it's sent. | Yes | empty string | Yes |
| Card CCV | The card's security code. | Yes | empty string | Yes |
| Subscription Name | A name for the subscription, shown in the Authorize.Net Merchant Interface, for example Gold Membership. | Yes | empty string | No |
| Subscription Amount | The 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. | Yes | 0 | Yes |
| Subscription Trial Amount | The amount billed for each trial payment. It's only sent when Trial Occurrences is set and the amount is above 0. | Yes | 0 | No |
| Expiration Month | The card's expiration month, for example 7 or 07. A one-digit month gets a leading zero. | Yes | empty string | Yes |
| Expiration Year | The card's expiration year, for example 30 or 2030. Only the last two digits are sent. | Yes | empty string | Yes |
| Interval Length | How 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. | Yes | empty string | Yes |
| Interval Unit | Days or Months. Can be set with an expression that returns 0 (Days) or 1 (Months). | Yes | Days | Yes |
| Total Occurrences | The 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. | Yes | empty string | Yes |
| Trial Occurrences | How many of the first payments are billed at the trial amount. It's ignored when Total Occurrences is 9999. | Yes | 0 | No |
| First Name | The billing first name. | Yes | empty string | Yes |
| Last Name | The billing last name. | Yes | empty string | Yes |
| Country | The billing country. | Yes | empty string | No |
| State | The billing state or province. | Yes | empty string | No |
| City | The billing city. | Yes | empty string | No |
| Address | The billing street address. | Yes | empty string | No |
| Postal Code | The billing postal or ZIP code. | Yes | empty string | No |
| Company | The billing company name. | Yes | empty string | No |
| Response Result Code TokenName | The name of a token to store the result code in. See Output Parameters Reference. | No | empty string | No |
| Response Message TokenName | The name of a token to store the response message in. | No | empty string | No |
| Response SubscriptionId TokenName | The name of a token to store the new subscription ID in. | No | empty string | No |
| Response Customer ProfileId TokenName | The name of a token to store the customer profile ID in. | No | empty string | No |
| Response Customer PaymentProfileId TokenName | The name of a token to store the customer payment profile ID in. | No | empty string | No |
| Response Customer Address Id TokenName | The name of a token to store the customer address ID in. | No | empty string | No |
| Response Ref Id TokenName | The name of a token to store the reference ID in. | No | empty string | No |
| Response SessionToken TokenName | The name of a token to store the session token in. | No | empty string | No |
| On Success | Actions that run when Authorize.Net creates the subscription. | No | empty list | No |
| On Error | Actions that run when Authorize.Net rejects the request. | No | empty list | No |
| On Subscription Payment Created | Actions that run when Authorize.Net notifies you that the subscription was created. See Webhook notifications. | No | empty list | No |
| On Subscription Payment Updated | Actions that run when Authorize.Net notifies you that the subscription was updated. | No | empty list | No |
| On Subscription Payment Suspended | Actions that run when Authorize.Net notifies you that the subscription was suspended. | No | empty list | No |
| On Subscription Payment Terminated | Actions that run when Authorize.Net notifies you that the subscription was terminated. | No | empty list | No |
| On Subscription Payment Cancelled | Actions that run when Authorize.Net notifies you that the subscription was cancelled. | No | empty list | No |
| On Subscription Payment Expiring | Actions that run when Authorize.Net notifies you that the subscription has only one payment left. | No | empty list | No |
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.
| Parameter | Description |
|---|---|
| Response Result Code TokenName | Ok if the subscription was created, Error if it wasn't. |
| Response Message TokenName | The 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 TokenName | The ID of the new subscription. Save it, because Update Subscription needs it. |
| Response Customer ProfileId TokenName | The ID of the customer profile Authorize.Net linked to the subscription, if it returned one. |
| Response Customer PaymentProfileId TokenName | The ID of the customer payment profile, if Authorize.Net returned one. |
| Response Customer Address Id TokenName | The ID of the customer address, if Authorize.Net returned one. |
| Response Ref Id TokenName | The reference ID. The action doesn't send one, so it's normally empty. |
| Response SessionToken TokenName | The session token Authorize.Net returned, normally empty. |
What happens when it runs
- The action checks that
Interval LengthandTotal Occurrencesare at least1. If not, it fails with an error and nothing is sent. - It sends the subscription to the sandbox or production environment, depending on
Go Live. The start date is always tomorrow. - It stores the output tokens you named.
- If the result is
Ok, it saves the current tokens for webhook notifications (see below) and runsOn Success. - If the result is
Error, for example because the card was rejected or a value is invalid, it runsOn Error. The action doesn't raise an error in this case, so put your error handling inOn 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 event | List that runs |
|---|---|
net.authorize.customer.subscription.created | On Subscription Payment Created |
net.authorize.customer.subscription.updated | On Subscription Payment Updated |
net.authorize.customer.subscription.suspended | On Subscription Payment Suspended |
net.authorize.customer.subscription.terminated | On Subscription Payment Terminated |
net.authorize.customer.subscription.cancelled | On Subscription Payment Cancelled |
net.authorize.customer.subscription.expiring | On 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 Liveunchecked and use a sandbox account's API Login ID and Transaction Key. Authorize.Net's sandbox accepts test card numbers such as4111111111111111. CheckGo Liveonly 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 Occurrencesincludes the trial payments. For example, 1 trial month plus 12 regular months is13. A trial isn't possible with9999occurrences, because the action ignoresTrial Occurrencesthen. The trial amount is only sent when it's above0, 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. SetInterval UnittoMonthsfor 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
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