Stripe Create Subscription
Audience:
Low-code EngineersSkill 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.
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
- Take a one-time payment. Use Stripe Checkout.
- Create the plan or the customer. Use Stripe Create Plan and Stripe Create Customer first.
- Change, pause or cancel a subscription. There's no action for this. Use the Stripe Dashboard.
- Find out if the first payment went through. The action doesn't return the subscription status. See Payment and incomplete subscriptions.
Related Actions
| Action Name | Description |
|---|---|
| Stripe Create Plan | Creates the plan to subscribe to. |
| Stripe Create Customer | Creates the customer and saves their card. |
| Stripe Get Event Details | Reads Stripe webhook events, for example to learn that a subscription payment failed. |
| Stripe Add Seller | Connects a seller's Stripe account to your platform. |
| Get Stripe User Account | Finds the ID of a connected account, for Payment To. |
| Add Stripe Connector | Creates the Stripe connector this action uses. |
| Create Subscription | Creates a recurring subscription in Authorize.Net instead. |
| Run SQL Query | Saves the subscription ID in your database. |
Input Parameter Reference
| Parameter | Description | Supports Tokens | Default | Required |
|---|---|---|---|---|
| API Connector | The Stripe connector with the secret key to use. See Add Stripe Connector. When using an expression, the value must be the connector ID. | Yes | none | Yes |
| Customer ID | The ID of the Stripe customer, for example cus_.... | Yes | empty string | Yes |
| Plan ID | The ID of the Stripe plan, for example plan_... from [Stripe:PlanId]. | Yes | empty string | Yes |
| Coupon ID | The ID of a Stripe coupon to apply to the subscription. Leave it empty for no discount. | Yes | empty string | No |
| Payment To | The 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. | Yes | empty string | No |
| Application Fee Percentage | The 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. | Yes | empty string | No |
| Tax Percentage | The tax percentage added to each invoice, with a dot for decimals. For example, a 10.00 plan with 20.0 bills 12.00. | Yes | empty string | No |
| Billing Type | Charge Automatically charges the customer's default payment method. Send Invoice has Stripe email the customer an invoice to pay. | No | Charge Automatically | No |
| Days Until Due | The 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. | Yes | empty string | Yes, with Send Invoice |
| On Success | Actions that run after Stripe creates the subscription. | No | empty list | No |
| On Error | Actions that run when Stripe rejects the request. The reason is in [Stripe:ErrorMessage]. | No | empty list | No |
The subscription always has a quantity of 1.
Output Parameters Reference
The tokens are set before On Success or On Error runs.
| Parameter | Description |
|---|---|
[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
- If
Billing TypeisSend InvoiceandDays Until Dueis less than1, the action raises an error right away.On Errordoesn't run for this. - It reads
Application Fee PercentageandTax Percentageas numbers. A value that isn't a number raises an error, andOn Errordoesn't run for it either. - It sends the subscription to Stripe with the connector's secret key, on the
Payment Toaccount if one is set. - On success, it sets
[Stripe:SubscriptionId]and runsOn Success. - If Stripe rejects the request, for example because the customer or plan doesn't exist, it sets
[Stripe:ErrorMessage]and runsOn Error. IfOn Erroris 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 IDandCoupon IDmust exist on the connected account. Customers and plans from your platform account aren't found. Application Fee Percentageis 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 IDandPayment Tofrom 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
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