website logo
⌘K
Getting Started
Introduction
Basic Concepts
Opening an Account
Creating & Configuring Products
Integrating SDK and Configuring License Fulfillment
Activate a Key-Based License
Vendor Platform
Issuing New Licenses
License Detail View
Order Detail View
Customer Detail View
Metadata
Analytics
Settings
Product Configuration
Product Features
Product Custom Fields
Product Versioning
License Policies
Product Bundles
License Entitlements
License Types
Activations & Device Transfers
Features
Custom Fields
License Start Date
License Note
Maintenance Period
Trial Licenses
Floating Licenses
License Activation Types
Portals
End-User Portal
Offline Portal
Air-Gapped Portal
License API
License API Authorization
License Activation/Deactivation
License Check
Consumption
Floating
Trial Key
Product Details
Device Variables
Changing Password
Management API
Making API Requests
Management API Authorization
Customer
Product
Order
License
Device
Analytics
SDKs
Tutorials
.NET/C# SDK
.NET/C# Management SDK
C++ SDK
Java SDK
Python SDK
Go SDK
Delphi SDK
Swift/Objective-C SDK
Android SDK
Unity SDK
Errors and Response Codes
Floating Server
API Reference
Deployment
Configuration
Floating Server UI
Securing the Server
Whitelabeling
FAQ
Floating Server Changelog
Integrations
Salesforce
FastSpring
Stripe
Shopify
Common Scenarios
Single Sign On (SSO)
Glossary
General
SDK Glossary
Vendor Platform
Product Configuration Glossary
License Configuration
Postman Collections
Frequently Asked Questions
Changelog
License API changelog
Platform changelog
Docs powered by
Archbee
Integrations
Stripe

Stripe Integration

22min

This guide covers typical scenarios in which Stripe integrates with LicenseSpring.

Implementation Steps

Follow these steps to configure licensing for products that you sell using Stripe:

  1. Create product in LicenseSpring platform
  2. Create product in Stripe dashboard
  3. Add custom attributes to the product price metadata
  4. Add webhook endpoint
  5. Add restricted api key from Stripe to LicenseSpring platform account
  6. Generate license keys

1. Create Product in LicenseSpring Platform

LicenseSpring product
LicenseSpring product


Product short code will be used to identify Stripe products with products defined in LicenseSpring.

All default products fields from LicenseSpring will be used as default license fields if no custom attributes are saved in Stripe product price metadata.

2. Create Product in Stripe Dashboard

On your Stripe dashboard go to Products -> Add product.

Stripe product
Stripe product


As a part of a product creation process in Stripe, you need to create a price for this product. If you select Recurring billing type, LicenseSpring integration will create subscription license type and use billing period from price settings as a valid duration in LicenseSpring. If you select One time billing type, LicenseSpring will use products default license type value or custom price attribute to set license type in LicenseSpring.

Creating initial product price settings
Creating initial product price settings


Click on Save product button in the top right corner of the screen to finish creating a product in Stripe.

3. Add Custom Attributes to the Product Price Metadata

To properly create licenses LicenseSpring will use product price metadata custom attributes. To add attributes to the price metadata, go to Product page and select the price which you want to customize.

Select product price
Select product price

Edit price metadata
Edit price metadata


3.1. License Policy

For every product in the LicenseSpring platform you can define one or many license policies which act as a template when creating licenses. License policy can be added to the Stripe products as a price metadata key license_policy with value of some license policy code. When order is being created via Stripe, our integration will take all the fields, product features and custom fields from included license policy and create the license based on those.

If license_policy attribute is not included Stripe integration will use default license policy for the product to create a license.

In case of subscription license_type will be always set as subscription and valid_duration period will use billing period from product price settings.

3.2. Custom Attributes

Custom attributes are used to overwrite fields from license policy and to handle some specific use cases which license policies don't cover. Note that short_code attribute is always required.

  • short_code - required. Add the product short code you configured LicenseSpring product with.
  • max_activations- optional, INT. If this field is not included, the default from the product configuration in LicenseSpring will be used.
  • floating_cloud - optional, INT. If this value is set licenses from this product will be created as floating cloud. This value also sets the total number of machines / users that can concurrently use a floating cloud license ( Max simultaneous license users value in LicenseSpring configuration ). Needs to be less than or equal to max activations attribute value.
  • license_type - optional, STRING. If this field is not included, the default license type from the product configuration in LicenseSpring is used (perpetual, time-limited, subscription,  consumption). For recurring product prices license type is always subscription.
  • valid_duration - optional, STRING. If this field is not included, the default valid_duration from the product configuration in LicenseSpring is used. The format for this is N[d/w/m/y] where N is number and option between d,w,m,y is possible (day, week, month, year - ex. "1y").Not applicable for subscription licenses.- subscription licenses will use billing period from product price settings.
  • enable_maintenance_duration - optional, BOOL. turns on maintenance capability. If not defined, default from LicenseSpring is used.
  • maintenance_duration  - optional, STRING behaves same as the valid_durationfield.
  • max_license_users  - optional, INT, limits the number of users which can be added to the licenses -. example: one license with multiple license users. Can be added only for products with user authorization method
  • is_license_manager - optional, BOOL, sets customer as a license manager. Useful on license-key based products where customer is not set as a license manager per default. If you are creating user based licenses, but do not want the customer to be assigned as a license manager, set this as false
  • assign_customer_as_user - optional, BOOL, customer will be automatically assigned to the license as a license user. Can be added only for products with user authorization method

3.2.1 Single License

