Integrations
Stripe

Stripe Integration

24min

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. Creating payment
  7. Generate License Keys



1. Create product in LicenseSpring platform

  1. Log in to https://saas.licensespring.com/login
  2. Go to Configure Products → Add new Product and create a new product
Document image




Document image




2. Create product in Stripe dashboard

  1. Log in to your Stripe dashboard and go to Products → Add product
  2. 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.
  3. Click on Save product button in the top right corner of the screen to finish creating a product in Stripe.



Document image




Document image




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_duration field.
  • 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
  • unpaid_active_license_period - optional, STRING, used to define a period during which the licenses remain active even if they haven't been paid for yet. The format for this is N[d/w/m/y] where N is a number and d, w, m, or y represents days, weeks, months or years respectively (e.g., "3d" for 3 days)



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

Product price metadata
Product price metadata




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.



3.2.3. Product Bundles

Product bundle is a unique type of product in LicenseSpring that requires specific configuration. This section outlines all the currently available Product Attributes for product bundles and instructions on how to use them.

Only one product bundle can be processed per order. Multiple quantities of the same product bundle are supported; however, including two or more different product bundles in the same order on Stripe is not supported.

How to set up product bundles in LicenseSpring?

  1. Go to the Products section in LicenseSpring platform
  2. Click the Add new bundle button

    Document image
    
  3. Insert the desired Bundle name and Bundle code, choose which Authorization method to use, and finally, select all the products that you want inside the bundle

    Document image
    
  4. After the bundle is created, it should look something like the following picture. Take the Bundle code value and use it as the short_code in the Stripe configuration. (Look at the list below to see all the available Product attributes for bundle products)

    Document image
    



All other setup steps are the same as they are for basic Products. The only difference is in the supported Product attributes.

If a product bundle contains, for example, three products, then four licenses will be created in LicenseSpring. One license will be for the bundle itself, which can be used for all products within the bundle. The remaining three licenses will be created for each individual product in the bundle. The value of these individual licenses is determined by the default license policy of each product.

Each license will include the features defined in the default license policy of the product for which the license was created.



Product Attributes

  • is_product_bundle - required, BOOLEAN, has to be set to true
  • short_code - required, with the code you configured LicenseSpring Product Bundle with
  • max_activations  - optional, INT. If this field is not included, the value from the default license policy on the product in Licensespring will be used.
  • floating_cloud - optional, INT. If this value is set licenses from this product bundle 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 of each product inside the bundle configuration in LicenseSpring is used (perpetualtime-limitedsubscription, consumption). For subscription products license type is always subscription.
  • valid_duration - optional, STRING. If this field is not included, the default valid_duration of each product inside the bundle 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). Applicable for time-limited licenses only.
  • maintenance_duration- optional, STRING behaves same as the valid_duration field
  • enable_maintenance_duration- optional, turns on maintenance capability. If not defined, default from LS is used
  • 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, sets customer as a license manager. Useful on license-key or user-based products where the customer is not set as a license manager by default.
  • 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
  • unpaid_active_license_period - optional, STRING, used to define a period during which the licenses remain active even if they haven't been paid for yet. The format for this is N[d/w/m/y] where N is a number and d, w, m, or y represents days, weeks, months or years respectively (e.g., "3d" for 3 days)



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.



Document image

Document image


Endpoint URL will be

https://integrations.licensespring.com/api/stripe?uuid={uuid}

Example URL

https://integrations.licensespring.com/api/stripe?uuid=12345678-7121-6bcb-a355-bbd6b6df0b84

To retrieve the uuid (api-key) go to LicenseSpring → Settings → Keys

Document image




Select these Events to listen to:

  • 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)
  • charge.refunded (licenses associated with the refunded charge will be disabled)



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 the Create restricted key button.



Document image


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 Settings -> Integrations.

Press Activate for Stripe.

Document image


Copy the key to the Stripe secret key text field.

Select the Management API key and License API key (uuid) that you want to use.

The License API key (uuid) needs to be the same as the one you used for the webhook endpoint

Document image


6. Creating payment

a) One-time products

With invoices

Document image


To generate an invoice, first select your customer and item (a one-time product). Then, set the payment collection method to 'Autocharge Customer.' Once you've reviewed everything, you can proceed to charge the customer.

Document image




With payment link

In the right upper corner click on the '+' sign and then on Payment Link

Document image


Once the page for payment link creation opens, firstly select the one-time product price for which you want to create the link



Document image


After you've selected the product click on After payment!

Make sure to select the 'Create an invoice PDF' checkbox.

Document image


b) subscription licenses

When dealing with subscription products, you should utilize a payment link. To do so, first choose 'Payment Link,' then select the product, and finally create the link.

Document image




Acessing link and making payment
Acessing link and making payment


After creating the link, access it to complete the payment process.

7. Generate License Keys

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

To generate licenses please use this generate_licenses endpoint from our Management API

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