Skip to main content
Version: 1.28 (Current)

Stripe Create Subscription

Audience: Low-code Engineers

Skill Prerequisites: Actions, Tokens, Connectors, Stripe

Subscribes an existing Stripe customer to an existing plan. Stripe then bills the customer on the plan's schedule. The action returns the ID of the new subscription.

You need a customer ID, for example from Stripe Create Customer, and a plan ID, for example from Stripe Create Plan. Stripe can charge the customer's saved card automatically, or email an invoice.

note

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

Typical Use Cases​

  • Start a monthly or yearly membership after the user enters a card in a form
  • Bill a business customer by invoice, with a number of days to pay
  • Apply a discount coupon to a new subscription
  • Create a subscription on a seller's connected Stripe account, and take an application fee
  • Save the subscription ID with the user's record

Don't use it to​

Action NameDescription
Stripe Create PlanCreates the plan to subscribe to.
Stripe Create CustomerCreates the customer and saves their card.
Stripe Get Event DetailsReads Stripe webhook events, for example to learn that a subscription payment failed.
Stripe Add SellerConnects a seller's Stripe account to your platform.
Get Stripe User AccountFinds the ID of a connected account, for Payment To.
Add Stripe ConnectorCreates the Stripe connector this action uses.
Create SubscriptionCreates a recurring subscription in Authorize.Net instead.
Run SQL QuerySaves the subscription ID in your database.

Input Parameter Reference​

ParameterDescriptionSupports TokensDefaultRequired
API ConnectorThe Stripe connector with the secret key to use. See Add Stripe Connector. When using an expression, the value must be the connector ID.YesnoneYes
Customer IDThe ID of the Stripe customer, for example cus_....Yesempty stringYes
Plan IDThe ID of the Stripe plan, for example plan_... from [Stripe:PlanId].Yesempty stringYes
Coupon IDThe ID of a Stripe coupon to apply to the subscription. Leave it empty for no discount.Yesempty stringNo
Payment ToThe ID of a connected Stripe account, for example acct_.... When set, the subscription is created on that account instead of your platform account. See Connected accounts.Yesempty stringNo
Application Fee PercentageThe percentage of each invoice subtotal that goes to your platform account, with a dot for decimals, for example 2.35. Only used, and only shown, when Payment To has a value.Yesempty stringNo
Tax PercentageThe tax percentage added to each invoice, with a dot for decimals. For example, a 10.00 plan with 20.0 bills 12.00.Yesempty stringNo
Billing TypeCharge Automatically charges the customer's default payment method. Send Invoice has Stripe email the customer an invoice to pay.NoCharge AutomaticallyNo
Days Until DueThe number of days the customer has to pay each invoice. Only shown, and required, when Billing Type is Send Invoice. It must be 1 or more.Yesempty stringYes, with Send Invoice
On SuccessActions that run after Stripe creates the subscription.Noempty listNo
On ErrorActions that run when Stripe rejects the request. The reason is in [Stripe:ErrorMessage].Noempty listNo

The subscription always has a quantity of 1.

Output Parameters Reference​

The tokens are set before On Success or On Error runs.

ParameterDescription
[Stripe:SubscriptionId]The ID of the new subscription, created by Stripe, for example sub_....
[Stripe:ErrorMessage]The error message from Stripe, when the request fails.

What happens when it runs​

  1. If Billing Type is Send Invoice and Days Until Due is less than 1, the action raises an error right away. On Error doesn't run for this.
  2. It reads Application Fee Percentage and Tax Percentage as numbers. A value that isn't a number raises an error, and On Error doesn't run for it either.
  3. It sends the subscription to Stripe with the connector's secret key, on the Payment To account if one is set.
  4. On success, it sets [Stripe:SubscriptionId] and runs On Success.
  5. If Stripe rejects the request, for example because the customer or plan doesn't exist, it sets [Stripe:ErrorMessage] and runs On Error. If On Error is empty, the action raises the error instead.

Payment and incomplete subscriptions​

With Charge Automatically, Stripe tries to pay the first invoice as soon as the subscription is created, using the customer's default card or payment method. Stripe Create Customer saves the card as the customer's default.

If that payment fails, or the bank asks for 3D Secure (SCA) authentication, Stripe still creates the subscription, with the status incomplete. The action treats this as a success. It sets [Stripe:SubscriptionId] and runs On Success. It doesn't return the status, and it doesn't show the customer a 3D Secure step.

If the first invoice isn't paid within about 23 hours, Stripe expires the subscription (incomplete_expired). Later payments that fail are handled by your Stripe billing settings, for example retries.

So don't treat On Success as proof of payment. Before you give access, check the status in Stripe, or listen to Stripe's webhook events, such as invoice.payment_succeeded and invoice.payment_failed, with Stripe Get Event Details.

With Send Invoice, nothing is charged when the action runs. Stripe sends the invoice, and the customer pays it within Days Until Due.

Connected accounts​