In your store, user can select different quantities for a product. Default behaviour is that multiple quantities will result in multiple licenses (both user and license-key based!). If instead, when user selects >1 quantity you want to make a SINGLE license that can be activated multiple times (for license-key based) or a SINGLE license that supports multiple users (for user-based licenses), you need to add this custom attribute: is_single_license- optional, BOOL

Single license product price inside the subscription cannot be replaced later with multiple license product price.

Price metadata
Price metadata


Create as many product price variations as you want. For example if you want to bundle a product with maintenance period and charge it more, create a new price, add related custom attributes to it and LicenseSpring integration will use them to create licenses based on that.

3.2.2 Max Simultaneous License Users From Quantity on a Single License

In case of single floating-cloud license, quantity can be used to determine max simultaneous license users instead of max_activations for license-key based or number of users for user based products. To enable this, please use this following combination of custom attributes on the product price:

floating_users_from_quantity : true

floating_cloud : 1

max_activations - optional, INT. If this field is not included, the default from the product configuration in Licensespring will be used.

4. Add Webhook Endpoint

LicenseSpring will listen to some events sent from Stripe to create orders and licenses in the platform. To enable this you need to create a Stripe webhook which will send those events to LicenseSpring server.

To create a webhook go to Developers -> Webhooks and click on Add endpoint button.

Webhook endpoint fields
Webhook endpoint fields


Webhook URL: https://api.licensespring.com/api/stripe?uuid={your_uuid_from_LS_platform}

To access your LS uuid key, go to LicenseSpring platform account -> Account Settings -> Keys and copy your key.

LicenseSpring uuid
LicenseSpring uuid


Select this events from the Events dropdown on webhook endpoint modal:

  • customer.subscription.created ( order and licenses will be created in LicenseSpring )
  • customer.subscription.deleted ( licenses from the subscription will be deactivated )
  • customer.subscription.updated ( licenses from the subscription will be updated with new values ( quantity, policy and trial changes ) )
  • invoice.payment_succeeded ( on successful payment licenses will be prolonged with new Expiration date written in license validity_period field )

All webhook events from Stripe are stored as "License history" and available in the platform as a "history log" for each license. This history log can be found under the "Usage report" for a license.

5. Add Restricted API Key from Stripe to LicenseSpring Platform Account

LicenseSpring needs limited access to your Stripe account to update Subscription metadata after order is created and to fetch and copy Customer from Stripe to LicenseSpring.

To enable this create restricted API key in your Stripe dashboard. Go to Developer -> API keys and click on a Create restricted key button.

Stripe restricted API key
Stripe restricted API key


The title of this key can be anything you like, but we recommend something relating to LicenseSpring. Set all permissions to Read except Subscriptions, Invoices and Stripe CLI permissions which need to be set to Write.

Save this key and add it to the LicenseSpring account by going to Account Settings -> Preferences. Copy the key to the Stripe secret key text field and click on the Save changes button.

Stripe secret key
Stripe secret key


6. Generate License Keys

License keys are generated only for products with license-key authorization method.

There are currently two ways how you can create licenses keys which will be then used for licensing your products.

a) Attaching to Metadata of the New Subscription (preferred)

If Stripe API will be used to create subscriptions, attach the generated license keys to the subscription metadata. LicenseSpring integration will use those keys to create licenses in the LicenseSpring platform. More about Stripe API subscriptions methods here: https://stripe.com/docs/api/subscriptions/create

To generate licenses please use this generate_licenses endpoint from our Management API https://docs.licensespring.com/docs/generate-license-key (OLD LINK)

Metadata format { "metadata": { "license_keys": { "{short_code_here}": ["G8HA-SRRZ-A6WK-TJWB", "GCUE-JSUQ-4X2K-P7PR"], "{if_more_products_another_short_code}": ["G8HA-SRRZ-A6WK-TJWA"] } } }

Instead of {short_code_here} placeholders add a product short code for which you want to use those license keys.

b) LicenseSpring Updates Subscription Metadata After Order Creation

If you are creating Stripe subscriptions and invoices ( in case of one time order, ex. perpetual licenses ) manually without the ability to create the subscription or invoice with prefilled metadata then LicenseSpring will detect that metadata doesn't contain keys for the product in question and it will generate them automatically. Upon order create is finished, subscriptions / invoice metadata on Stripe will be updated with those license keys.

To access them you can subscribe your application to Stripe customer.subscription_updated event in case of a subscription or invoice.updated event in case of a one time order.

Alternatively you can fetch the subscription or invoice afterwards using Stripe API.

License keys will be visible on Stripe dashboard on metadata section of the created subscription / invoice.

Subscription metadata
Subscription metadata


To send the license keys automatically to your customers user our Email notification policies to create and customize preferred email notifications.

LicenseSpring integration with Stripe supports subscription with single products only.



Updated 05 Sep 2023
Did this page help you?
PREVIOUS
Stripe
NEXT
Shopify
Docs powered by
Archbee
TABLE OF CONTENTS
Implementation Steps
1. Create Product in LicenseSpring Platform
2. Create Product in Stripe Dashboard
3. Add Custom Attributes to the Product Price Metadata
3.1. License Policy
3.2. Custom Attributes
4. Add Webhook Endpoint
5. Add Restricted API Key from Stripe to LicenseSpring Platform Account
6. Generate License Keys
a) Attaching to Metadata of the New Subscription (preferred)
b) LicenseSpring Updates Subscription Metadata After Order Creation
Docs powered by
Archbee