This library provides a .NET client to interact with Stigg’s GraphQL API based on API operations that are in use by the Stigg’s Node.js SDK
Under the hood, it leverages Strawberry Shake to generate C# classes for GraphQL types.
The first step is to add the SDK as a dependency in your .NET application, Stigg package is published as a Nuget package
dotnet add package Stigg.Api.Client
It’s recommended to hard code the stigg-api-dot-net
version according to the latest version available here.
In the Stigg app, go to Settings > Account > Environments.
Copy the Server API key of the relevant environment.
Import the Stigg client and initialize it with the API key.
Synchronous client:
using Stigg.Api.Client;
class App {
public static void main() {
var stigg = Stigg.createClient("<SERVER-API-KEY>");
}
}
When a new customer is provisioned within your application (for example: as part of your registration or onboarding process), you should also provision them in Stigg.
The customer’s billing information can also be passed to Stigg when a customer is created or updated. When Stigg is integrated with additional service, this information will be propagated to the active integrations. The billing information is not persisted on Stigg’s servers.
You can optionally pass subscriptionParams
to create subscription for that customer using a single operation. Doing so, will allow Stigg admins to override the requested subscription with no-code from the Stigg Console using the product’s Customer Journey configuration.
var resp = await stigg.ProvisionCustomer.ExecuteAsync(new ProvisionCustomerInput()
{
CustomerId= "customer-81726628184",
Name = "Acme",
Email = "john@example.com",
SubscriptionParams = new ProvisionCustomerSubscriptionInput()
{
PlanId = "plan-revvenu-basic"
}
});
Show Result
{
"provisionCustomer": {
"customer": {
"__typename": "Customer",
"slimCustomerFragment": {
"id": "4168b1ed-56de-41fe-9382-4d9eaf45e161",
"name": "Acme",
"email": "john@example.com",
"createdAt": "2023-11-20T22:39:19.840Z",
"updatedAt": "2023-11-20T22:39:19.840Z",
"refId": "customer-5162641",
"customerId": "customer-5162641",
"billingId": null,
"additionalMetaData": {
"key": "value"
}
}
},
"subscriptionDecisionStrategy": {
"rawValue": "REQUESTED_PLAN"
},
"subscription": {
"__typename": "CustomerSubscription",
"slimSubscriptionFragment": {
"id": "e09b03a6-d0ec-4d6b-b184-1b897981283e",
"refId": "subscription-plan-revvenu-basic-tctmtyrvfv",
"status": {
"rawValue": "ACTIVE"
},
"additionalMetaData": null,
"billingId": null,
"billingLinkUrl": null,
"effectiveEndDate": null,
"currentBillingPeriodEnd": "2023-12-20T22:39:19.893Z",
"pricingType": {
"rawValue": "FREE"
},
"latestInvoice": null,
"paymentCollection": {
"rawValue": "NOT_REQUIRED"
},
"billingSyncError": null,
"resource": null,
"experimentInfo": null,
"prices": [],
"totalPrice": null,
"plan": {
"id": "bad48997-2aec-4f01-bfa5-534e80826c0e",
"refId": "plan-revvenu-basic"
},
"addons": [],
"customer": {
"id": "4168b1ed-56de-41fe-9382-4d9eaf45e161",
"refId": "customer-5162641"
}
}
}
}
}
Customer information can also be updated whenever you like assuming it already exists, for example: In order to update the customer’s email, you only need to send the new email value without the rest of the customer. Due to the fact that the customer’s billing information is not persisted on Stigg’s servers, in order to update it, the entire billing information object must be passed each time.
var res = await stigg.UpdateCustomer.ExecuteAsync(new UpdateCustomerInput()
{
CustomerId = "customer-demo-01",
Name = "Acme",
Email = "john@example.com",
});
Show Result
{
"updateCustomer": {
"__typename": "Customer",
"slimCustomerFragment": {
"id": "a7b2a41b-1f2c-40ab-b639-ef345e5adf17",
"name": "Acme",
"email": "john@example.com",
"createdAt": "2023-11-21T14:14:50.386Z",
"updatedAt": "2023-11-21T14:30:07.487Z",
"refId": "customer-demo-01",
"customerId": "customer-demo-01",
"billingId": null,
"additionalMetaData": {
"key": "value"
}
}
}
}
var res = await stigg.GetCustomerById.ExecuteAsync(new GetCustomerByRefIdInput()
{
CustomerId = "customer-demo-01",
});
Show Result
{
"getCustomerByRefId": {
"__typename": "Customer",
"customerWithSubscriptionsFragment": {
"__typename": "Customer",
"subscriptions": [
{
"__typename": "CustomerSubscription",
"subscriptionFragment": {
"id": "ed2696e4-e840-47b8-af7b-a0babbf1a464",
"startDate": "2023-10-21T13:14:45.992Z",
"endDate": null,
"trialEndDate": null,
"cancellationDate": null,
"effectiveEndDate": null,
"status": {
"rawValue": "ACTIVE"
},
"refId": "subscription-plan-revvenu-basic-g6d4kugtyp",
"currentBillingPeriodEnd": "2023-12-21T13:14:45.992Z",
"additionalMetaData": null,
"billingId": null,
"billingLinkUrl": null,
"latestInvoice": null,
"paymentCollection": {
"rawValue": "NOT_REQUIRED"
},
"billingSyncError": null,
"resource": null,
"experimentInfo": null,
"prices": [],
"totalPrice": null,
"pricingType": {
"rawValue": "FREE"
},
"plan": {
"__typename": "Plan",
"planFragment": {
"id": "05a09259-dcb8-47ca-a447-571a2835e694",
"refId": "plan-revvenu-basic",
"displayName": "Basic",
"description": null,
"billingId": "prod_P30kaef2AIphhb",
"versionNumber": 1,
"additionalMetaData": null,
"product": {
"__typename": "Product",
"productFragment": {
"refId": "product-revvenu",
"displayName": "Revvenu",
"description": null,
"additionalMetaData": {
"recommendedPlan": "plan-revvenu-essentials"
},
"productSettings": {
"downgradePlan": null
}
}
},
"basePlan": null,
"entitlements": [
{
"__typename": "PackageEntitlement",
"packageEntitlementFragment": {
"usageLimit": 3,
"hasUnlimitedUsage": null,
"featureId": "109e38e3-fa95-40d2-94a7-730b2bce0e87",
"resetPeriod": null,
"hiddenFromWidgets": [],
"isCustom": null,
"displayNameOverride": null,
"feature": {
"featureType": {
"rawValue": "NUMBER"
},
"meterType": {
"rawValue": "Fluctuating"
},
"featureUnits": "template",
"featureUnitsPlural": "templates",
"displayName": "Templates",
"description": null,
"refId": "feature-01-templates",
"additionalMetaData": null
}
}
},
{
"__typename": "PackageEntitlement",
"packageEntitlementFragment": {
"usageLimit": 4,
"hasUnlimitedUsage": null,
"featureId": "cce3f1fe-494e-472a-919d-5135bb932349",
"resetPeriod": {
"rawValue": "MONTH"
},
"hiddenFromWidgets": [],
"isCustom": null,
"displayNameOverride": null,
"feature": {
"featureType": {
"rawValue": "NUMBER"
},
"meterType": {
"rawValue": "Incremental"
},
"featureUnits": "campaign",
"featureUnitsPlural": "campaigns",
"displayName": "Campaigns",
"description": null,
"refId": "feature-02-campaigns",
"additionalMetaData": null
}
}
},
{
"__typename": "PackageEntitlement",
"packageEntitlementFragment": {
"usageLimit": 1000,
"hasUnlimitedUsage": null,
"featureId": "c8947bb3-c480-46a9-bdb3-9babe145921b",
"resetPeriod": {
"rawValue": "MONTH"
},
"hiddenFromWidgets": [],
"isCustom": null,
"displayNameOverride": null,
"feature": {
"featureType": {
"rawValue": "NUMBER"
},
"meterType": {
"rawValue": "Incremental"
},
"featureUnits": "active user",
"featureUnitsPlural": "active users",
"displayName": "Active users",
"description": null,
"refId": "feature-07-active-users",
"additionalMetaData": null
}
}
},
{
"__typename": "PackageEntitlement",
"packageEntitlementFragment": {
"usageLimit": 5,
"hasUnlimitedUsage": null,
"featureId": "8743a7be-3778-4b33-9036-dd1f9d7fff08",
"resetPeriod": null,
"hiddenFromWidgets": [],
"isCustom": null,
"displayNameOverride": "5MB file size limit",
"feature": {
"featureType": {
"rawValue": "NUMBER"
},
"meterType": {
"rawValue": "None"
},
"featureUnits": "MB",
"featureUnitsPlural": "MB",
"displayName": "Max file size",
"description": null,
"refId": "feature-06-max-file-size",
"additionalMetaData": null
}
}
}
],
"inheritedEntitlements": [],
"compatibleAddons": [],
"prices": [],
"pricingType": {
"rawValue": "FREE"
},
"defaultTrialConfig": null
}
},
"addons": [],
"scheduledUpdates": [],
"futureUpdates": []
}
}
],
"customerFragment": {
"__typename": "Customer",
"hasPaymentMethod": false,
"hasActiveSubscription": true,
"defaultPaymentExpirationMonth": null,
"defaultPaymentExpirationYear": null,
"defaultPaymentMethodLast4Digits": null,
"trialedPlans": [],
"experimentInfo": null,
"coupon": null,
"eligibleForTrial": [],
"promotionalEntitlements": [
{
"__typename": "PromotionalEntitlement",
"promotionalEntitlementFragment": {
"status": {
"rawValue": "Active"
},
"usageLimit": null,
"featureId": "56141e76-9a3f-4d16-b76f-e30228f98a22",
"hasUnlimitedUsage": null,
"resetPeriod": null,
"endDate": null,
"isVisible": true,
"feature": {
"featureType": {
"rawValue": "BOOLEAN"
},
"meterType": {
"rawValue": "None"
},
"featureUnits": null,
"featureUnitsPlural": null,
"displayName": "Custom domain",
"description": null,
"refId": "feature-03-custom-domain",
"additionalMetaData": null
}
}
}
],
"slimCustomerFragment": {
"id": "a7b2a41b-1f2c-40ab-b639-ef345e5adf17",
"name": "Acme",
"email": "john@example.com",
"createdAt": "2023-11-21T14:14:50.386Z",
"updatedAt": "2023-11-21T16:14:35.415Z",
"refId": "customer-demo-01",
"customerId": "customer-demo-01",
"billingId": null,
"additionalMetaData": {
"key": "value"
}
}
}
}
}
}
var res = await stigg.GetActiveSubscriptionsList.ExecuteAsync(new GetActiveSubscriptionsInput()
{
CustomerId = "customer-demo-01",
ResourceId = "site-1" // optional resource ID
});
Show Result
{
"getActiveSubscriptions": [
{
"__typename": "CustomerSubscription",
"slimSubscriptionFragmentV2": {
"startDate": "2023-11-21T16:26:11.000Z",
"status": {
"rawValue": "ACTIVE"
},
"subscriptionId": "subscription-plan-revvenu-essentials-cd0ba9",
"currentBillingPeriodEnd": "2023-12-21T16:26:30.000Z",
"resource": null,
"pricingType": {
"rawValue": "PAID"
},
"plan": {
"planId": "plan-revvenu-essentials",
"displayName": "Essentials",
},
"addons": [
{
"quantity": 2,
"addon": {
"addonId": "addon-10-campaigns",
}
}
],
}
}
]
}
To retrieve extended subscription data:
var res = await stigg.GetSubscription.ExecuteAsync(new GetSubscriptionInput()
{
SubscriptionId = "subscription-id",
});
Show Result
{
"getSubscription": {
"__typename": "CustomerSubscription",
"subscriptionFragment": {
"id": "b8b48c70-df8a-460c-b5f9-2276a5854a03",
"startDate": "2023-11-21T16:26:11.000Z",
"endDate": null,
"trialEndDate": null,
"cancellationDate": null,
"effectiveEndDate": null,
"status": {
"rawValue": "ACTIVE"
},
"refId": "subscription-plan-revvenu-essentials-cd0ba9",
"currentBillingPeriodEnd": "2023-12-21T16:26:30.000Z",
"additionalMetaData": null,
"billingId": "sub_1OEwmQAnAO1PFouUVaDluuRj",
"billingLinkUrl": "https://dashboard.stripe.com/test/subscriptions/sub_1OEwmQAnAO1PFouUVaDluuRj",
"latestInvoice": {
"__typename": "SubscriptionInvoice",
"subscriptionInvoiceFragment": {
"billingId": "in_1OEwmQAnAO1PFouU8W9U6ldu",
"status": {
"rawValue": "PAID"
},
"createdAt": "2023-11-21T16:26:30.000Z",
"updatedAt": "2023-11-21T16:26:32.842Z",
"requiresAction": false,
"paymentUrl": "https://invoice.stripe.com/i/acct_1KxDMtAnAO1PFouU/test_YWNjdF8xS3hETXRBbkFPMVBGb3VVLF9QMzJzcDRKTGxJcGNucWhZOEJCd2ZheG9SZk5TOEdJLDkxMTI0Nzkz0200ZnGaOwnQ?s=ap",
"paymentSecret": "pi_3OEwmRAnAO1PFouU1Zg54ALZ_secret_28nQjBxmQnzVg0ISlvBC2eQJR",
"errorMessage": null
}
},
"paymentCollection": {
"rawValue": "NOT_REQUIRED"
},
"billingSyncError": null,
"resource": null,
"experimentInfo": null,
"prices": [
{
"usageLimit": 7,
"price": {
"__typename": "Price",
"priceFragment": {
"billingModel": {
"rawValue": "PER_UNIT"
},
"billingPeriod": {
"rawValue": "MONTHLY"
},
"billingId": "price_1OEuj0AnAO1PFouUPwz1QA7U",
"minUnitQuantity": 5,
"maxUnitQuantity": null,
"billingCountryCode": null,
"price": {
"amount": 6,
"currency": {
"rawValue": "USD"
}
},
"tiersMode": null,
"tiers": null,
"feature": {
"refId": "feature-01-templates",
"featureUnits": "template",
"featureUnitsPlural": "templates",
"displayName": "Templates",
"description": null
}
}
}
}
],
"totalPrice": {
"__typename": "CustomerSubscriptionTotalPrice",
"totalPriceFragment": {
"subTotal": {
"amount": 52,
"currency": {
"rawValue": "USD"
}
},
"total": {
"amount": 52,
"currency": {
"rawValue": "USD"
}
}
}
},
"pricingType": {
"rawValue": "PAID"
},
"plan": {
"__typename": "Plan",
"planFragment": {
"id": "7a3979c1-c553-4338-a5b3-c7523bec288f",
"refId": "plan-revvenu-essentials",
"displayName": "Essentials",
"description": null,
"billingId": "prod_P30kP9lB01YaiE",
"versionNumber": 1,
"additionalMetaData": null,
"product": {
"__typename": "Product",
"productFragment": {
"refId": "product-revvenu",
"displayName": "Revvenu",
"description": null,
"additionalMetaData": {
"recommendedPlan": "plan-revvenu-essentials"
},
"productSettings": {
"downgradePlan": null
}
}
},
"basePlan": {
"refId": "plan-revvenu-basic",
"displayName": "Basic"
},
"entitlements": [
{
"__typename": "PackageEntitlement",
"packageEntitlementFragment": {
"usageLimit": 12,
"hasUnlimitedUsage": null,
"featureId": "cce3f1fe-494e-472a-919d-5135bb932349",
"resetPeriod": {
"rawValue": "MONTH"
},
"hiddenFromWidgets": [],
"isCustom": null,
"displayNameOverride": null,
"feature": {
"featureType": {
"rawValue": "NUMBER"
},
"meterType": {
"rawValue": "Incremental"
},
"featureUnits": "campaign",
"featureUnitsPlural": "campaigns",
"displayName": "Campaigns",
"description": null,
"refId": "feature-02-campaigns",
"additionalMetaData": null
}
}
},
{
"__typename": "PackageEntitlement",
"packageEntitlementFragment": {
"usageLimit": 25000,
"hasUnlimitedUsage": null,
"featureId": "c8947bb3-c480-46a9-bdb3-9babe145921b",
"resetPeriod": {
"rawValue": "MONTH"
},
"hiddenFromWidgets": [],
"isCustom": null,
"displayNameOverride": null,
"feature": {
"featureType": {
"rawValue": "NUMBER"
},
"meterType": {
"rawValue": "Incremental"
},
"featureUnits": "active user",
"featureUnitsPlural": "active users",
"displayName": "Active users",
"description": null,
"refId": "feature-07-active-users",
"additionalMetaData": null
}
}
},
{
"__typename": "PackageEntitlement",
"packageEntitlementFragment": {
"usageLimit": 100,
"hasUnlimitedUsage": null,
"featureId": "8743a7be-3778-4b33-9036-dd1f9d7fff08",
"resetPeriod": null,
"hiddenFromWidgets": [],
"isCustom": null,
"displayNameOverride": "100MB file size limit",
"feature": {
"featureType": {
"rawValue": "NUMBER"
},
"meterType": {
"rawValue": "None"
},
"featureUnits": "MB",
"featureUnitsPlural": "MB",
"displayName": "Max file size",
"description": null,
"refId": "feature-06-max-file-size",
"additionalMetaData": null
}
}
},
{
"__typename": "PackageEntitlement",
"packageEntitlementFragment": {
"usageLimit": null,
"hasUnlimitedUsage": null,
"featureId": "0937bf25-2fec-457b-a1f5-bd470396a100",
"resetPeriod": null,
"hiddenFromWidgets": [],
"isCustom": null,
"displayNameOverride": null,
"feature": {
"featureType": {
"rawValue": "BOOLEAN"
},
"meterType": {
"rawValue": "None"
},
"featureUnits": null,
"featureUnitsPlural": null,
"displayName": "Analytics",
"description": null,
"refId": "feature-04-analytics",
"additionalMetaData": null
}
}
}
],
"inheritedEntitlements": [],
"compatibleAddons": [
{
"__typename": "Addon",
"addonFragment": {
"id": "59b81b8b-7bff-4b00-9ede-c5c9b9544500",
"refId": "addon-10-campaigns",
"billingId": "prod_P30kizGUa6097e",
"displayName": "10 campaigns",
"description": "Additional quota of 10 campaigns",
"additionalMetaData": null,
"entitlements": [
{
"__typename": "PackageEntitlement",
"packageEntitlementFragment": {
"usageLimit": 10,
"hasUnlimitedUsage": null,
"featureId": "cce3f1fe-494e-472a-919d-5135bb932349",
"resetPeriod": {
"rawValue": "MONTH"
},
"hiddenFromWidgets": [],
"isCustom": null,
"displayNameOverride": null,
"feature": {
"featureType": {
"rawValue": "NUMBER"
},
"meterType": {
"rawValue": "Incremental"
},
"featureUnits": "campaign",
"featureUnitsPlural": "campaigns",
"displayName": "Campaigns",
"description": null,
"refId": "feature-02-campaigns",
"additionalMetaData": null
}
}
}
],
"prices": [
{
"__typename": "Price",
"priceFragment": {
"billingModel": {
"rawValue": "FLAT_FEE"
},
"billingPeriod": {
"rawValue": "MONTHLY"
},
"billingId": "price_1OEuizAnAO1PFouUJwetn2ZQ",
"minUnitQuantity": null,
"maxUnitQuantity": null,
"billingCountryCode": null,
"price": {
"amount": 5,
"currency": {
"rawValue": "USD"
}
},
"tiersMode": null,
"tiers": null,
"feature": null
}
},
{
"__typename": "Price",
"priceFragment": {
"billingModel": {
"rawValue": "FLAT_FEE"
},
"billingPeriod": {
"rawValue": "ANNUALLY"
},
"billingId": "price_1OEuizAnAO1PFouUulgWldtN",
"minUnitQuantity": null,
"maxUnitQuantity": null,
"billingCountryCode": null,
"price": {
"amount": 54,
"currency": {
"rawValue": "USD"
}
},
"tiersMode": null,
"tiers": null,
"feature": null
}
}
],
"pricingType": {
"rawValue": "PAID"
}
}
}
],
"prices": [
{
"__typename": "Price",
"priceFragment": {
"billingModel": {
"rawValue": "PER_UNIT"
},
"billingPeriod": {
"rawValue": "ANNUALLY"
},
"billingId": "price_1OEuj0AnAO1PFouUlmmaUgsh",
"minUnitQuantity": 5,
"maxUnitQuantity": null,
"billingCountryCode": null,
"price": {
"amount": 60,
"currency": {
"rawValue": "USD"
}
},
"tiersMode": null,
"tiers": null,
"feature": {
"refId": "feature-01-templates",
"featureUnits": "template",
"featureUnitsPlural": "templates",
"displayName": "Templates",
"description": null
}
}
},
{
"__typename": "Price",
"priceFragment": {
"billingModel": {
"rawValue": "PER_UNIT"
},
"billingPeriod": {
"rawValue": "MONTHLY"
},
"billingId": "price_1OEuj0AnAO1PFouUPwz1QA7U",
"minUnitQuantity": 5,
"maxUnitQuantity": null,
"billingCountryCode": null,
"price": {
"amount": 6,
"currency": {
"rawValue": "USD"
}
},
"tiersMode": null,
"tiers": null,
"feature": {
"refId": "feature-01-templates",
"featureUnits": "template",
"featureUnitsPlural": "templates",
"displayName": "Templates",
"description": null
}
}
}
],
"pricingType": {
"rawValue": "PAID"
},
"defaultTrialConfig": null
}
},
"addons": [
{
"id": "0a86b7b0-b85f-479f-abf9-e7e1167c251d",
"quantity": 2,
"addon": {
"__typename": "Addon",
"addonFragment": {
"id": "59b81b8b-7bff-4b00-9ede-c5c9b9544500",
"refId": "addon-10-campaigns",
"billingId": "prod_P30kizGUa6097e",
"displayName": "10 campaigns",
"description": "Additional quota of 10 campaigns",
"additionalMetaData": null,
"entitlements": [
{
"__typename": "PackageEntitlement",
"packageEntitlementFragment": {
"usageLimit": 10,
"hasUnlimitedUsage": null,
"featureId": "cce3f1fe-494e-472a-919d-5135bb932349",
"resetPeriod": {
"rawValue": "MONTH"
},
"hiddenFromWidgets": [],
"isCustom": null,
"displayNameOverride": null,
"feature": {
"featureType": {
"rawValue": "NUMBER"
},
"meterType": {
"rawValue": "Incremental"
},
"featureUnits": "campaign",
"featureUnitsPlural": "campaigns",
"displayName": "Campaigns",
"description": null,
"refId": "feature-02-campaigns",
"additionalMetaData": null
}
}
}
],
"prices": [
{
"__typename": "Price",
"priceFragment": {
"billingModel": {
"rawValue": "FLAT_FEE"
},
"billingPeriod": {
"rawValue": "MONTHLY"
},
"billingId": "price_1OEuizAnAO1PFouUJwetn2ZQ",
"minUnitQuantity": null,
"maxUnitQuantity": null,
"billingCountryCode": null,
"price": {
"amount": 5,
"currency": {
"rawValue": "USD"
}
},
"tiersMode": null,
"tiers": null,
"feature": null
}
},
{
"__typename": "Price",
"priceFragment": {
"billingModel": {
"rawValue": "FLAT_FEE"
},
"billingPeriod": {
"rawValue": "ANNUALLY"
},
"billingId": "price_1OEuizAnAO1PFouUulgWldtN",
"minUnitQuantity": null,
"maxUnitQuantity": null,
"billingCountryCode": null,
"price": {
"amount": 54,
"currency": {
"rawValue": "USD"
}
},
"tiersMode": null,
"tiers": null,
"feature": null
}
}
],
"pricingType": {
"rawValue": "PAID"
}
}
}
}
],
"scheduledUpdates": [],
"futureUpdates": []
}
}
}
When a customer subscribes to a new plan (for example: during an upgrade from a free plan to a paid plan, or downgrade from a higher tier to a lower tier), a subscription needs to be created in Stigg.
When provisioning of a paid subscription is attempted, Stigg is integrated with a billing solution and payment details have not been previously provided by the customer, Stigg will auto-magically redirect customers to a the billing solution’s checkout page. After the customer enters the required payment details in the presented checkout page, the relevant subscription will be created in both Stigg and the billing solution.
When no payment is required or when Stigg is not integrated with a billing solution, the subscription will be immediately created in Stigg.
When a customer subscribes to a new plan (free, paid, trial, etc.), provision a subscription in Stigg. The provision result can be a successfully created subscription, or a redirect link to stripe checkout in case payment is needed.
var res = await stigg.ProvisionSubscription.ExecuteAsync(new ProvisionSubscriptionInput()
{
CustomerId = "customer-demo-01",
PlanId = "plan-revvenu-essentials",
BillingPeriod = BillingPeriod.Monthly,
BillableFeatures = new List<BillableFeatureInput>()
{
new()
{
FeatureId = "feature-01-templates",
Quantity = 5
}
},
Addons = new List<SubscriptionAddonInput>()
{
new()
{
AddonId = "addon-extra-stuff",
Quantity = 5
}
},
});
Show Result - Success
{
"provisionSubscription": {
"checkoutUrl": null,
"status": {
"rawValue": "SUCCESS"
},
"subscription": {
"__typename": "CustomerSubscription",
"slimSubscriptionFragment": {
"id": "bad12052-32f1-4590-9230-911298c2d21b",
"refId": "subscription-plan-revvenu-essentials-bum2flivze",
"status": {
"rawValue": "ACTIVE"
},
"additionalMetaData": {
"key": "value"
},
"billingId": "sub_1OEwmQAnAO1PFouUVaDluuRj",
"billingLinkUrl": "https://dashboard.stripe.com/test/subscriptions/sub_1OEwmQAnAO1PFouUVaDluuRj",
"effectiveEndDate": null,
"currentBillingPeriodEnd": "2023-12-21T16:26:30.000Z",
"pricingType": {
"rawValue": "PAID"
},
"latestInvoice": {
"__typename": "SubscriptionInvoice",
"subscriptionInvoiceFragment": {
"billingId": "in_1OExBFAnAO1PFouUfLM3dpL9",
"status": {
"rawValue": "PAID"
},
"createdAt": "2023-11-21T16:52:09.000Z",
"updatedAt": "2023-11-21T16:52:58.491Z",
"requiresAction": false,
"paymentUrl": "https://invoice.stripe.com/i/acct_1KxDMtAnAO1PFouU/test_YWNjdF8xS3hETXRBbkFPMVBGb3VVLF9QMzNIamZCSm5IVEJ1TkhDVFNCa2kzcVRnZXllVlpNLDkxMTI2Mzc40200A5QhGfKJ?s=ap",
"paymentSecret": null,
"errorMessage": null
}
},
"paymentCollection": {
"rawValue": "NOT_REQUIRED"
},
"billingSyncError": null,
"resource": null,
"experimentInfo": null,
"prices": [
{
"usageLimit": 5,
"price": {
"__typename": "Price",
"priceFragment": {
"billingModel": {
"rawValue": "PER_UNIT"
},
"billingPeriod": {
"rawValue": "MONTHLY"
},
"billingId": "price_1OEuj0AnAO1PFouUPwz1QA7U",
"minUnitQuantity": 5,
"maxUnitQuantity": null,
"billingCountryCode": null,
"price": {
"amount": 6,
"currency": {
"rawValue": "USD"
}
},
"tiersMode": null,
"tiers": null,
"feature": {
"refId": "feature-01-templates",
"featureUnits": "template",
"featureUnitsPlural": "templates",
"displayName": "Templates",
"description": null
}
}
}
}
],
"totalPrice": {
"__typename": "CustomerSubscriptionTotalPrice",
"totalPriceFragment": {
"subTotal": {
"amount": 30,
"currency": {
"rawValue": "USD"
}
},
"total": {
"amount": 30,
"currency": {
"rawValue": "USD"
}
}
}
},
"plan": {
"id": "7a3979c1-c553-4338-a5b3-c7523bec288f",
"refId": "plan-revvenu-essentials"
},
"addons": [],
"customer": {
"id": "a7b2a41b-1f2c-40ab-b639-ef345e5adf17",
"refId": "customer-demo-01"
}
}
}
}
}
Show Result - Action required (3DS)
{
"provision_subscription": {
"subscription": {
"paymentCollection": {
"rawValue": "ACTION_REQUIRED"
},
"latestInvoice": {
"paymentUrl": "https...",
"paymentSecret": "secret",
}
}
}
}
Show Result - Payment failed
{
"provisionSubscription": {
"subscription": {
"paymentCollection": {
"rawValue": "FAILED"
},
"latestInvoice": {
"paymentUrl": "https...",
"errorMessage": "no sufficient funds"
}
}
}
}
Show Result - Checkout
{
"provisionSubscription": {
"checkoutUrl": "https://checkout.stripe.com/c/pay/cs_test_b1PKYNIzXFR3uejdj59M0BghDF4mNtL2MoHf6vipEpREAJPQ7zhR6rlJQG#fid2cGd2ZndsdXFsamtQa2x0cGBrYHZ2QGtkZ2lgYSc%2FY2RpdmApJ3Zxd2x1YERmZmpwa3EnPydkZmZxWjROfUFIcURrREo0VUNqcFAnKSdkdWxOYHwnPyd1blpxYHZxWjA0TnZpVjZCX11oMk9QUzxWcEpPRzN8cTZQXDZSSDRwcGRpQ3BiZ0w8NDY9PFZiX2REa0tHZzJDdXBHTD1caEN%2FQ3doS21Abn00REhDUH12cW50fW9rcHJ0NTVwVTxpdEFsMicpJ2N3amhWYHdzYHcnP3F3cGApJ2lkfGpwcVF8dWAnPydocGlxbFpscWBoJyknYGtkZ2lgVWlkZmBtamlhYHd2Jz9xd3BgeCUl",
"status": {
"rawValue": "PAYMENT_REQUIRED"
},
"subscription": null
}
}
skipTrial: true
parameter to the provisionSubscription()
method.Updating an existing subscription, this can be used to update the feature quantity that the customer is subscribed for or the add-ons.
var res = await stigg.UpdateSubscription.ExecuteAsync(new UpdateSubscriptionInput()
{
SubscriptionId = "subscription-plan-revvenu-essentials-cpzi7p2g09",
BillableFeatures = new List<BillableFeatureInput>()
{
new()
{
FeatureId = "feature-01-templates",
Quantity = 7
}
},
Addons = new List<SubscriptionAddonInput>()
{
new()
{
AddonId = "addon-extra-stuff",
Quantity = 5
}
},
});
Show Result
{
"updateSubscription": {
"__typename": "CustomerSubscription",
"slimSubscriptionFragment": {
"id": "bad12052-32f1-4590-9230-911298c2d21b",
"refId": "subscription-plan-revvenu-essentials-bum2flivze",
"status": {
"rawValue": "ACTIVE"
},
"additionalMetaData": {
"key": "value"
},
"billingId": "sub_1OEwmQAnAO1PFouUVaDluuRj",
"billingLinkUrl": "https://dashboard.stripe.com/test/subscriptions/sub_1OEwmQAnAO1PFouUVaDluuRj",
"effectiveEndDate": null,
"currentBillingPeriodEnd": "2023-12-21T16:26:30.000Z",
"pricingType": {
"rawValue": "PAID"
},
"latestInvoice": {
"__typename": "SubscriptionInvoice",
"subscriptionInvoiceFragment": {
"billingId": "in_1OExBFAnAO1PFouUfLM3dpL9",
"status": {
"rawValue": "PAID"
},
"createdAt": "2023-11-21T16:52:09.000Z",
"updatedAt": "2023-11-21T16:52:59.336Z",
"requiresAction": false,
"paymentUrl": "https://invoice.stripe.com/i/acct_1KxDMtAnAO1PFouU/test_YWNjdF8xS3hETXRBbkFPMVBGb3VVLF9QMzNIamZCSm5IVEJ1TkhDVFNCa2kzcVRnZXllVlpNLDkxMTI2Mzc50200GdQT8sqx?s=ap",
"paymentSecret": null,
"errorMessage": null
}
},
"paymentCollection": {
"rawValue": "NOT_REQUIRED"
},
"billingSyncError": null,
"resource": null,
"experimentInfo": null,
"prices": [
{
"usageLimit": 5,
"price": {
"__typename": "Price",
"priceFragment": {
"billingModel": {
"rawValue": "PER_UNIT"
},
"billingPeriod": {
"rawValue": "MONTHLY"
},
"billingId": "price_1OEuj0AnAO1PFouUPwz1QA7U",
"minUnitQuantity": 5,
"maxUnitQuantity": null,
"billingCountryCode": null,
"price": {
"amount": 6,
"currency": {
"rawValue": "USD"
}
},
"tiersMode": null,
"tiers": null,
"feature": {
"refId": "feature-01-templates",
"featureUnits": "template",
"featureUnitsPlural": "templates",
"displayName": "Templates",
"description": null
}
}
}
}
],
"totalPrice": {
"__typename": "CustomerSubscriptionTotalPrice",
"totalPriceFragment": {
"subTotal": {
"amount": 30,
"currency": {
"rawValue": "USD"
}
},
"total": {
"amount": 30,
"currency": {
"rawValue": "USD"
}
}
}
},
"plan": {
"id": "7a3979c1-c553-4338-a5b3-c7523bec288f",
"refId": "plan-revvenu-essentials"
},
"addons": [],
"customer": {
"id": "a7b2a41b-1f2c-40ab-b639-ef345e5adf17",
"refId": "customer-demo-01"
}
}
}
}
var res = await stigg.CancelSubscription.ExecuteAsync(new SubscriptionCancellationInput()
{
SubscriptionRefId = "subscription-plan-revvenu-essentials-cpzi7p2g09",
SubscriptionCancellationTime = SubscriptionCancellationTime.END_OF_BILLING_PERIOD, // optional
});
Show Result
{
"cancel_subscription": {
"id": "subscription-plan-revvenu-growth-589879",
"status": "CANCELED",
"metadata": null,
"billing_id": "sub_1LxD4TE1gVT2zwZVSav7tZvC",
"billing_link_url": "https:\/\/dashboard.stripe.com\/test\/subscriptions\/sub_1LxD4TE1gVT2zwZVSav7tZvC",
"effective_end_date": "2022-10-30T23:54:38.582Z",
"current_billing_period_end": "2022-11-26T17:07:17.000Z",
"pricing_type": "PAID",
"prices": [
{
"usage_limit": 2,
"price": {
"__typename": "Price",
"billing_model": "PER_UNIT",
"billing_period": "MONTHLY",
"price": {
"amount": 1,
"currency": "USD"
},
"feature": {
"__typename": "Feature",
"id": "feature-01-templates",
"feature_type": "NUMBER",
"meter_type": "Fluctuating",
"feature_units": "template",
"feature_units_plural": "templates",
"display_name": "Templates",
"description": null
}
}
}
],
"total_price": {
"sub_total": {
"amount": 17,
"currency": "USD"
},
"total": {
"amount": 17,
"currency": "USD"
}
},
"plan": {
"id": "plan-revvenu-growth"
},
"addons": [
{
"quantity": 3,
"addon": {
"id": "addon-10-campaigns"
}
}
],
"customer": {
"id": "customer-demo-01"
}
}
}
Subscription cancellation will take place according to the defined product behavior.
Used to check if the customer has access to a feature, the usage limit, and the current usage.
var resp = await stigg.GetEntitlement.ExecuteAsync(new FetchEntitlementQuery()
{
CustomerId = "customer-demo-01",
FeatureId = "feature-02-templates",
ResourceId = "site-1" // optional
});
Show Result
{
"entitlement": {
"__typename": "Entitlement",
"entitlementFragment": {
"isGranted": false,
"accessDeniedReason": {
"rawValue": "RequestedUsageExceedingLimit"
},
"customerId": null,
"resourceId": null,
"usageLimit": 5,
"hasUnlimitedUsage": false,
"currentUsage": 3,
"requestedUsage": 10,
"entitlementUpdatedAt": null,
"usageUpdatedAt": null,
"usagePeriodAnchor": null,
"usagePeriodStart": null,
"usagePeriodEnd": null,
"resetPeriod": null,
"resetPeriodConfiguration": null,
"feature": {
"__typename": "EntitlementFeature",
"featureFragment": {
"featureType": {
"rawValue": "NUMBER"
},
"meterType": {
"rawValue": "Fluctuating"
},
"featureUnits": "template",
"featureUnitsPlural": "templates",
"description": null,
"displayName": "Templates",
"refId": "feature-01-templates"
}
}
}
}
}
Used to check to what features the customer has access to, the usage limit , and the current usage of each entitlement.
var resp = await stigg.GetEntitlements.ExecuteAsync(new FetchEntitlementsQuery()
{
CustomerId = "customer-demo-01",
ResourceId = "site-1" // optional resource ID
});
Show Result
{
"entitlements": [
{
"__typename": "Entitlement",
"entitlementFragment": {
"isGranted": true,
"accessDeniedReason": null,
"customerId": null,
"resourceId": null,
"usageLimit": null,
"hasUnlimitedUsage": false,
"currentUsage": null,
"requestedUsage": null,
"entitlementUpdatedAt": null,
"usageUpdatedAt": null,
"usagePeriodAnchor": null,
"usagePeriodStart": null,
"usagePeriodEnd": null,
"resetPeriod": null,
"resetPeriodConfiguration": null,
"feature": {
"__typename": "EntitlementFeature",
"featureFragment": {
"featureType": {
"rawValue": "BOOLEAN"
},
"meterType": {
"rawValue": "None"
},
"featureUnits": null,
"featureUnitsPlural": null,
"description": null,
"displayName": "Analytics",
"refId": "feature-04-analytics"
}
}
}
},
{
"__typename": "Entitlement",
"entitlementFragment": {
"isGranted": true,
"accessDeniedReason": null,
"customerId": null,
"resourceId": null,
"usageLimit": 100,
"hasUnlimitedUsage": false,
"currentUsage": null,
"requestedUsage": null,
"entitlementUpdatedAt": null,
"usageUpdatedAt": null,
"usagePeriodAnchor": null,
"usagePeriodStart": null,
"usagePeriodEnd": null,
"resetPeriod": null,
"resetPeriodConfiguration": null,
"feature": {
"__typename": "EntitlementFeature",
"featureFragment": {
"featureType": {
"rawValue": "NUMBER"
},
"meterType": {
"rawValue": "None"
},
"featureUnits": "MB",
"featureUnitsPlural": "MB",
"description": null,
"displayName": "Max file size",
"refId": "feature-06-max-file-size"
}
}
}
},
{
"__typename": "Entitlement",
"entitlementFragment": {
"isGranted": true,
"accessDeniedReason": null,
"customerId": null,
"resourceId": null,
"usageLimit": 25000,
"hasUnlimitedUsage": false,
"currentUsage": 0,
"requestedUsage": null,
"entitlementUpdatedAt": null,
"usageUpdatedAt": 1700595037.13,
"usagePeriodAnchor": 1703116800,
"usagePeriodStart": 1703116800,
"usagePeriodEnd": 1700568000,
"resetPeriod": {
"rawValue": "MONTH"
},
"resetPeriodConfiguration": {
"__typename": "MonthlyResetPeriodConfig",
"resetPeriodConfigurationFragment": {
"__typename": "MonthlyResetPeriodConfig",
"onMonthlyResetPeriodConfig": {
"monthlyAccordingTo": {
"rawValue": "SubscriptionStart"
}
},
"onWeeklyResetPeriodConfig": null
}
},
"feature": {
"__typename": "EntitlementFeature",
"featureFragment": {
"featureType": {
"rawValue": "NUMBER"
},
"meterType": {
"rawValue": "Incremental"
},
"featureUnits": "active user",
"featureUnitsPlural": "active users",
"description": null,
"displayName": "Active users",
"refId": "feature-07-active-users"
}
}
}
},
{
"__typename": "Entitlement",
"entitlementFragment": {
"isGranted": true,
"accessDeniedReason": null,
"customerId": null,
"resourceId": null,
"usageLimit": 12,
"hasUnlimitedUsage": false,
"currentUsage": 0,
"requestedUsage": null,
"entitlementUpdatedAt": null,
"usageUpdatedAt": 1700595037.13,
"usagePeriodAnchor": 1703116800,
"usagePeriodStart": 1703116800,
"usagePeriodEnd": 1700568000,
"resetPeriod": {
"rawValue": "MONTH"
},
"resetPeriodConfiguration": {
"__typename": "MonthlyResetPeriodConfig",
"resetPeriodConfigurationFragment": {
"__typename": "MonthlyResetPeriodConfig",
"onMonthlyResetPeriodConfig": {
"monthlyAccordingTo": {
"rawValue": "SubscriptionStart"
}
},
"onWeeklyResetPeriodConfig": null
}
},
"feature": {
"__typename": "EntitlementFeature",
"featureFragment": {
"featureType": {
"rawValue": "NUMBER"
},
"meterType": {
"rawValue": "Incremental"
},
"featureUnits": "campaign",
"featureUnitsPlural": "campaigns",
"description": null,
"displayName": "Campaigns",
"refId": "feature-02-campaigns"
}
}
}
},
{
"__typename": "Entitlement",
"entitlementFragment": {
"isGranted": true,
"accessDeniedReason": null,
"customerId": null,
"resourceId": null,
"usageLimit": 5,
"hasUnlimitedUsage": false,
"currentUsage": 3,
"requestedUsage": null,
"entitlementUpdatedAt": null,
"usageUpdatedAt": 1700594586.26,
"usagePeriodAnchor": null,
"usagePeriodStart": null,
"usagePeriodEnd": null,
"resetPeriod": null,
"resetPeriodConfiguration": null,
"feature": {
"__typename": "EntitlementFeature",
"featureFragment": {
"featureType": {
"rawValue": "NUMBER"
},
"meterType": {
"rawValue": "Fluctuating"
},
"featureUnits": "template",
"featureUnitsPlural": "templates",
"description": null,
"displayName": "Templates",
"refId": "feature-01-templates"
}
}
}
},
{
"__typename": "Entitlement",
"entitlementFragment": {
"isGranted": true,
"accessDeniedReason": null,
"customerId": null,
"resourceId": null,
"usageLimit": null,
"hasUnlimitedUsage": false,
"currentUsage": null,
"requestedUsage": null,
"entitlementUpdatedAt": null,
"usageUpdatedAt": null,
"usagePeriodAnchor": null,
"usagePeriodStart": null,
"usagePeriodEnd": null,
"resetPeriod": null,
"resetPeriodConfiguration": null,
"feature": {
"__typename": "EntitlementFeature",
"featureFragment": {
"featureType": {
"rawValue": "BOOLEAN"
},
"meterType": {
"rawValue": "None"
},
"featureUnits": null,
"featureUnitsPlural": null,
"description": null,
"displayName": "Custom domain",
"refId": "feature-03-custom-domain"
}
}
}
}
]
}
The Stigg SDK allows you to report usage measurements for metered features. The reported usage will be used to track, limit and bill the customer’s usage of metered features.
Stigg supports metering of usage from the following data sources:
More details about Stigg’s metering and aggregation capabilities can be found here:
Validating that a measurement was successfully reported to Stigg is also possible in the customer details section of the relevant customer in the Stigg app.
var resp = await stigg.ReportUsage.ExecuteAsync(new ReportUsageInput()
{
CustomerId = "customer-demo-01",
FeatureId = "feature-02-campaigns",
ResourceId = "site-1" // optional resource ID
Value = 1
});
By default, the value reported should represent the change in usage of the feature, for example user added 2 more seats then the report usage call should have the value of 2.
In some cases, it’s more useful to set the usage to some value instead of reporting the change value, it’s possible by passing the updateBehavior
parameter:
var resp = await stigg.ReportUsage.ExecuteAsync(new ReportUsageInput()
{
CustomerId = "customer-demo-01",
FeatureId = "feature-02-campaigns",
ResourceId = "site-1" // optional resource ID
Value = 3
UpdateBehavior = UsageUpdateBehavior.Set
});
Show Result
{
"reportUsage": {
"id": "5fc41989-e624-4240-a482-c588b4255791",
"currentUsage": 3,
"usagePeriodEnd": 1700568000,
"usagePeriodEnd": 1703116800,
"timestamp": 1700595372.708
}
}
var resp = await stigg.ReportEvent.ExecuteAsync(new UsageEventsReportInput()
{
UsageEvents = new List<UsageEventReportInput>()
{
new()
{
CustomerId = "customer-demo-01",
EventName = "user_login",
Dimensions = JsonSerializer.SerializeToElement(new { user_id = "1" }),
IdempotencyKey = Guid.NewGuid().ToString(),
}
}
});
It’s also possible to send a batch of events in one invocation. To do so, simply pass an array of events to the reportEvent
method.
var resp = await stigg.GetCoupons.ExecuteAsync();
Show Result
{
"coupons": {
"edges": [
{
"node": {
"__typename": "Coupon",
"couponFragment": {
"id": "8fe11e1f-7dc2-4a82-b357-c1c3dc738660",
"discountValue": 20,
"type": {
"rawValue": "PERCENTAGE"
},
"additionalMetaData": null,
"refId": "coupon-vip",
"name": "VIP",
"description": null,
"createdAt": 1700576088.148,
"updatedAt": 1700576091.342,
"billingId": "9zQ41isX",
"billingLinkUrl": "https://dashboard.stripe.com/test/coupons/9zQ41isX",
"status": {
"rawValue": "ACTIVE"
},
"syncStates": [
{
"vendorIdentifier": {
"rawValue": "STRIPE"
},
"status": {
"rawValue": "SUCCESS"
}
}
],
"customers": []
}
}
}
]
}
}
You can grant promotional entitlements for customers using the GrantPromotionalEntitlements
method.
var resp = await stigg.GrantPromotionalEntitlements.ExecuteAsync(new GrantPromotionalEntitlementsInput()
{
CustomerId = "customer-demo-01",
PromotionalEntitlements = new List<GrantPromotionalEntitlementInput>()
{
new()
{
FeatureId = "feature-04-analytics",
Period = PromotionalEntitlementPeriod.Lifetime
},
new()
{
FeatureId = "feature-02-campaigns",
Period = PromotionalEntitlementPeriod.Custom,
CustomEndDate = DateTime.Now.AddDays(15),
UsageLimit = 100
}
}
});
Show Result
{
"grantPromotionalEntitlements": [
{
"__typename": "PromotionalEntitlement",
"promotionalEntitlementFragment": {
"status": {
"rawValue": "Active"
},
"usageLimit": null,
"featureId": "0937bf25-2fec-457b-a1f5-bd470396a100",
"hasUnlimitedUsage": null,
"resetPeriod": null,
"endDate": 1703188217.659,
"isVisible": true,
"feature": {
"featureType": {
"rawValue": "BOOLEAN"
},
"meterType": {
"rawValue": "None"
},
"featureUnits": null,
"featureUnitsPlural": null,
"displayName": "Analytics",
"description": null,
"refId": "feature-04-analytics",
"additionalMetaData": null
}
}
},
{
"__typename": "PromotionalEntitlement",
"promotionalEntitlementFragment": {
"status": {
"rawValue": "Active"
},
"usageLimit": 100,
"featureId": "cce3f1fe-494e-472a-919d-5135bb932349",
"hasUnlimitedUsage": null,
"resetPeriod": null,
"endDate": 1703188216.028,
"isVisible": true,
"feature": {
"featureType": {
"rawValue": "NUMBER"
},
"meterType": {
"rawValue": "Incremental"
},
"featureUnits": "campaign",
"featureUnitsPlural": "campaigns",
"displayName": "Campaigns",
"description": null,
"refId": "feature-02-campaigns",
"additionalMetaData": null
}
}
}
]
}
You can revoke promotional entitlements from customer using the RevokePromotionalEntitlement
method.
await stigg.RevokePromotionalEntitlement.ExecuteAsync(new RevokePromotionalEntitlementInput()
{
CustomerId = "customer-demo-01",
FeatureId = "feature-04-analytics"
});
Show Result
{
"revokePromotionalEntitlement": {
"id": "f77c7c8c-098b-42f2-a82b-134f69241e2d"
}
}
You can estimate the subscription cost using the EstimateSubscription
method. This can help the customer to understand the costs before paying.
var resp = await stigg.EstimateSubscription.ExecuteAsync(new EstimateSubscriptionInput()
{
CustomerId = "customer-demo-01",
PlanId = "plan-revvenu-essentials",
BillableFeatures = new List<BillableFeatureInput>()
{
new()
{
FeatureId = "feature-01-templates",
Quantity = 5
}
},
Addons = new List<SubscriptionAddonInput>()
{
new()
{
AddonId = "addon-10-campaigns",
Quantity = 5
}
},
});
Show Result
{
"estimateSubscription": {
"__typename": "SubscriptionPreview",
"subscriptionPreviewFragment": {
"subTotal": {
"amount": 24.88,
"currency": {
"rawValue": "USD"
}
},
"totalExcludingTax": {
"amount": 24.88,
"currency": {
"rawValue": "USD"
}
},
"total": {
"amount": 2.89,
"currency": {
"rawValue": "USD"
}
},
"discountAmount": null,
"taxDetails": null,
"tax": {
"amount": 0,
"currency": {
"rawValue": "USD"
}
},
"billingPeriodRange": {
"start": 1700596892.977,
"end": 1703188892.977
},
"discount": null,
"subscription": {
"subTotal": {
"amount": 55,
"currency": {
"rawValue": "USD"
}
},
"totalExcludingTax": {
"amount": 55,
"currency": {
"rawValue": "USD"
}
},
"total": {
"amount": 55,
"currency": {
"rawValue": "USD"
}
},
"tax": {
"amount": 0,
"currency": {
"rawValue": "USD"
}
},
"discountAmount": null,
"taxDetails": null,
"discount": null
},
"proration": {
"prorationDate": 1700596893,
"credit": {
"amount": 0,
"currency": {
"rawValue": "USD"
}
},
"debit": {
"amount": 24.88,
"currency": {
"rawValue": "USD"
}
},
"netAmount": {
"amount": 24.88,
"currency": {
"rawValue": "USD"
}
}
},
"isPlanDowngrade": null,
"hasScheduledUpdates": null,
"credits": {
"initial": {
"amount": 21.99,
"currency": {
"rawValue": "USD"
}
},
"used": {
"amount": 21.99,
"currency": {
"rawValue": "USD"
}
},
"remaining": {
"amount": 0,
"currency": {
"rawValue": "USD"
}
}
}
}
}
}
You can also estimate the cost of updating an existing subscription using the EstimateSubscriptionUpdate
method, which also returns a breakdown of the proration amounts:
var resp = await stigg.EstimateSubscriptionUpdate.ExecuteAsync(new EstimateSubscriptionUpdateInput()
{
SubscriptionId = "subscription-plan-revvenu-essentials-bum2flivze",
BillableFeatures = new List<BillableFeatureInput>()
{
new()
{
FeatureId = "feature-01-templates",
Quantity = 5
}
},
Addons = new List<SubscriptionAddonInput>()
{
new()
{
AddonId = "addon-10-campaigns",
Quantity = 5
}
},
});
Show Result
{
"estimateSubscriptionUpdate": {
"__typename": "SubscriptionPreview",
"subscriptionPreviewFragment": {
"subTotal": {
"amount": 24.87,
"currency": {
"rawValue": "USD"
}
},
"totalExcludingTax": {
"amount": 24.87,
"currency": {
"rawValue": "USD"
}
},
"total": {
"amount": 2.8800000000000026,
"currency": {
"rawValue": "USD"
}
},
"discountAmount": null,
"taxDetails": null,
"tax": {
"amount": 0,
"currency": {
"rawValue": "USD"
}
},
"billingPeriodRange": {
"start": 1700583990,
"end": 1703175990
},
"discount": null,
"subscription": {
"subTotal": {
"amount": 55,
"currency": {
"rawValue": "USD"
}
},
"totalExcludingTax": {
"amount": 55,
"currency": {
"rawValue": "USD"
}
},
"total": {
"amount": 55,
"currency": {
"rawValue": "USD"
}
},
"tax": {
"amount": 0,
"currency": {
"rawValue": "USD"
}
},
"discountAmount": null,
"taxDetails": null,
"discount": null
},
"proration": {
"prorationDate": 1700597071,
"credit": {
"amount": 0,
"currency": {
"rawValue": "USD"
}
},
"debit": {
"amount": 24.87,
"currency": {
"rawValue": "USD"
}
},
"netAmount": {
"amount": 24.87,
"currency": {
"rawValue": "USD"
}
}
},
"isPlanDowngrade": null,
"hasScheduledUpdates": null,
"credits": {
"initial": {
"amount": 21.99,
"currency": {
"rawValue": "USD"
}
},
"used": {
"amount": 21.99,
"currency": {
"rawValue": "USD"
}
},
"remaining": {
"amount": 0,
"currency": {
"rawValue": "USD"
}
}
}
}
}
}
This library provides a .NET client to interact with Stigg’s GraphQL API based on API operations that are in use by the Stigg’s Node.js SDK
Under the hood, it leverages Strawberry Shake to generate C# classes for GraphQL types.
The first step is to add the SDK as a dependency in your .NET application, Stigg package is published as a Nuget package
dotnet add package Stigg.Api.Client
It’s recommended to hard code the stigg-api-dot-net
version according to the latest version available here.
In the Stigg app, go to Settings > Account > Environments.
Copy the Server API key of the relevant environment.
Import the Stigg client and initialize it with the API key.
Synchronous client:
using Stigg.Api.Client;
class App {
public static void main() {
var stigg = Stigg.createClient("<SERVER-API-KEY>");
}
}
When a new customer is provisioned within your application (for example: as part of your registration or onboarding process), you should also provision them in Stigg.
The customer’s billing information can also be passed to Stigg when a customer is created or updated. When Stigg is integrated with additional service, this information will be propagated to the active integrations. The billing information is not persisted on Stigg’s servers.
You can optionally pass subscriptionParams
to create subscription for that customer using a single operation. Doing so, will allow Stigg admins to override the requested subscription with no-code from the Stigg Console using the product’s Customer Journey configuration.
var resp = await stigg.ProvisionCustomer.ExecuteAsync(new ProvisionCustomerInput()
{
CustomerId= "customer-81726628184",
Name = "Acme",
Email = "john@example.com",
SubscriptionParams = new ProvisionCustomerSubscriptionInput()
{
PlanId = "plan-revvenu-basic"
}
});
Show Result
{
"provisionCustomer": {
"customer": {
"__typename": "Customer",
"slimCustomerFragment": {
"id": "4168b1ed-56de-41fe-9382-4d9eaf45e161",
"name": "Acme",
"email": "john@example.com",
"createdAt": "2023-11-20T22:39:19.840Z",
"updatedAt": "2023-11-20T22:39:19.840Z",
"refId": "customer-5162641",
"customerId": "customer-5162641",
"billingId": null,
"additionalMetaData": {
"key": "value"
}
}
},
"subscriptionDecisionStrategy": {
"rawValue": "REQUESTED_PLAN"
},
"subscription": {
"__typename": "CustomerSubscription",
"slimSubscriptionFragment": {
"id": "e09b03a6-d0ec-4d6b-b184-1b897981283e",
"refId": "subscription-plan-revvenu-basic-tctmtyrvfv",
"status": {
"rawValue": "ACTIVE"
},
"additionalMetaData": null,
"billingId": null,
"billingLinkUrl": null,
"effectiveEndDate": null,
"currentBillingPeriodEnd": "2023-12-20T22:39:19.893Z",
"pricingType": {
"rawValue": "FREE"
},
"latestInvoice": null,
"paymentCollection": {
"rawValue": "NOT_REQUIRED"
},
"billingSyncError": null,
"resource": null,
"experimentInfo": null,
"prices": [],
"totalPrice": null,
"plan": {
"id": "bad48997-2aec-4f01-bfa5-534e80826c0e",
"refId": "plan-revvenu-basic"
},
"addons": [],
"customer": {
"id": "4168b1ed-56de-41fe-9382-4d9eaf45e161",
"refId": "customer-5162641"
}
}
}
}
}
Customer information can also be updated whenever you like assuming it already exists, for example: In order to update the customer’s email, you only need to send the new email value without the rest of the customer. Due to the fact that the customer’s billing information is not persisted on Stigg’s servers, in order to update it, the entire billing information object must be passed each time.
var res = await stigg.UpdateCustomer.ExecuteAsync(new UpdateCustomerInput()
{
CustomerId = "customer-demo-01",
Name = "Acme",
Email = "john@example.com",
});
Show Result
{
"updateCustomer": {
"__typename": "Customer",
"slimCustomerFragment": {
"id": "a7b2a41b-1f2c-40ab-b639-ef345e5adf17",
"name": "Acme",
"email": "john@example.com",
"createdAt": "2023-11-21T14:14:50.386Z",
"updatedAt": "2023-11-21T14:30:07.487Z",
"refId": "customer-demo-01",
"customerId": "customer-demo-01",
"billingId": null,
"additionalMetaData": {
"key": "value"
}
}
}
}
var res = await stigg.GetCustomerById.ExecuteAsync(new GetCustomerByRefIdInput()
{
CustomerId = "customer-demo-01",
});
Show Result
{
"getCustomerByRefId": {
"__typename": "Customer",
"customerWithSubscriptionsFragment": {
"__typename": "Customer",
"subscriptions": [
{
"__typename": "CustomerSubscription",
"subscriptionFragment": {
"id": "ed2696e4-e840-47b8-af7b-a0babbf1a464",
"startDate": "2023-10-21T13:14:45.992Z",
"endDate": null,
"trialEndDate": null,
"cancellationDate": null,
"effectiveEndDate": null,
"status": {
"rawValue": "ACTIVE"
},
"refId": "subscription-plan-revvenu-basic-g6d4kugtyp",
"currentBillingPeriodEnd": "2023-12-21T13:14:45.992Z",
"additionalMetaData": null,
"billingId": null,
"billingLinkUrl": null,
"latestInvoice": null,
"paymentCollection": {
"rawValue": "NOT_REQUIRED"
},
"billingSyncError": null,
"resource": null,
"experimentInfo": null,
"prices": [],
"totalPrice": null,
"pricingType": {
"rawValue": "FREE"
},
"plan": {
"__typename": "Plan",
"planFragment": {
"id": "05a09259-dcb8-47ca-a447-571a2835e694",
"refId": "plan-revvenu-basic",
"displayName": "Basic",
"description": null,
"billingId": "prod_P30kaef2AIphhb",
"versionNumber": 1,
"additionalMetaData": null,
"product": {
"__typename": "Product",
"productFragment": {
"refId": "product-revvenu",
"displayName": "Revvenu",
"description": null,
"additionalMetaData": {
"recommendedPlan": "plan-revvenu-essentials"
},
"productSettings": {
"downgradePlan": null
}
}
},
"basePlan": null,
"entitlements": [
{
"__typename": "PackageEntitlement",
"packageEntitlementFragment": {
"usageLimit": 3,
"hasUnlimitedUsage": null,
"featureId": "109e38e3-fa95-40d2-94a7-730b2bce0e87",
"resetPeriod": null,
"hiddenFromWidgets": [],
"isCustom": null,
"displayNameOverride": null,
"feature": {
"featureType": {
"rawValue": "NUMBER"
},
"meterType": {
"rawValue": "Fluctuating"
},
"featureUnits": "template",
"featureUnitsPlural": "templates",
"displayName": "Templates",
"description": null,
"refId": "feature-01-templates",
"additionalMetaData": null
}
}
},
{
"__typename": "PackageEntitlement",
"packageEntitlementFragment": {
"usageLimit": 4,
"hasUnlimitedUsage": null,
"featureId": "cce3f1fe-494e-472a-919d-5135bb932349",
"resetPeriod": {
"rawValue": "MONTH"
},
"hiddenFromWidgets": [],
"isCustom": null,
"displayNameOverride": null,
"feature": {
"featureType": {
"rawValue": "NUMBER"
},
"meterType": {
"rawValue": "Incremental"
},
"featureUnits": "campaign",
"featureUnitsPlural": "campaigns",
"displayName": "Campaigns",
"description": null,
"refId": "feature-02-campaigns",
"additionalMetaData": null
}
}
},
{
"__typename": "PackageEntitlement",
"packageEntitlementFragment": {
"usageLimit": 1000,
"hasUnlimitedUsage": null,
"featureId": "c8947bb3-c480-46a9-bdb3-9babe145921b",
"resetPeriod": {
"rawValue": "MONTH"
},
"hiddenFromWidgets": [],
"isCustom": null,
"displayNameOverride": null,
"feature": {
"featureType": {
"rawValue": "NUMBER"
},
"meterType": {
"rawValue": "Incremental"
},
"featureUnits": "active user",
"featureUnitsPlural": "active users",
"displayName": "Active users",
"description": null,
"refId": "feature-07-active-users",
"additionalMetaData": null
}
}
},
{
"__typename": "PackageEntitlement",
"packageEntitlementFragment": {
"usageLimit": 5,
"hasUnlimitedUsage": null,
"featureId": "8743a7be-3778-4b33-9036-dd1f9d7fff08",
"resetPeriod": null,
"hiddenFromWidgets": [],
"isCustom": null,
"displayNameOverride": "5MB file size limit",
"feature": {
"featureType": {
"rawValue": "NUMBER"
},
"meterType": {
"rawValue": "None"
},
"featureUnits": "MB",
"featureUnitsPlural": "MB",
"displayName": "Max file size",
"description": null,
"refId": "feature-06-max-file-size",
"additionalMetaData": null
}
}
}
],
"inheritedEntitlements": [],
"compatibleAddons": [],
"prices": [],
"pricingType": {
"rawValue": "FREE"
},
"defaultTrialConfig": null
}
},
"addons": [],
"scheduledUpdates": [],
"futureUpdates": []
}
}
],
"customerFragment": {
"__typename": "Customer",
"hasPaymentMethod": false,
"hasActiveSubscription": true,
"defaultPaymentExpirationMonth": null,
"defaultPaymentExpirationYear": null,
"defaultPaymentMethodLast4Digits": null,
"trialedPlans": [],
"experimentInfo": null,
"coupon": null,
"eligibleForTrial": [],
"promotionalEntitlements": [
{
"__typename": "PromotionalEntitlement",
"promotionalEntitlementFragment": {
"status": {
"rawValue": "Active"
},
"usageLimit": null,
"featureId": "56141e76-9a3f-4d16-b76f-e30228f98a22",
"hasUnlimitedUsage": null,
"resetPeriod": null,
"endDate": null,
"isVisible": true,
"feature": {
"featureType": {
"rawValue": "BOOLEAN"
},
"meterType": {
"rawValue": "None"
},
"featureUnits": null,
"featureUnitsPlural": null,
"displayName": "Custom domain",
"description": null,
"refId": "feature-03-custom-domain",
"additionalMetaData": null
}
}
}
],
"slimCustomerFragment": {
"id": "a7b2a41b-1f2c-40ab-b639-ef345e5adf17",
"name": "Acme",
"email": "john@example.com",
"createdAt": "2023-11-21T14:14:50.386Z",
"updatedAt": "2023-11-21T16:14:35.415Z",
"refId": "customer-demo-01",
"customerId": "customer-demo-01",
"billingId": null,
"additionalMetaData": {
"key": "value"
}
}
}
}
}
}
var res = await stigg.GetActiveSubscriptionsList.ExecuteAsync(new GetActiveSubscriptionsInput()
{
CustomerId = "customer-demo-01",
ResourceId = "site-1" // optional resource ID
});
Show Result
{
"getActiveSubscriptions": [
{
"__typename": "CustomerSubscription",
"slimSubscriptionFragmentV2": {
"startDate": "2023-11-21T16:26:11.000Z",
"status": {
"rawValue": "ACTIVE"
},
"subscriptionId": "subscription-plan-revvenu-essentials-cd0ba9",
"currentBillingPeriodEnd": "2023-12-21T16:26:30.000Z",
"resource": null,
"pricingType": {
"rawValue": "PAID"
},
"plan": {
"planId": "plan-revvenu-essentials",
"displayName": "Essentials",
},
"addons": [
{
"quantity": 2,
"addon": {
"addonId": "addon-10-campaigns",
}
}
],
}
}
]
}
To retrieve extended subscription data:
var res = await stigg.GetSubscription.ExecuteAsync(new GetSubscriptionInput()
{
SubscriptionId = "subscription-id",
});
Show Result
{
"getSubscription": {
"__typename": "CustomerSubscription",
"subscriptionFragment": {
"id": "b8b48c70-df8a-460c-b5f9-2276a5854a03",
"startDate": "2023-11-21T16:26:11.000Z",
"endDate": null,
"trialEndDate": null,
"cancellationDate": null,
"effectiveEndDate": null,
"status": {
"rawValue": "ACTIVE"
},
"refId": "subscription-plan-revvenu-essentials-cd0ba9",
"currentBillingPeriodEnd": "2023-12-21T16:26:30.000Z",
"additionalMetaData": null,
"billingId": "sub_1OEwmQAnAO1PFouUVaDluuRj",
"billingLinkUrl": "https://dashboard.stripe.com/test/subscriptions/sub_1OEwmQAnAO1PFouUVaDluuRj",
"latestInvoice": {
"__typename": "SubscriptionInvoice",
"subscriptionInvoiceFragment": {
"billingId": "in_1OEwmQAnAO1PFouU8W9U6ldu",
"status": {
"rawValue": "PAID"
},
"createdAt": "2023-11-21T16:26:30.000Z",
"updatedAt": "2023-11-21T16:26:32.842Z",
"requiresAction": false,
"paymentUrl": "https://invoice.stripe.com/i/acct_1KxDMtAnAO1PFouU/test_YWNjdF8xS3hETXRBbkFPMVBGb3VVLF9QMzJzcDRKTGxJcGNucWhZOEJCd2ZheG9SZk5TOEdJLDkxMTI0Nzkz0200ZnGaOwnQ?s=ap",
"paymentSecret": "pi_3OEwmRAnAO1PFouU1Zg54ALZ_secret_28nQjBxmQnzVg0ISlvBC2eQJR",
"errorMessage": null
}
},
"paymentCollection": {
"rawValue": "NOT_REQUIRED"
},
"billingSyncError": null,
"resource": null,
"experimentInfo": null,
"prices": [
{
"usageLimit": 7,
"price": {
"__typename": "Price",
"priceFragment": {
"billingModel": {
"rawValue": "PER_UNIT"
},
"billingPeriod": {
"rawValue": "MONTHLY"
},
"billingId": "price_1OEuj0AnAO1PFouUPwz1QA7U",
"minUnitQuantity": 5,
"maxUnitQuantity": null,
"billingCountryCode": null,
"price": {
"amount": 6,
"currency": {
"rawValue": "USD"
}
},
"tiersMode": null,
"tiers": null,
"feature": {
"refId": "feature-01-templates",
"featureUnits": "template",
"featureUnitsPlural": "templates",
"displayName": "Templates",
"description": null
}
}
}
}
],
"totalPrice": {
"__typename": "CustomerSubscriptionTotalPrice",
"totalPriceFragment": {
"subTotal": {
"amount": 52,
"currency": {
"rawValue": "USD"
}
},
"total": {
"amount": 52,
"currency": {
"rawValue": "USD"
}
}
}
},
"pricingType": {
"rawValue": "PAID"
},
"plan": {
"__typename": "Plan",
"planFragment": {
"id": "7a3979c1-c553-4338-a5b3-c7523bec288f",
"refId": "plan-revvenu-essentials",
"displayName": "Essentials",
"description": null,
"billingId": "prod_P30kP9lB01YaiE",
"versionNumber": 1,
"additionalMetaData": null,
"product": {
"__typename": "Product",
"productFragment": {
"refId": "product-revvenu",
"displayName": "Revvenu",
"description": null,
"additionalMetaData": {
"recommendedPlan": "plan-revvenu-essentials"
},
"productSettings": {
"downgradePlan": null
}
}
},
"basePlan": {
"refId": "plan-revvenu-basic",
"displayName": "Basic"
},
"entitlements": [
{
"__typename": "PackageEntitlement",
"packageEntitlementFragment": {
"usageLimit": 12,
"hasUnlimitedUsage": null,
"featureId": "cce3f1fe-494e-472a-919d-5135bb932349",
"resetPeriod": {
"rawValue": "MONTH"
},
"hiddenFromWidgets": [],
"isCustom": null,
"displayNameOverride": null,
"feature": {
"featureType": {
"rawValue": "NUMBER"
},
"meterType": {
"rawValue": "Incremental"
},
"featureUnits": "campaign",
"featureUnitsPlural": "campaigns",
"displayName": "Campaigns",
"description": null,
"refId": "feature-02-campaigns",
"additionalMetaData": null
}
}
},
{
"__typename": "PackageEntitlement",
"packageEntitlementFragment": {
"usageLimit": 25000,
"hasUnlimitedUsage": null,
"featureId": "c8947bb3-c480-46a9-bdb3-9babe145921b",
"resetPeriod": {
"rawValue": "MONTH"
},
"hiddenFromWidgets": [],
"isCustom": null,
"displayNameOverride": null,
"feature": {
"featureType": {
"rawValue": "NUMBER"
},
"meterType": {
"rawValue": "Incremental"
},
"featureUnits": "active user",
"featureUnitsPlural": "active users",
"displayName": "Active users",
"description": null,
"refId": "feature-07-active-users",
"additionalMetaData": null
}
}
},
{
"__typename": "PackageEntitlement",
"packageEntitlementFragment": {
"usageLimit": 100,
"hasUnlimitedUsage": null,
"featureId": "8743a7be-3778-4b33-9036-dd1f9d7fff08",
"resetPeriod": null,
"hiddenFromWidgets": [],
"isCustom": null,
"displayNameOverride": "100MB file size limit",
"feature": {
"featureType": {
"rawValue": "NUMBER"
},
"meterType": {
"rawValue": "None"
},
"featureUnits": "MB",
"featureUnitsPlural": "MB",
"displayName": "Max file size",
"description": null,
"refId": "feature-06-max-file-size",
"additionalMetaData": null
}
}
},
{
"__typename": "PackageEntitlement",
"packageEntitlementFragment": {
"usageLimit": null,
"hasUnlimitedUsage": null,
"featureId": "0937bf25-2fec-457b-a1f5-bd470396a100",
"resetPeriod": null,
"hiddenFromWidgets": [],
"isCustom": null,
"displayNameOverride": null,
"feature": {
"featureType": {
"rawValue": "BOOLEAN"
},
"meterType": {
"rawValue": "None"
},
"featureUnits": null,
"featureUnitsPlural": null,
"displayName": "Analytics",
"description": null,
"refId": "feature-04-analytics",
"additionalMetaData": null
}
}
}
],
"inheritedEntitlements": [],
"compatibleAddons": [
{
"__typename": "Addon",
"addonFragment": {
"id": "59b81b8b-7bff-4b00-9ede-c5c9b9544500",
"refId": "addon-10-campaigns",
"billingId": "prod_P30kizGUa6097e",
"displayName": "10 campaigns",
"description": "Additional quota of 10 campaigns",
"additionalMetaData": null,
"entitlements": [
{
"__typename": "PackageEntitlement",
"packageEntitlementFragment": {
"usageLimit": 10,
"hasUnlimitedUsage": null,
"featureId": "cce3f1fe-494e-472a-919d-5135bb932349",
"resetPeriod": {
"rawValue": "MONTH"
},
"hiddenFromWidgets": [],
"isCustom": null,
"displayNameOverride": null,
"feature": {
"featureType": {
"rawValue": "NUMBER"
},
"meterType": {
"rawValue": "Incremental"
},
"featureUnits": "campaign",
"featureUnitsPlural": "campaigns",
"displayName": "Campaigns",
"description": null,
"refId": "feature-02-campaigns",
"additionalMetaData": null
}
}
}
],
"prices": [
{
"__typename": "Price",
"priceFragment": {
"billingModel": {
"rawValue": "FLAT_FEE"
},
"billingPeriod": {
"rawValue": "MONTHLY"
},
"billingId": "price_1OEuizAnAO1PFouUJwetn2ZQ",
"minUnitQuantity": null,
"maxUnitQuantity": null,
"billingCountryCode": null,
"price": {
"amount": 5,
"currency": {
"rawValue": "USD"
}
},
"tiersMode": null,
"tiers": null,
"feature": null
}
},
{
"__typename": "Price",
"priceFragment": {
"billingModel": {
"rawValue": "FLAT_FEE"
},
"billingPeriod": {
"rawValue": "ANNUALLY"
},
"billingId": "price_1OEuizAnAO1PFouUulgWldtN",
"minUnitQuantity": null,
"maxUnitQuantity": null,
"billingCountryCode": null,
"price": {
"amount": 54,
"currency": {
"rawValue": "USD"
}
},
"tiersMode": null,
"tiers": null,
"feature": null
}
}
],
"pricingType": {
"rawValue": "PAID"
}
}
}
],
"prices": [
{
"__typename": "Price",
"priceFragment": {
"billingModel": {
"rawValue": "PER_UNIT"
},
"billingPeriod": {
"rawValue": "ANNUALLY"
},
"billingId": "price_1OEuj0AnAO1PFouUlmmaUgsh",
"minUnitQuantity": 5,
"maxUnitQuantity": null,
"billingCountryCode": null,
"price": {
"amount": 60,
"currency": {
"rawValue": "USD"
}
},
"tiersMode": null,
"tiers": null,
"feature": {
"refId": "feature-01-templates",
"featureUnits": "template",
"featureUnitsPlural": "templates",
"displayName": "Templates",
"description": null
}
}
},
{
"__typename": "Price",
"priceFragment": {
"billingModel": {
"rawValue": "PER_UNIT"
},
"billingPeriod": {
"rawValue": "MONTHLY"
},
"billingId": "price_1OEuj0AnAO1PFouUPwz1QA7U",
"minUnitQuantity": 5,
"maxUnitQuantity": null,
"billingCountryCode": null,
"price": {
"amount": 6,
"currency": {
"rawValue": "USD"
}
},
"tiersMode": null,
"tiers": null,
"feature": {
"refId": "feature-01-templates",
"featureUnits": "template",
"featureUnitsPlural": "templates",
"displayName": "Templates",
"description": null
}
}
}
],
"pricingType": {
"rawValue": "PAID"
},
"defaultTrialConfig": null
}
},
"addons": [
{
"id": "0a86b7b0-b85f-479f-abf9-e7e1167c251d",
"quantity": 2,
"addon": {
"__typename": "Addon",
"addonFragment": {
"id": "59b81b8b-7bff-4b00-9ede-c5c9b9544500",
"refId": "addon-10-campaigns",
"billingId": "prod_P30kizGUa6097e",
"displayName": "10 campaigns",
"description": "Additional quota of 10 campaigns",
"additionalMetaData": null,
"entitlements": [
{
"__typename": "PackageEntitlement",
"packageEntitlementFragment": {
"usageLimit": 10,
"hasUnlimitedUsage": null,
"featureId": "cce3f1fe-494e-472a-919d-5135bb932349",
"resetPeriod": {
"rawValue": "MONTH"
},
"hiddenFromWidgets": [],
"isCustom": null,
"displayNameOverride": null,
"feature": {
"featureType": {
"rawValue": "NUMBER"
},
"meterType": {
"rawValue": "Incremental"
},
"featureUnits": "campaign",
"featureUnitsPlural": "campaigns",
"displayName": "Campaigns",
"description": null,
"refId": "feature-02-campaigns",
"additionalMetaData": null
}
}
}
],
"prices": [
{
"__typename": "Price",
"priceFragment": {
"billingModel": {
"rawValue": "FLAT_FEE"
},
"billingPeriod": {
"rawValue": "MONTHLY"
},
"billingId": "price_1OEuizAnAO1PFouUJwetn2ZQ",
"minUnitQuantity": null,
"maxUnitQuantity": null,
"billingCountryCode": null,
"price": {
"amount": 5,
"currency": {
"rawValue": "USD"
}
},
"tiersMode": null,
"tiers": null,
"feature": null
}
},
{
"__typename": "Price",
"priceFragment": {
"billingModel": {
"rawValue": "FLAT_FEE"
},
"billingPeriod": {
"rawValue": "ANNUALLY"
},
"billingId": "price_1OEuizAnAO1PFouUulgWldtN",
"minUnitQuantity": null,
"maxUnitQuantity": null,
"billingCountryCode": null,
"price": {
"amount": 54,
"currency": {
"rawValue": "USD"
}
},
"tiersMode": null,
"tiers": null,
"feature": null
}
}
],
"pricingType": {
"rawValue": "PAID"
}
}
}
}
],
"scheduledUpdates": [],
"futureUpdates": []
}
}
}
When a customer subscribes to a new plan (for example: during an upgrade from a free plan to a paid plan, or downgrade from a higher tier to a lower tier), a subscription needs to be created in Stigg.
When provisioning of a paid subscription is attempted, Stigg is integrated with a billing solution and payment details have not been previously provided by the customer, Stigg will auto-magically redirect customers to a the billing solution’s checkout page. After the customer enters the required payment details in the presented checkout page, the relevant subscription will be created in both Stigg and the billing solution.
When no payment is required or when Stigg is not integrated with a billing solution, the subscription will be immediately created in Stigg.
When a customer subscribes to a new plan (free, paid, trial, etc.), provision a subscription in Stigg. The provision result can be a successfully created subscription, or a redirect link to stripe checkout in case payment is needed.
var res = await stigg.ProvisionSubscription.ExecuteAsync(new ProvisionSubscriptionInput()
{
CustomerId = "customer-demo-01",
PlanId = "plan-revvenu-essentials",
BillingPeriod = BillingPeriod.Monthly,
BillableFeatures = new List<BillableFeatureInput>()
{
new()
{
FeatureId = "feature-01-templates",
Quantity = 5
}
},
Addons = new List<SubscriptionAddonInput>()
{
new()
{
AddonId = "addon-extra-stuff",
Quantity = 5
}
},
});
Show Result - Success
{
"provisionSubscription": {
"checkoutUrl": null,
"status": {
"rawValue": "SUCCESS"
},
"subscription": {
"__typename": "CustomerSubscription",
"slimSubscriptionFragment": {
"id": "bad12052-32f1-4590-9230-911298c2d21b",
"refId": "subscription-plan-revvenu-essentials-bum2flivze",
"status": {
"rawValue": "ACTIVE"
},
"additionalMetaData": {
"key": "value"
},
"billingId": "sub_1OEwmQAnAO1PFouUVaDluuRj",
"billingLinkUrl": "https://dashboard.stripe.com/test/subscriptions/sub_1OEwmQAnAO1PFouUVaDluuRj",
"effectiveEndDate": null,
"currentBillingPeriodEnd": "2023-12-21T16:26:30.000Z",
"pricingType": {
"rawValue": "PAID"
},
"latestInvoice": {
"__typename": "SubscriptionInvoice",
"subscriptionInvoiceFragment": {
"billingId": "in_1OExBFAnAO1PFouUfLM3dpL9",
"status": {
"rawValue": "PAID"
},
"createdAt": "2023-11-21T16:52:09.000Z",
"updatedAt": "2023-11-21T16:52:58.491Z",
"requiresAction": false,
"paymentUrl": "https://invoice.stripe.com/i/acct_1KxDMtAnAO1PFouU/test_YWNjdF8xS3hETXRBbkFPMVBGb3VVLF9QMzNIamZCSm5IVEJ1TkhDVFNCa2kzcVRnZXllVlpNLDkxMTI2Mzc40200A5QhGfKJ?s=ap",
"paymentSecret": null,
"errorMessage": null
}
},
"paymentCollection": {
"rawValue": "NOT_REQUIRED"
},
"billingSyncError": null,
"resource": null,
"experimentInfo": null,
"prices": [
{
"usageLimit": 5,
"price": {
"__typename": "Price",
"priceFragment": {
"billingModel": {
"rawValue": "PER_UNIT"
},
"billingPeriod": {
"rawValue": "MONTHLY"
},
"billingId": "price_1OEuj0AnAO1PFouUPwz1QA7U",
"minUnitQuantity": 5,
"maxUnitQuantity": null,
"billingCountryCode": null,
"price": {
"amount": 6,
"currency": {
"rawValue": "USD"
}
},
"tiersMode": null,
"tiers": null,
"feature": {
"refId": "feature-01-templates",
"featureUnits": "template",
"featureUnitsPlural": "templates",
"displayName": "Templates",
"description": null
}
}
}
}
],
"totalPrice": {
"__typename": "CustomerSubscriptionTotalPrice",
"totalPriceFragment": {
"subTotal": {
"amount": 30,
"currency": {
"rawValue": "USD"
}
},
"total": {
"amount": 30,
"currency": {
"rawValue": "USD"
}
}
}
},
"plan": {
"id": "7a3979c1-c553-4338-a5b3-c7523bec288f",
"refId": "plan-revvenu-essentials"
},
"addons": [],
"customer": {
"id": "a7b2a41b-1f2c-40ab-b639-ef345e5adf17",
"refId": "customer-demo-01"
}
}
}
}
}
Show Result - Action required (3DS)
{
"provision_subscription": {
"subscription": {
"paymentCollection": {
"rawValue": "ACTION_REQUIRED"
},
"latestInvoice": {
"paymentUrl": "https...",
"paymentSecret": "secret",
}
}
}
}
Show Result - Payment failed
{
"provisionSubscription": {
"subscription": {
"paymentCollection": {
"rawValue": "FAILED"
},
"latestInvoice": {
"paymentUrl": "https...",
"errorMessage": "no sufficient funds"
}
}
}
}
Show Result - Checkout
{
"provisionSubscription": {
"checkoutUrl": "https://checkout.stripe.com/c/pay/cs_test_b1PKYNIzXFR3uejdj59M0BghDF4mNtL2MoHf6vipEpREAJPQ7zhR6rlJQG#fid2cGd2ZndsdXFsamtQa2x0cGBrYHZ2QGtkZ2lgYSc%2FY2RpdmApJ3Zxd2x1YERmZmpwa3EnPydkZmZxWjROfUFIcURrREo0VUNqcFAnKSdkdWxOYHwnPyd1blpxYHZxWjA0TnZpVjZCX11oMk9QUzxWcEpPRzN8cTZQXDZSSDRwcGRpQ3BiZ0w8NDY9PFZiX2REa0tHZzJDdXBHTD1caEN%2FQ3doS21Abn00REhDUH12cW50fW9rcHJ0NTVwVTxpdEFsMicpJ2N3amhWYHdzYHcnP3F3cGApJ2lkfGpwcVF8dWAnPydocGlxbFpscWBoJyknYGtkZ2lgVWlkZmBtamlhYHd2Jz9xd3BgeCUl",
"status": {
"rawValue": "PAYMENT_REQUIRED"
},
"subscription": null
}
}
skipTrial: true
parameter to the provisionSubscription()
method.Updating an existing subscription, this can be used to update the feature quantity that the customer is subscribed for or the add-ons.
var res = await stigg.UpdateSubscription.ExecuteAsync(new UpdateSubscriptionInput()
{
SubscriptionId = "subscription-plan-revvenu-essentials-cpzi7p2g09",
BillableFeatures = new List<BillableFeatureInput>()
{
new()
{
FeatureId = "feature-01-templates",
Quantity = 7
}
},
Addons = new List<SubscriptionAddonInput>()
{
new()
{
AddonId = "addon-extra-stuff",
Quantity = 5
}
},
});
Show Result
{
"updateSubscription": {
"__typename": "CustomerSubscription",
"slimSubscriptionFragment": {
"id": "bad12052-32f1-4590-9230-911298c2d21b",
"refId": "subscription-plan-revvenu-essentials-bum2flivze",
"status": {
"rawValue": "ACTIVE"
},
"additionalMetaData": {
"key": "value"
},
"billingId": "sub_1OEwmQAnAO1PFouUVaDluuRj",
"billingLinkUrl": "https://dashboard.stripe.com/test/subscriptions/sub_1OEwmQAnAO1PFouUVaDluuRj",
"effectiveEndDate": null,
"currentBillingPeriodEnd": "2023-12-21T16:26:30.000Z",
"pricingType": {
"rawValue": "PAID"
},
"latestInvoice": {
"__typename": "SubscriptionInvoice",
"subscriptionInvoiceFragment": {
"billingId": "in_1OExBFAnAO1PFouUfLM3dpL9",
"status": {
"rawValue": "PAID"
},
"createdAt": "2023-11-21T16:52:09.000Z",
"updatedAt": "2023-11-21T16:52:59.336Z",
"requiresAction": false,
"paymentUrl": "https://invoice.stripe.com/i/acct_1KxDMtAnAO1PFouU/test_YWNjdF8xS3hETXRBbkFPMVBGb3VVLF9QMzNIamZCSm5IVEJ1TkhDVFNCa2kzcVRnZXllVlpNLDkxMTI2Mzc50200GdQT8sqx?s=ap",
"paymentSecret": null,
"errorMessage": null
}
},
"paymentCollection": {
"rawValue": "NOT_REQUIRED"
},
"billingSyncError": null,
"resource": null,
"experimentInfo": null,
"prices": [
{
"usageLimit": 5,
"price": {
"__typename": "Price",
"priceFragment": {
"billingModel": {
"rawValue": "PER_UNIT"
},
"billingPeriod": {
"rawValue": "MONTHLY"
},
"billingId": "price_1OEuj0AnAO1PFouUPwz1QA7U",
"minUnitQuantity": 5,
"maxUnitQuantity": null,
"billingCountryCode": null,
"price": {
"amount": 6,
"currency": {
"rawValue": "USD"
}
},
"tiersMode": null,
"tiers": null,
"feature": {
"refId": "feature-01-templates",
"featureUnits": "template",
"featureUnitsPlural": "templates",
"displayName": "Templates",
"description": null
}
}
}
}
],
"totalPrice": {
"__typename": "CustomerSubscriptionTotalPrice",
"totalPriceFragment": {
"subTotal": {
"amount": 30,
"currency": {
"rawValue": "USD"
}
},
"total": {
"amount": 30,
"currency": {
"rawValue": "USD"
}
}
}
},
"plan": {
"id": "7a3979c1-c553-4338-a5b3-c7523bec288f",
"refId": "plan-revvenu-essentials"
},
"addons": [],
"customer": {
"id": "a7b2a41b-1f2c-40ab-b639-ef345e5adf17",
"refId": "customer-demo-01"
}
}
}
}
var res = await stigg.CancelSubscription.ExecuteAsync(new SubscriptionCancellationInput()
{
SubscriptionRefId = "subscription-plan-revvenu-essentials-cpzi7p2g09",
SubscriptionCancellationTime = SubscriptionCancellationTime.END_OF_BILLING_PERIOD, // optional
});
Show Result
{
"cancel_subscription": {
"id": "subscription-plan-revvenu-growth-589879",
"status": "CANCELED",
"metadata": null,
"billing_id": "sub_1LxD4TE1gVT2zwZVSav7tZvC",
"billing_link_url": "https:\/\/dashboard.stripe.com\/test\/subscriptions\/sub_1LxD4TE1gVT2zwZVSav7tZvC",
"effective_end_date": "2022-10-30T23:54:38.582Z",
"current_billing_period_end": "2022-11-26T17:07:17.000Z",
"pricing_type": "PAID",
"prices": [
{
"usage_limit": 2,
"price": {
"__typename": "Price",
"billing_model": "PER_UNIT",
"billing_period": "MONTHLY",
"price": {
"amount": 1,
"currency": "USD"
},
"feature": {
"__typename": "Feature",
"id": "feature-01-templates",
"feature_type": "NUMBER",
"meter_type": "Fluctuating",
"feature_units": "template",
"feature_units_plural": "templates",
"display_name": "Templates",
"description": null
}
}
}
],
"total_price": {
"sub_total": {
"amount": 17,
"currency": "USD"
},
"total": {
"amount": 17,
"currency": "USD"
}
},
"plan": {
"id": "plan-revvenu-growth"
},
"addons": [
{
"quantity": 3,
"addon": {
"id": "addon-10-campaigns"
}
}
],
"customer": {
"id": "customer-demo-01"
}
}
}
Subscription cancellation will take place according to the defined product behavior.
Used to check if the customer has access to a feature, the usage limit, and the current usage.
var resp = await stigg.GetEntitlement.ExecuteAsync(new FetchEntitlementQuery()
{
CustomerId = "customer-demo-01",
FeatureId = "feature-02-templates",
ResourceId = "site-1" // optional
});
Show Result
{
"entitlement": {
"__typename": "Entitlement",
"entitlementFragment": {
"isGranted": false,
"accessDeniedReason": {
"rawValue": "RequestedUsageExceedingLimit"
},
"customerId": null,
"resourceId": null,
"usageLimit": 5,
"hasUnlimitedUsage": false,
"currentUsage": 3,
"requestedUsage": 10,
"entitlementUpdatedAt": null,
"usageUpdatedAt": null,
"usagePeriodAnchor": null,
"usagePeriodStart": null,
"usagePeriodEnd": null,
"resetPeriod": null,
"resetPeriodConfiguration": null,
"feature": {
"__typename": "EntitlementFeature",
"featureFragment": {
"featureType": {
"rawValue": "NUMBER"
},
"meterType": {
"rawValue": "Fluctuating"
},
"featureUnits": "template",
"featureUnitsPlural": "templates",
"description": null,
"displayName": "Templates",
"refId": "feature-01-templates"
}
}
}
}
}
Used to check to what features the customer has access to, the usage limit , and the current usage of each entitlement.
var resp = await stigg.GetEntitlements.ExecuteAsync(new FetchEntitlementsQuery()
{
CustomerId = "customer-demo-01",
ResourceId = "site-1" // optional resource ID
});
Show Result
{
"entitlements": [
{
"__typename": "Entitlement",
"entitlementFragment": {
"isGranted": true,
"accessDeniedReason": null,
"customerId": null,
"resourceId": null,
"usageLimit": null,
"hasUnlimitedUsage": false,
"currentUsage": null,
"requestedUsage": null,
"entitlementUpdatedAt": null,
"usageUpdatedAt": null,
"usagePeriodAnchor": null,
"usagePeriodStart": null,
"usagePeriodEnd": null,
"resetPeriod": null,
"resetPeriodConfiguration": null,
"feature": {
"__typename": "EntitlementFeature",
"featureFragment": {
"featureType": {
"rawValue": "BOOLEAN"
},
"meterType": {
"rawValue": "None"
},
"featureUnits": null,
"featureUnitsPlural": null,
"description": null,
"displayName": "Analytics",
"refId": "feature-04-analytics"
}
}
}
},
{
"__typename": "Entitlement",
"entitlementFragment": {
"isGranted": true,
"accessDeniedReason": null,
"customerId": null,
"resourceId": null,
"usageLimit": 100,
"hasUnlimitedUsage": false,
"currentUsage": null,
"requestedUsage": null,
"entitlementUpdatedAt": null,
"usageUpdatedAt": null,
"usagePeriodAnchor": null,
"usagePeriodStart": null,
"usagePeriodEnd": null,
"resetPeriod": null,
"resetPeriodConfiguration": null,
"feature": {
"__typename": "EntitlementFeature",
"featureFragment": {
"featureType": {
"rawValue": "NUMBER"
},
"meterType": {
"rawValue": "None"
},
"featureUnits": "MB",
"featureUnitsPlural": "MB",
"description": null,
"displayName": "Max file size",
"refId": "feature-06-max-file-size"
}
}
}
},
{
"__typename": "Entitlement",
"entitlementFragment": {
"isGranted": true,
"accessDeniedReason": null,
"customerId": null,
"resourceId": null,
"usageLimit": 25000,
"hasUnlimitedUsage": false,
"currentUsage": 0,
"requestedUsage": null,
"entitlementUpdatedAt": null,
"usageUpdatedAt": 1700595037.13,
"usagePeriodAnchor": 1703116800,
"usagePeriodStart": 1703116800,
"usagePeriodEnd": 1700568000,
"resetPeriod": {
"rawValue": "MONTH"
},
"resetPeriodConfiguration": {
"__typename": "MonthlyResetPeriodConfig",
"resetPeriodConfigurationFragment": {
"__typename": "MonthlyResetPeriodConfig",
"onMonthlyResetPeriodConfig": {
"monthlyAccordingTo": {
"rawValue": "SubscriptionStart"
}
},
"onWeeklyResetPeriodConfig": null
}
},
"feature": {
"__typename": "EntitlementFeature",
"featureFragment": {
"featureType": {
"rawValue": "NUMBER"
},
"meterType": {
"rawValue": "Incremental"
},
"featureUnits": "active user",
"featureUnitsPlural": "active users",
"description": null,
"displayName": "Active users",
"refId": "feature-07-active-users"
}
}
}
},
{
"__typename": "Entitlement",
"entitlementFragment": {
"isGranted": true,
"accessDeniedReason": null,
"customerId": null,
"resourceId": null,
"usageLimit": 12,
"hasUnlimitedUsage": false,
"currentUsage": 0,
"requestedUsage": null,
"entitlementUpdatedAt": null,
"usageUpdatedAt": 1700595037.13,
"usagePeriodAnchor": 1703116800,
"usagePeriodStart": 1703116800,
"usagePeriodEnd": 1700568000,
"resetPeriod": {
"rawValue": "MONTH"
},
"resetPeriodConfiguration": {
"__typename": "MonthlyResetPeriodConfig",
"resetPeriodConfigurationFragment": {
"__typename": "MonthlyResetPeriodConfig",
"onMonthlyResetPeriodConfig": {
"monthlyAccordingTo": {
"rawValue": "SubscriptionStart"
}
},
"onWeeklyResetPeriodConfig": null
}
},
"feature": {
"__typename": "EntitlementFeature",
"featureFragment": {
"featureType": {
"rawValue": "NUMBER"
},
"meterType": {
"rawValue": "Incremental"
},
"featureUnits": "campaign",
"featureUnitsPlural": "campaigns",
"description": null,
"displayName": "Campaigns",
"refId": "feature-02-campaigns"
}
}
}
},
{
"__typename": "Entitlement",
"entitlementFragment": {
"isGranted": true,
"accessDeniedReason": null,
"customerId": null,
"resourceId": null,
"usageLimit": 5,
"hasUnlimitedUsage": false,
"currentUsage": 3,
"requestedUsage": null,
"entitlementUpdatedAt": null,
"usageUpdatedAt": 1700594586.26,
"usagePeriodAnchor": null,
"usagePeriodStart": null,
"usagePeriodEnd": null,
"resetPeriod": null,
"resetPeriodConfiguration": null,
"feature": {
"__typename": "EntitlementFeature",
"featureFragment": {
"featureType": {
"rawValue": "NUMBER"
},
"meterType": {
"rawValue": "Fluctuating"
},
"featureUnits": "template",
"featureUnitsPlural": "templates",
"description": null,
"displayName": "Templates",
"refId": "feature-01-templates"
}
}
}
},
{
"__typename": "Entitlement",
"entitlementFragment": {
"isGranted": true,
"accessDeniedReason": null,
"customerId": null,
"resourceId": null,
"usageLimit": null,
"hasUnlimitedUsage": false,
"currentUsage": null,
"requestedUsage": null,
"entitlementUpdatedAt": null,
"usageUpdatedAt": null,
"usagePeriodAnchor": null,
"usagePeriodStart": null,
"usagePeriodEnd": null,
"resetPeriod": null,
"resetPeriodConfiguration": null,
"feature": {
"__typename": "EntitlementFeature",
"featureFragment": {
"featureType": {
"rawValue": "BOOLEAN"
},
"meterType": {
"rawValue": "None"
},
"featureUnits": null,
"featureUnitsPlural": null,
"description": null,
"displayName": "Custom domain",
"refId": "feature-03-custom-domain"
}
}
}
}
]
}
The Stigg SDK allows you to report usage measurements for metered features. The reported usage will be used to track, limit and bill the customer’s usage of metered features.
Stigg supports metering of usage from the following data sources:
More details about Stigg’s metering and aggregation capabilities can be found here:
Validating that a measurement was successfully reported to Stigg is also possible in the customer details section of the relevant customer in the Stigg app.
var resp = await stigg.ReportUsage.ExecuteAsync(new ReportUsageInput()
{
CustomerId = "customer-demo-01",
FeatureId = "feature-02-campaigns",
ResourceId = "site-1" // optional resource ID
Value = 1
});
By default, the value reported should represent the change in usage of the feature, for example user added 2 more seats then the report usage call should have the value of 2.
In some cases, it’s more useful to set the usage to some value instead of reporting the change value, it’s possible by passing the updateBehavior
parameter:
var resp = await stigg.ReportUsage.ExecuteAsync(new ReportUsageInput()
{
CustomerId = "customer-demo-01",
FeatureId = "feature-02-campaigns",
ResourceId = "site-1" // optional resource ID
Value = 3
UpdateBehavior = UsageUpdateBehavior.Set
});
Show Result
{
"reportUsage": {
"id": "5fc41989-e624-4240-a482-c588b4255791",
"currentUsage": 3,
"usagePeriodEnd": 1700568000,
"usagePeriodEnd": 1703116800,
"timestamp": 1700595372.708
}
}
var resp = await stigg.ReportEvent.ExecuteAsync(new UsageEventsReportInput()
{
UsageEvents = new List<UsageEventReportInput>()
{
new()
{
CustomerId = "customer-demo-01",
EventName = "user_login",
Dimensions = JsonSerializer.SerializeToElement(new { user_id = "1" }),
IdempotencyKey = Guid.NewGuid().ToString(),
}
}
});
It’s also possible to send a batch of events in one invocation. To do so, simply pass an array of events to the reportEvent
method.
var resp = await stigg.GetCoupons.ExecuteAsync();
Show Result
{
"coupons": {
"edges": [
{
"node": {
"__typename": "Coupon",
"couponFragment": {
"id": "8fe11e1f-7dc2-4a82-b357-c1c3dc738660",
"discountValue": 20,
"type": {
"rawValue": "PERCENTAGE"
},
"additionalMetaData": null,
"refId": "coupon-vip",
"name": "VIP",
"description": null,
"createdAt": 1700576088.148,
"updatedAt": 1700576091.342,
"billingId": "9zQ41isX",
"billingLinkUrl": "https://dashboard.stripe.com/test/coupons/9zQ41isX",
"status": {
"rawValue": "ACTIVE"
},
"syncStates": [
{
"vendorIdentifier": {
"rawValue": "STRIPE"
},
"status": {
"rawValue": "SUCCESS"
}
}
],
"customers": []
}
}
}
]
}
}
You can grant promotional entitlements for customers using the GrantPromotionalEntitlements
method.
var resp = await stigg.GrantPromotionalEntitlements.ExecuteAsync(new GrantPromotionalEntitlementsInput()
{
CustomerId = "customer-demo-01",
PromotionalEntitlements = new List<GrantPromotionalEntitlementInput>()
{
new()
{
FeatureId = "feature-04-analytics",
Period = PromotionalEntitlementPeriod.Lifetime
},
new()
{
FeatureId = "feature-02-campaigns",
Period = PromotionalEntitlementPeriod.Custom,
CustomEndDate = DateTime.Now.AddDays(15),
UsageLimit = 100
}
}
});
Show Result
{
"grantPromotionalEntitlements": [
{
"__typename": "PromotionalEntitlement",
"promotionalEntitlementFragment": {
"status": {
"rawValue": "Active"
},
"usageLimit": null,
"featureId": "0937bf25-2fec-457b-a1f5-bd470396a100",
"hasUnlimitedUsage": null,
"resetPeriod": null,
"endDate": 1703188217.659,
"isVisible": true,
"feature": {
"featureType": {
"rawValue": "BOOLEAN"
},
"meterType": {
"rawValue": "None"
},
"featureUnits": null,
"featureUnitsPlural": null,
"displayName": "Analytics",
"description": null,
"refId": "feature-04-analytics",
"additionalMetaData": null
}
}
},
{
"__typename": "PromotionalEntitlement",
"promotionalEntitlementFragment": {
"status": {
"rawValue": "Active"
},
"usageLimit": 100,
"featureId": "cce3f1fe-494e-472a-919d-5135bb932349",
"hasUnlimitedUsage": null,
"resetPeriod": null,
"endDate": 1703188216.028,
"isVisible": true,
"feature": {
"featureType": {
"rawValue": "NUMBER"
},
"meterType": {
"rawValue": "Incremental"
},
"featureUnits": "campaign",
"featureUnitsPlural": "campaigns",
"displayName": "Campaigns",
"description": null,
"refId": "feature-02-campaigns",
"additionalMetaData": null
}
}
}
]
}
You can revoke promotional entitlements from customer using the RevokePromotionalEntitlement
method.
await stigg.RevokePromotionalEntitlement.ExecuteAsync(new RevokePromotionalEntitlementInput()
{
CustomerId = "customer-demo-01",
FeatureId = "feature-04-analytics"
});
Show Result
{
"revokePromotionalEntitlement": {
"id": "f77c7c8c-098b-42f2-a82b-134f69241e2d"
}
}
You can estimate the subscription cost using the EstimateSubscription
method. This can help the customer to understand the costs before paying.
var resp = await stigg.EstimateSubscription.ExecuteAsync(new EstimateSubscriptionInput()
{
CustomerId = "customer-demo-01",
PlanId = "plan-revvenu-essentials",
BillableFeatures = new List<BillableFeatureInput>()
{
new()
{
FeatureId = "feature-01-templates",
Quantity = 5
}
},
Addons = new List<SubscriptionAddonInput>()
{
new()
{
AddonId = "addon-10-campaigns",
Quantity = 5
}
},
});
Show Result
{
"estimateSubscription": {
"__typename": "SubscriptionPreview",
"subscriptionPreviewFragment": {
"subTotal": {
"amount": 24.88,
"currency": {
"rawValue": "USD"
}
},
"totalExcludingTax": {
"amount": 24.88,
"currency": {
"rawValue": "USD"
}
},
"total": {
"amount": 2.89,
"currency": {
"rawValue": "USD"
}
},
"discountAmount": null,
"taxDetails": null,
"tax": {
"amount": 0,
"currency": {
"rawValue": "USD"
}
},
"billingPeriodRange": {
"start": 1700596892.977,
"end": 1703188892.977
},
"discount": null,
"subscription": {
"subTotal": {
"amount": 55,
"currency": {
"rawValue": "USD"
}
},
"totalExcludingTax": {
"amount": 55,
"currency": {
"rawValue": "USD"
}
},
"total": {
"amount": 55,
"currency": {
"rawValue": "USD"
}
},
"tax": {
"amount": 0,
"currency": {
"rawValue": "USD"
}
},
"discountAmount": null,
"taxDetails": null,
"discount": null
},
"proration": {
"prorationDate": 1700596893,
"credit": {
"amount": 0,
"currency": {
"rawValue": "USD"
}
},
"debit": {
"amount": 24.88,
"currency": {
"rawValue": "USD"
}
},
"netAmount": {
"amount": 24.88,
"currency": {
"rawValue": "USD"
}
}
},
"isPlanDowngrade": null,
"hasScheduledUpdates": null,
"credits": {
"initial": {
"amount": 21.99,
"currency": {
"rawValue": "USD"
}
},
"used": {
"amount": 21.99,
"currency": {
"rawValue": "USD"
}
},
"remaining": {
"amount": 0,
"currency": {
"rawValue": "USD"
}
}
}
}
}
}
You can also estimate the cost of updating an existing subscription using the EstimateSubscriptionUpdate
method, which also returns a breakdown of the proration amounts:
var resp = await stigg.EstimateSubscriptionUpdate.ExecuteAsync(new EstimateSubscriptionUpdateInput()
{
SubscriptionId = "subscription-plan-revvenu-essentials-bum2flivze",
BillableFeatures = new List<BillableFeatureInput>()
{
new()
{
FeatureId = "feature-01-templates",
Quantity = 5
}
},
Addons = new List<SubscriptionAddonInput>()
{
new()
{
AddonId = "addon-10-campaigns",
Quantity = 5
}
},
});
Show Result
{
"estimateSubscriptionUpdate": {
"__typename": "SubscriptionPreview",
"subscriptionPreviewFragment": {
"subTotal": {
"amount": 24.87,
"currency": {
"rawValue": "USD"
}
},
"totalExcludingTax": {
"amount": 24.87,
"currency": {
"rawValue": "USD"
}
},
"total": {
"amount": 2.8800000000000026,
"currency": {
"rawValue": "USD"
}
},
"discountAmount": null,
"taxDetails": null,
"tax": {
"amount": 0,
"currency": {
"rawValue": "USD"
}
},
"billingPeriodRange": {
"start": 1700583990,
"end": 1703175990
},
"discount": null,
"subscription": {
"subTotal": {
"amount": 55,
"currency": {
"rawValue": "USD"
}
},
"totalExcludingTax": {
"amount": 55,
"currency": {
"rawValue": "USD"
}
},
"total": {
"amount": 55,
"currency": {
"rawValue": "USD"
}
},
"tax": {
"amount": 0,
"currency": {
"rawValue": "USD"
}
},
"discountAmount": null,
"taxDetails": null,
"discount": null
},
"proration": {
"prorationDate": 1700597071,
"credit": {
"amount": 0,
"currency": {
"rawValue": "USD"
}
},
"debit": {
"amount": 24.87,
"currency": {
"rawValue": "USD"
}
},
"netAmount": {
"amount": 24.87,
"currency": {
"rawValue": "USD"
}
}
},
"isPlanDowngrade": null,
"hasScheduledUpdates": null,
"credits": {
"initial": {
"amount": 21.99,
"currency": {
"rawValue": "USD"
}
},
"used": {
"amount": 21.99,
"currency": {
"rawValue": "USD"
}
},
"remaining": {
"amount": 0,
"currency": {
"rawValue": "USD"
}
}
}
}
}
}