When Payment To has a value, the request is made on behalf of that connected account. The subscription, and its payments, belong to the connected account, not your platform account. This means:

  • The Customer ID, Plan ID and Coupon ID must exist on the connected account. Customers and plans from your platform account aren't found.
  • Application Fee Percentage is the part of each invoice that's sent to your platform account.
  • The connector's secret key must be your platform key, and the account must be connected to your platform, for example with Stripe Add Seller.

Considerations​

  • Test and live keys. A connector with a test key (sk_test_...) creates test subscriptions. The customer, plan and coupon must come from the same mode as the key.
  • Don't let users choose IDs. Load Customer ID, Plan ID, Coupon ID and Payment To from your own data, for example the current user's saved record. If they come from form fields that users can edit, a user could change them, for example to subscribe another customer or use another plan.
  • Save the subscription ID. You need it to find the subscription in Stripe and to match webhook events to your users.
  • Trials. The action doesn't ask Stripe to use the plan's Default Trial Period Days, so the subscription starts without a trial. See Stripe Create Plan.
  • Duplicates. Stripe doesn't block a second subscription to the same plan. A double submit can create two subscriptions, so guard against it, for example by checking your database first.
  • Decimals use a dot. Enter percentages like 2.35. A comma may fail, or be read differently, depending on the server's language settings.
  • Tax Percentage is an older Stripe feature. Stripe now uses tax rates instead. The action uses the Stripe.net library version 29.2.0 (Stripe API version 2019-09-09), which still supports it.

Examples​

tip

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

1. Monthly membership charged to the saved card​

This action subscribes the customer in [StripeCustomerId], for example created by Stripe Create Customer earlier in the same form, to the plan in [GoldPlanId]. On success, it saves the subscription ID and tells the user to wait for confirmation. Replace the connector ID with your Stripe connector.

{
"Title": "Stripe Create Subscription",
"ActionType": "StripeCreateSubscription",
"Description": "Subscribe the customer to the Gold plan",
"Condition": "[StripeCustomerId] != \"\"",
"Parameters": {
"Credentials": {
"Entry": "00000000-0000-0000-0000-000000000000"
},
"CustomerId": "[StripeCustomerId]",
"PlanId": "[GoldPlanId]",
"BillingType": "ChargeAutomatically",
"OnSuccess": [
{
"Title": "Run SQL Query",
"ActionType": "RunSql",
"Parameters": {
"ConnectionString": "",
"QueryTimeout": "",
"SqlQuery": "UPDATE dbo.Members SET StripeSubscriptionId = '[Stripe:SubscriptionId]', Status = 'Pending' WHERE UserId = [User:UserId]",
"BindTokens": "",
"OutputTokenName": "",
"ExtractColumns": "",
"OnError": [],
"ShowErrors": false
}
},
{
"Title": "Display Message",
"ActionType": "ShowMessage",
"Parameters": {
"Message": "<p>Thanks! We'll activate your membership as soon as your payment is confirmed.</p>"
}
}
],
"OnError": [
{
"Title": "Display Error Message",
"ActionType": "ShowError",
"Parameters": {
"Message": "<p>We couldn't start your membership: [Stripe:ErrorMessage]</p>"
}
}
]
}
}

2. Invoice billing with 30 days to pay​

This action subscribes a business customer to a plan and has Stripe email an invoice each period, due in 30 days. The customer and plan IDs come from the [CustomerStripeId] and [PlanStripeId] tokens, for example loaded from your database. Any error is written to the log.

{
"Title": "Stripe Create Subscription",
"ActionType": "StripeCreateSubscription",
"Description": "Subscribe a business customer with invoice billing",
"Parameters": {
"Credentials": {
"IsExpression": true,
"Entry": "[StripeConnectorId]"
},
"CustomerId": "[CustomerStripeId]",
"PlanId": "[PlanStripeId]",
"BillingType": "SendInvoice",
"DaysUntilDue": "30",
"OnError": [
{
"Title": "Log Error",
"ActionType": "LogError",
"Parameters": {
"Message": "Stripe subscription failed for customer [CustomerStripeId]: [Stripe:ErrorMessage]"
}
}
]
}
}

3. Subscription on a seller's account with a platform fee​

This action creates the subscription on the connected account in [SellerAccountId] and sends 5% of each invoice to your platform account. The customer and plan must exist on the seller's account.

{
"Title": "Stripe Create Subscription",
"ActionType": "StripeCreateSubscription",
"Description": "Subscribe the customer on the seller's account",
"Parameters": {
"Credentials": {
"Entry": "00000000-0000-0000-0000-000000000000"
},
"CustomerId": "[SellerCustomerId]",
"PlanId": "[SellerPlanId]",
"PaymentTo": "[SellerAccountId]",
"ApplicationFeePercent": "5",
"BillingType": "ChargeAutomatically",
"OnError": [
{
"Title": "Display Error Message",
"ActionType": "ShowError",
"Parameters": {
"Message": "<p>We couldn't start the subscription: [Stripe:ErrorMessage]</p>"
}
}
]
}
}

Revised 09/27/2026