Overview
This library provides a Java client to interact with Stigg’s GraphQL API based on API operations that are in use by the Stigg’s Node.js SDK By leveraging Apollo Kotlin to generate Java classes for GraphQL types, and okhttp as default HTTP client responses are being automatically converted to native Java classes.Installing the SDK
The first step is to add the SDK as a dependency in your Java application :Copy
Ask AI
dependencies {
implementation 'io.stigg:stigg-api-client:+'
implementation 'com.apollographql.apollo3:apollo-runtime:3.8.2'
implementation 'com.apollographql.apollo3:apollo-api-jvm:3.8.2'
implementation 'com.apollographql.apollo3:apollo-adapters-jvm:3.8.2'
}
repositories {
mavenCentral()
}
It’s recommended to hard code the
stigg-api-client
version according to the latest version available hereRetrieving the server API Key
In the Stigg Cloud Console, go to Settings > Account > Environments. Copy the Server API key of the relevant environment.Initializing the SDK
Import the Stigg client and initialize it with the API key. Synchronous client:Copy
Ask AI
import io.stigg.api.client.Stigg;
class App {
public static void main(String[] ...args) {
var stigg = Stigg.createClient("<SERVER-API-KEY>");
}
}
Provisioning customers
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 passsubscriptionParams
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.
Copy
Ask AI
var resp = stigg.mutation(
ProvisionCustomerMutation.builder()
.input(ProvisionCustomerInput.builder()
// all fields are optional
.customerId("customer-81726628184")
.name("Acme")
.email("john@example.com")
.billingInformation(CustomerBillingInfo.builder()
.billingAddress(Address.builder()
.country("US")
.city("New York")
.state("NY")
.addressLine1("123 Main Street")
.addressLine2("Apt. 1")
.phoneNumber("+1 212-499-5321")
.postalCode("10164")
.build())
.build())
.additionalMetaData(new HashMap<>() {{
put("key", "value");
}})
.subscriptionParams(ProvisionCustomerSubscriptionInput.builder()
.planId("plan-revvenu-basic")
.build())
.build())
.build()
);
Show Result
Show Result
Copy
Ask AI
{
"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"
}
}
}
}
}
Updating customers
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.Copy
Ask AI
var resp = stigg.mutation(
UpdateCustomerMutation.builder()
.input(UpdateCustomerInput.builder()
.customerId("customer-demo-01")
.name("Acme")
.email("john@example.com")
.additionalMetaData(new HashMap<>() {{
put("key", "value");
}})
.billingInformation(CustomerBillingInfo.builder()
.language("en")
.timezone("America/New_York")
.currency(Currency.USD)
.taxIds(List.of(
TaxExempt.builder()
.type("vat")
.value("123456789")
.build()
))
.build())
.build())
.build()
);
Show Result
Show Result
Copy
Ask AI
{
"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"
}
}
}
}
Getting customer data
Copy
Ask AI
var resp = stigg.query(
GetCustomerByIdQuery.builder()
.input(GetCustomerByRefIdInput.builder().customerId("customer-demo-01").build())
.build()
);
Show Result
Show Result
Copy
Ask AI
{
"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"
}
}
}
}
}
}
Getting customer active subscriptions
TheGetActiveSubscriptionsList
method returns a list of slim subscription data, for extended data for a specific subscription use GetSubscription
method.
Copy
Ask AI
var resp = stigg.query(
GetActiveSubscriptionsListQuery.builder()
.input(GetActiveSubscriptionsInput.builder()
.customerId("customer-demo-01")
.resourceId("site-1") // optional resource ID
.build())
.build()
);
Show Result
Show Result
Copy
Ask AI
{
"getActiveSubscriptions": [
{
"__typename": "CustomerSubscription",
"slimSubscriptionFragmentV2": {
"subscriptionId": "subscription-plan-revvenu-essentials-cd0ba9",
"status": {
"rawValue": "ACTIVE"
},
"pricingType": {
"rawValue": "PAID"
},
"startDate": "2023-11-21T16:26:11.000Z",
"currentBillingPeriodEnd": "2023-12-21T16:26:30.000Z",
"customer": {
"customerId": "customer-demo-01",
},
"plan": {
"planId": "plan-id",
"displayName": "Plan name"
}
}
}
]
}
Getting a subscription
To retrieve extended subscription:Copy
Ask AI
var resp = stigg.query(
GetSubscriptionQuery.builder()
.input(GetSubscriptionInput.builder()
.subscriptionId("subscription-id")
.build())
.build()
);
Show Result
Show Result
Copy
Ask AI
{
"getSubscription": [
{
"__typename": "CustomerSubscription",
"slimSubscriptionFragmentV2": {
"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": []
}
}
]
}
Provision subscriptions
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.Copy
Ask AI
var resp = stigg.mutation(
ProvisionSubscriptionMutation.builder()
.input(ProvisionSubscriptionInput.builder()
.customerId("customer-demo-01")
.planId("plan-revvenu-basic")
// optional, required for multiple subscription for same product:
.resourceId("site-1")
// optional, required for paid plans:
.billingPeriod(BillingPeriod.MONTHLY)
// optional, required for plans with per-unit pricing with charges:
.billableFeatures(List.of(
BillableFeatureInput.builder()
.featureId("feature-01-templates")
.quantity(2.0)
.build()
))
// optional:
.addons(List.of(
SubscriptionAddonInput.builder()
.addonId("addon-extra-stuff")
.quantity(5)
.build()
))
// optional, required for price localization, must be in the ISO-3166-1 format:
.billingCountryCode("DK")
// optional, but will throw if missing and no customer payment method is available:
.checkoutOptions(
CheckoutOptions.builder()
.successUrl("https://your-success-url.com")
.cancelUrl("https://your-cancel-url.com")
.allowPromoCodes(true)
.collectBillingAddress(true)
.collectPhoneNumber(true)
.build()
)
.additionalMetaData(new HashMap<>() {{
put("key", "value");
}})
.build())
.build()
);
Show Result - Success
Show Result - Success
Copy
Ask AI
{
"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)
Show Result - Action required (3DS)
Copy
Ask AI
{
"provision_subscription": {
"subscription": {
"paymentCollection": {
"rawValue": "ACTION_REQUIRED"
},
"latestInvoice": {
"paymentUrl": "https...",
"paymentSecret": "secret",
}
}
}
}
Show Result - Payment failed
Show Result - Payment failed
Copy
Ask AI
{
"provisionSubscription": {
"subscription": {
"paymentCollection": {
"rawValue": "FAILED"
},
"latestInvoice": {
"paymentUrl": "https...",
"errorMessage": "no sufficient funds"
}
}
}
}
Show Result - Checkout
Show Result - Checkout
Copy
Ask AI
{
"provisionSubscription": {
"checkoutUrl": "https://checkout.stripe.com/c/pay/cs_test_b1PKYNIzXFR3uejdj59M0BghDF4mNtL2MoHf6vipEpREAJPQ7zhR6rlJQG#fid2cGd2ZndsdXFsamtQa2x0cGBrYHZ2QGtkZ2lgYSc%2FY2RpdmApJ3Zxd2x1YERmZmpwa3EnPydkZmZxWjROfUFIcURrREo0VUNqcFAnKSdkdWxOYHwnPyd1blpxYHZxWjA0TnZpVjZCX11oMk9QUzxWcEpPRzN8cTZQXDZSSDRwcGRpQ3BiZ0w8NDY9PFZiX2REa0tHZzJDdXBHTD1caEN%2FQ3doS21Abn00REhDUH12cW50fW9rcHJ0NTVwVTxpdEFsMicpJ2N3amhWYHdzYHcnP3F3cGApJ2lkfGpwcVF8dWAnPydocGlxbFpscWBoJyknYGtkZ2lgVWlkZmBtamlhYHd2Jz9xd3BgeCUl",
"status": {
"rawValue": "PAYMENT_REQUIRED"
},
"subscription": null
}
}
- A customer can have both a non-trial (free or paid) subscription and trial subscription to different plans of the same product in parallel - this logic allows customers to trial a higher tier plan, while still paying for an existing plan.
- When the customer has a trial subscription for plan X of product A and a new subscription is created for the same plan, the new subscription will be created as as non-trial (paid) subscription - this logic follows an upgrade flow of a trial subscription to a paid subscription of a specific plan.
- Except in the above mentioned cases, when a customer has an active subscription for product X, and another subscription for the same product is created with start date S, the existing subscription will automatically be cancelled and the new subscription will start on start date S.
- It’s also possible to explicitly skip the trial period of the selected plan by providing the
skipTrial: true
parameter to theprovisionSubscription()
method.
Updating subscriptions
Updating an existing subscription, this can be used to update the feature quantity that the customer is subscribed for or the add-ons.Copy
Ask AI
var resp = stigg.mutation(
UpdateSubscriptionMutation.builder()
.input(
UpdateSubscriptionInput.builder()
.subscriptionId("subscription-plan-revvenu-essentials-bum2flivze")
.billableFeatures(List.of(
BillableFeatureInput.builder()
.featureId("feature-01-templates")
.quantity(5.0)
.build()
))
// optional:
.addons(List.of(
SubscriptionAddonInput.builder()
.addonId("addon-extra-stuff")
.quantity(5)
.build()
))
.build()
)
.build()
);
Show Result
Show Result
Copy
Ask AI
{
"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"
}
}
}
}
Cancel subscription
Copy
Ask AI
var resp =
stigg.mutation(
CancelSubscriptionMutation.builder()
.input(
SubscriptionCancellationInput.builder()
.subscriptionRefId("subscription-plan-revvenu-essentials-bum2flivze")
// optional:
.subscriptionCancellationAction(SubscriptionCancellationAction.DEFAULT)
// optional:
.subscriptionCancellationTime(SubscriptionCancellationTime.END_OF_BILLING_PERIOD)
.build())
.build());
Show Result
Show Result
Copy
Ask AI
{
"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.
Getting the entitlement of a customer for a specific feature
Used to check if the customer has access to a feature, the usage limit, and the current usage.Copy
Ask AI
var resp =
stigg.query(
GetEntitlementQuery.builder()
.query(FetchEntitlementQuery.builder()
.customerId("customer-demo-01")
.featureId("feature-01-templates")
.options(EntitlementOptions.builder()
.requestedUsage(10.0)
.build())
.resourceId("site-1") // optional resource ID
.build())
.build()
);
Show Result
Show Result
Copy
Ask AI
{
"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,
"usagePeriodEnd": null,
"usagePeriodEnd": 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"
}
}
}
}
}
Getting all of the entitlements of a customer
Used to check to what features the customer has access to, the usage limit , and the current usage of each entitlement.Copy
Ask AI
var resp =
stigg.query(
GetEntitlementsQuery.builder()
.query(
FetchEntitlementsQuery.builder()
.customerId("customer-demo-01")
.resourceId("site-1") // optional resource ID
.build())
.build());
Show Result
Show Result
Copy
Ask AI
{
"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"
}
}
}
}
]
}
Getting paywall data
Useful for rendering the public pricing page or customer paywall.Copy
Ask AI
var resp = stigg.query(GetPaywallQuery.builder()
.input(GetPaywallInput.builder()
// optional, filters by product
.productId("product-revvenu")
// optional, omit if customer doesn't exist yet
.customerId("customer-demo-01")
// optional
.resourceId("resource-01")
// optional, for localized prices
.billingCountryCode("US")
// optional, fetches all countries prices
.fetchAllCountriesPrices(false)
.build())
.build());
Show Result
Show Result
Copy
Ask AI
{
"paywall" : {
"__typename" : "Paywall",
"paywallFragment" : {
"plans" : [ {
"__typename" : "Plan",
"planFragment" : {
"id" : "5c4e7d78-de1d-4e5b-a45b-cc654954b963",
"refId" : "plan-revvenu-basic",
"displayName" : "Basic",
"description" : null,
"billingId" : "prod_SHVZXN9YGpXVWg",
"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.0,
"hasUnlimitedUsage" : null,
"featureId" : "2ce7e908-87ac-4232-8367-246cd212eb38",
"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.0,
"hasUnlimitedUsage" : null,
"featureId" : "495cd082-249f-472b-b80b-f2dc3022c464",
"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.0,
"hasUnlimitedUsage" : null,
"featureId" : "7bf6d8b6-4c5a-4855-a5eb-425e8988236f",
"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.0,
"hasUnlimitedUsage" : null,
"featureId" : "e017a084-7879-42a0-83d2-897ec0ab07cf",
"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
}
}, {
"__typename" : "Plan",
"planFragment" : {
"id" : "e1ce548a-2978-4ffa-a5c3-f555b8729aa7",
"refId" : "plan-revvenu-essentials",
"displayName" : "Essentials",
"description" : null,
"billingId" : "prod_SHVZTqzMf6H3iT",
"versionNumber" : 2,
"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" : 120.0,
"hasUnlimitedUsage" : null,
"featureId" : "495cd082-249f-472b-b80b-f2dc3022c464",
"resetPeriod" : {
"rawValue" : "DAY"
},
"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.0,
"hasUnlimitedUsage" : null,
"featureId" : "7bf6d8b6-4c5a-4855-a5eb-425e8988236f",
"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.0,
"hasUnlimitedUsage" : null,
"featureId" : "e017a084-7879-42a0-83d2-897ec0ab07cf",
"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" : "7f70a8b0-4e1d-435b-b852-4a060a3a46c2",
"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
}
}
}, {
"__typename" : "PackageEntitlement",
"packageEntitlementFragment" : {
"usageLimit" : null,
"hasUnlimitedUsage" : false,
"featureId" : "32346f06-0a13-4914-888b-a2a4a9528cd7",
"resetPeriod" : null,
"hiddenFromWidgets" : [ ],
"isCustom" : null,
"displayNameOverride" : null,
"feature" : {
"featureType" : {
"rawValue" : "BOOLEAN"
},
"meterType" : {
"rawValue" : "None"
},
"featureUnits" : null,
"featureUnitsPlural" : null,
"displayName" : "Custom domain",
"description" : null,
"refId" : "feature-03-custom-domain",
"additionalMetaData" : null
}
}
} ],
"inheritedEntitlements" : [ ],
"compatibleAddons" : [ {
"__typename" : "Addon",
"addonFragment" : {
"id" : "0660c5f7-7e07-4657-8568-e490601e35ee",
"refId" : "addon-10-campaigns",
"billingId" : "prod_SHVZMZVcHz9P1T",
"displayName" : "10 campaigns",
"description" : "Additional quota of 10 campaigns",
"additionalMetaData" : null,
"entitlements" : [ {
"__typename" : "PackageEntitlement",
"packageEntitlementFragment" : {
"usageLimit" : 10.0,
"hasUnlimitedUsage" : null,
"featureId" : "495cd082-249f-472b-b80b-f2dc3022c464",
"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_1RMwXtAnAO1PFouUm9Piixnk",
"minUnitQuantity" : null,
"maxUnitQuantity" : null,
"billingCountryCode" : null,
"price" : {
"amount" : 5.0,
"currency" : {
"rawValue" : "USD"
}
},
"tiersMode" : null,
"tiers" : null,
"feature" : null
}
}, {
"__typename" : "Price",
"priceFragment" : {
"billingModel" : {
"rawValue" : "FLAT_FEE"
},
"billingPeriod" : {
"rawValue" : "ANNUALLY"
},
"billingId" : "price_1RMwXtAnAO1PFouUoUeQkvdU",
"minUnitQuantity" : null,
"maxUnitQuantity" : null,
"billingCountryCode" : null,
"price" : {
"amount" : 54.0,
"currency" : {
"rawValue" : "USD"
}
},
"tiersMode" : null,
"tiers" : null,
"feature" : null
}
} ],
"pricingType" : {
"rawValue" : "PAID"
}
}
} ],
"prices" : [ {
"__typename" : "Price",
"priceFragment" : {
"billingModel" : {
"rawValue" : "PER_UNIT"
},
"billingPeriod" : {
"rawValue" : "MONTHLY"
},
"billingId" : "price_1RMwXvAnAO1PFouUzlf4YG5j",
"minUnitQuantity" : 5.0,
"maxUnitQuantity" : null,
"billingCountryCode" : null,
"price" : {
"amount" : 6.0,
"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" : "ANNUALLY"
},
"billingId" : "price_1RMwXvAnAO1PFouUM5jLNebw",
"minUnitQuantity" : 5.0,
"maxUnitQuantity" : null,
"billingCountryCode" : null,
"price" : {
"amount" : 60.0,
"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
}
}, {
"__typename" : "Plan",
"planFragment" : {
"id" : "2d589501-d53d-4991-b48e-b7481129e4cf",
"refId" : "plan-revvenu-pro",
"displayName" : "Professional",
"description" : null,
"billingId" : "prod_SHVZkaUkjSiWKr",
"versionNumber" : 2,
"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-essentials",
"displayName" : "Essentials"
},
"entitlements" : [ {
"__typename" : "PackageEntitlement",
"packageEntitlementFragment" : {
"usageLimit" : null,
"hasUnlimitedUsage" : null,
"featureId" : "2ce7e908-87ac-4232-8367-246cd212eb38",
"resetPeriod" : null,
"hiddenFromWidgets" : [ ],
"isCustom" : true,
"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" : null,
"hasUnlimitedUsage" : null,
"featureId" : "495cd082-249f-472b-b80b-f2dc3022c464",
"resetPeriod" : {
"rawValue" : "MONTH"
},
"hiddenFromWidgets" : [ ],
"isCustom" : true,
"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" : null,
"hasUnlimitedUsage" : null,
"featureId" : "7bf6d8b6-4c5a-4855-a5eb-425e8988236f",
"resetPeriod" : {
"rawValue" : "MONTH"
},
"hiddenFromWidgets" : [ ],
"isCustom" : true,
"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" : null,
"hasUnlimitedUsage" : true,
"featureId" : "e017a084-7879-42a0-83d2-897ec0ab07cf",
"resetPeriod" : null,
"hiddenFromWidgets" : [ ],
"isCustom" : null,
"displayNameOverride" : "No 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" : "0f95c87d-6e04-4a78-a279-3f08b68642b2",
"resetPeriod" : null,
"hiddenFromWidgets" : [ ],
"isCustom" : null,
"displayNameOverride" : null,
"feature" : {
"featureType" : {
"rawValue" : "BOOLEAN"
},
"meterType" : {
"rawValue" : "None"
},
"featureUnits" : null,
"featureUnitsPlural" : null,
"displayName" : "Integrations",
"description" : null,
"refId" : "feature-05-integrations",
"additionalMetaData" : null
}
}
} ],
"inheritedEntitlements" : [ {
"__typename" : "PackageEntitlement",
"packageEntitlementFragment" : {
"usageLimit" : null,
"hasUnlimitedUsage" : false,
"featureId" : "32346f06-0a13-4914-888b-a2a4a9528cd7",
"resetPeriod" : null,
"hiddenFromWidgets" : [ ],
"isCustom" : null,
"displayNameOverride" : null,
"feature" : {
"featureType" : {
"rawValue" : "BOOLEAN"
},
"meterType" : {
"rawValue" : "None"
},
"featureUnits" : null,
"featureUnitsPlural" : null,
"displayName" : "Custom domain",
"description" : null,
"refId" : "feature-03-custom-domain",
"additionalMetaData" : null
}
}
}, {
"__typename" : "PackageEntitlement",
"packageEntitlementFragment" : {
"usageLimit" : null,
"hasUnlimitedUsage" : null,
"featureId" : "7f70a8b0-4e1d-435b-b852-4a060a3a46c2",
"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
}
}
} ],
"compatibleAddons" : [ ],
"prices" : [ ],
"pricingType" : {
"rawValue" : "CUSTOM"
},
"defaultTrialConfig" : null
}
} ],
"currency" : {
"__typename" : "PaywallCurrency",
"paywallCurrencyFragment" : {
"code" : {
"rawValue" : "USD"
},
"symbol" : "$"
}
},
"configuration" : {
"__typename" : "PaywallConfiguration",
"paywallConfigurationFragment" : {
"palette" : {
"primary" : "#2e7d32",
"textColor" : "#000000",
"backgroundColor" : null,
"borderColor" : null,
"currentPlanBackground" : "#f5fbf7"
},
"typography" : {
"__typename" : "TypographyConfiguration",
"typographyConfigurationFragment" : {
"fontFamily" : null,
"h1" : {
"__typename" : "FontVariant",
"fontVariantFragment" : {
"fontSize" : 28.0,
"fontWeight" : null
}
},
"h2" : {
"__typename" : "FontVariant",
"fontVariantFragment" : {
"fontSize" : 20.0,
"fontWeight" : null
}
},
"h3" : {
"__typename" : "FontVariant",
"fontVariantFragment" : {
"fontSize" : 14.0,
"fontWeight" : null
}
},
"body" : null
}
},
"layout" : {
"__typename" : "PaywallLayoutConfiguration",
"layoutConfigurationFragment" : {
"alignment" : null,
"planWidth" : 320.0,
"planMargin" : 20.0,
"planPadding" : 32.0
}
},
"customCss" : null
}
},
"customer" : null,
"activeSubscriptions" : null,
"resource" : null,
"paywallCalculatedPricePoints" : [ {
"__typename" : "PaywallPricePoint",
"paywallCalculatedPricePointsFragment" : {
"planId" : "plan-revvenu-essentials",
"additionalChargesMayApply" : true,
"billingPeriod" : {
"rawValue" : "MONTHLY"
},
"amount" : 6.0,
"currency" : {
"rawValue" : "USD"
},
"billingCountryCode" : null,
"feature" : null
}
}, {
"__typename" : "PaywallPricePoint",
"paywallCalculatedPricePointsFragment" : {
"planId" : "plan-revvenu-essentials",
"additionalChargesMayApply" : true,
"billingPeriod" : {
"rawValue" : "ANNUALLY"
},
"amount" : 60.0,
"currency" : {
"rawValue" : "USD"
},
"billingCountryCode" : null,
"feature" : null
}
} ]
}
}
}
Reporting usage measurements to Stigg
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:- Calculated usage - usage that has been aggregated and calculated by your application. This type is useful for features, such as: seats.
- Raw events - raw events from your application, which Stigg filters and aggregates aggregate to calculate customer usage. This type is useful for features, such as: monthly active users (MAUs).
Stigg's metering and aggregation capabilities
- Reporting of measurements to Stigg should be done only after the relevant resources have been provisioned in your application.
- To ensure that the provisioned resources are aligned with the measurements that are reported to Stigg, ensure that customers are not allowed to allocate new resources until an acknowledgement about the processed measurement is received from the Stigg backend.
Validating that a measurement was successfully reported to Stigg is also possible in the customer details section of the relevant customer in the Stigg Cloud Console.
Calculated usage
Copy
Ask AI
var resp =
stigg.mutation(
ReportUsageMutation.builder()
.input(
ReportUsageInput.builder()
.customerId("customer-demo-01")
.featureId("feature-01-templates")
.value(1.0)
.resourceId("site-1") // optional resource ID
.build())
.build());
updateBehavior
parameter:
Copy
Ask AI
var resp =
stigg.mutation(
ReportUsageMutation.builder()
.input(
ReportUsageInput.builder()
.customerId("customer-demo-01")
.featureId("feature-02-campaigns")
.value(3.0)
.updateBehavior(UsageUpdateBehavior.SET)
.build())
.build());
Show Result
Show Result
Copy
Ask AI
{
"reportUsage": {
"id": "5fc41989-e624-4240-a482-c588b4255791",
"currentUsage": 3,
"usagePeriodEnd": 1700568000,
"usagePeriodEnd": 1703116800,
"timestamp": 1700595372.708
}
}
Raw events
Copy
Ask AI
var resp =
stigg.mutation(
ReportEventMutation.builder()
.input(
UsageEventsReportInput.builder()
.usageEvents(List.of(
UsageEventReportInput.builder()
.customerId("customer-demo-01")
.eventName("user_login")
.idempotencyKey("227c1b73-883a-457b-b715-6ba5a2c69ce4")
.timestamp(Instant.now())
.dimensions(new HashMap<>() {{
put("user_id", "user-01");
put("ip", "127.0.0.1");
}})
.resourceId("site-1") // optional resource ID
.build()
))
.build())
.build());
reportEvent
method.
Getting available coupons
Copy
Ask AI
var resp = stigg.query(GetCouponsQuery.builder().build());
Show Result
Show Result
Copy
Ask AI
{
"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": []
}
}
}
]
}
}
Granting promotional entitlements
You can grant promotional entitlements for customers using thegrant_promotional_entitlements
method.
Copy
Ask AI
var resp =
stigg.mutation(
GrantPromotionalEntitlementsMutation.builder()
.input(
GrantPromotionalEntitlementsInput.builder()
.customerId("customer-demo-01")
.promotionalEntitlements(
List.of(
GrantPromotionalEntitlementInput.builder()
.featureId("feature-04-analytics")
.period(PromotionalEntitlementPeriod.ONE_MONTH)
.build(),
GrantPromotionalEntitlementInput.builder()
.featureId("feature-02-campaigns")
.period(PromotionalEntitlementPeriod.CUSTOM)
.customEndDate(Instant.now().atZone(ZoneId.of("UTC")).plusDays(30).toInstant())
.usageLimit(100.0)
.build()
)
)
.build())
.build()
);
Show Result
Show Result
Copy
Ask AI
{
"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
}
}
}
]
}
Revoking promotional entitlements
You can revoke promotional entitlements from customer using therevoke_promotional_entitlements
method.
Copy
Ask AI
var resp =
stigg.mutation(
RevokePromotionalEntitlementMutation.builder()
.input(
RevokePromotionalEntitlementInput.builder()
.featureId("feature-04-analytics")
.customerId("customer-demo-01")
.build()
)
.build());
Show Result
Show Result
Copy
Ask AI
{
"revokePromotionalEntitlement": {
"id": "f77c7c8c-098b-42f2-a82b-134f69241e2d"
}
}
Estimate subscription cost
You can estimate the subscription cost using theestimateSubscription
method. This can help the customer to understand the costs before paying.
Copy
Ask AI
var resp =
stigg.mutation(
EstimateSubscriptionMutation.builder()
.input(
EstimateSubscriptionInput.builder()
.customerId("customer-demo-01")
.billingPeriod(BillingPeriod.MONTHLY)
.planId("plan-revvenu-essentials")
.billableFeatures(
List.of(
BillableFeatureInput.builder()
.featureId("feature-01-templates")
.quantity(5.0)
.build()))
.addons(
List.of(
SubscriptionAddonInput.builder()
.addonId("addon-10-campaigns")
.quantity(5)
.build()))
.billingCountryCode("DK")
.resourceId("site-1") // optional resource ID
.build())
.build());
Show Result
Show Result
Copy
Ask AI
{
"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"
}
}
}
}
}
}
updateSubscription
method, which also returns a breakdown of the proration amounts:
Copy
Ask AI
var resp =
stigg.mutation(
EstimateSubscriptionUpdateMutation.builder()
.input(
EstimateSubscriptionUpdateInput.builder()
.subscriptionId("subscription-plan-revvenu-essentials-bum2flivze")
.billableFeatures(
List.of(
BillableFeatureInput.builder()
.featureId("feature-01-templates")
.quantity(5.0)
.build())
)
.addons(
List.of(
SubscriptionAddonInput.builder()
.addonId("addon-10-campaigns")
.quantity(5)
.build())
)
.build())
.build());
Show Result
Show Result
Copy
Ask AI
{
"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"
}
}
}
}
}
}