Skip to main content

Getting Started

This guide shows how easy it is to get started with Subscription Management. Follow all the steps or jump to where you are in the process.

1. Connect your Stripe Account

Subscription Management uses your Stripe account as a backend for all data. All your products as well as future customers and subscriptions will be stored and handled directly within Stripe.

caution

The Subscription Management app will have full access to your Stripe account. If you already have a Stripe account then we recommended you create a separate account solely for this purpose.

2. Setup Stripe Product & Price

Subscription Management uses Stripe Product to represent Publisher's proposition to customers. Please follow documentation from Stripe to set it up. As for now Subscription Management supports Standard, Package and Graduated pricing models. Volume ("metered") one is in a pipeline.

info

To extend your product pricing options (by currencies and billing intervals), just add a new price with the same name. Please check our Stripe Schema documentation to get more information about how to set up the Stripe configuration implemented in Subscription Management.

3. Installing dependencies

Subscription Management is a separate extension which you use as a dependency app for each extension you would like to monetize.
  1. Install Subscription Management extension into your cloud development environment.
  2. Add a dependency to your extension's app.json.
dependencies
{
"id": "6717135a-d80c-4a63-8a3a-5ded6717135a",
"publisher": "Theta Systems Limited",
"name": "SubscriptionMgt",
"version": "1.0.0.0"
}

4. Basic Integration

Use TryAddProduct API to enable Subscription Management to handle your extension monetization. We recommend executing it during installation and upgrade of your extension to the tenant.

Example
SubscriptionMgtProxy.Codeunit.al
codeunit 50000 SubscriptionMgtProxy
{
[NonDebuggable]
internal procedure AddProduct()
var
SubscriptionMgt: Codeunit SubscriptionMgt_SM_TSL;
Info: ModuleInfo;
TryAddProductErr: Label 'Failed to register product.';
begin
if NavApp.GetCurrentModuleInfo(Info) then
if SubscriptionMgt.TryAddProduct(
GetSecret('StripeSecretKey'),
GetSecret('StripePublishableKey'),
Info,
GetSecret('StripeProductID'))
then
exit;
LogError('SubscriptionMgtProxy-0001', TryAddProductErr)
end;

[NonDebuggable]
local procedure GetSecret(Name: Text) Result: Text
var
SecretProvider: Codeunit "App Key Vault Secret Provider";
GetSecretErr: Label 'Failed to get ''%1'' secret.', Comment = '%1 - Secret Name';
begin
// TODO: Can be replaced with your own secret provider
if SecretProvider.TryInitializeFromCurrentApp() then
if SecretProvider.GetSecret(Name, Result) then
exit;
LogError('SubscriptionMgtProxy-0002', GetSecretErr)
end;

local procedure LogError(EventId: Text; Message: Text)
var
CustDimension: Dictionary of [Text, Text];
begin
// TODO: Can be replaced with Error if installation error is acceptable.
LogMessage(
EventId,
Message,
Verbosity::Critical,
DataClassification::EndUserPseudonymousIdentifiers,
TelemetryScope::ExtensionPublisher,
CustDimension)
end;
}
info

To block your customers from using your application without an account you can use a combination of IsActive/ShowNotification within your application UX entry points or use them to control extension-specific ApplicationArea if such has been defined.