Interface Monetization


  • public interface Monetization
    SPI for external monetization engine integrations (e.g., Moesif + Stripe).
    • Method Detail

      • init

        default void init​(String serviceUrl)
        Initializes the implementation with the billing service base URL.
        Parameters:
        serviceUrl - the billing service base URL
      • configMonetizationSetup

        Map<String,​String> configMonetizationSetup​(String organization,
                                                         Map<String,​Object> orgContext)
                                                  throws MonetizationException
        Configures the monetization billing engine for an organization
        Parameters:
        organization - tenant/org id
        orgContext - setup context (billingEngine, stripeSecretKey, devPortalWebhookUrl, etc.)
        Returns:
        setup outputs (webhook endpoint ids, signing secret, etc.)
        Throws:
        MonetizationException - if configuration fails
      • disableMonetization

        boolean disableMonetization​(String organization,
                                    String apiIdentifier,
                                    Map<String,​Object> monetizationContext)
                             throws MonetizationException
        Disables monetization for an API
        Parameters:
        organization - organization
        apiIdentifier - API UUID
        monetizationContext - context (environment, billingEngine, etc.)
        Returns:
        true if disabled successfully
        Throws:
        MonetizationException - if disabling monetization fails
      • deleteBillingMeters

        void deleteBillingMeters​(String organization,
                                 Map<String,​Object> monetizationContext)
                          throws MonetizationException
        Deletes billing meters from the engine.
        Parameters:
        organization - organization
        monetizationContext - context (environment, billingEngine, billingMeterIds)
        Throws:
        MonetizationException - if deletion fails
      • monetizeSubscription

        Map<String,​String> monetizeSubscription​(String tenantDomain,
                                                      Map<String,​Object> subscriptionData)
                                               throws MonetizationException
        Executes the subscription monetization workflow (customer creation, billing subscription, usage metering linkage).
        Parameters:
        tenantDomain - tenant or organization
        subscriptionData - subscriber, application, API, plan, and payment details
        Returns:
        created subscription info (customerId, subscriptionId, etc.)
        Throws:
        MonetizationException - if subscription monetization fails
      • getUsageData

        Map<String,​String> getUsageData​(String tenantDomain,
                                              Map<String,​Object> usageInputContext)
                                       throws MonetizationException
        Returns current usage metrics for a subscription.
        Parameters:
        tenantDomain - tenant or organization
        usageInputContext - usage context (subscriptionId, billingMeterId, timeRange, etc.)
        Returns:
        usage data metrics
        Throws:
        MonetizationException - if usage data retrieval fails
      • getTotalRevenue

        Map<String,​String> getTotalRevenue​(String tenantDomain,
                                                 String apiIdentifier,
                                                 List<MoesifPlanInfo> moesifPlanList,
                                                 Map<String,​Object> inputContext)
                                          throws MonetizationException
        Returns aggregated revenue for an API.
        Parameters:
        tenantDomain - tenant or organization
        apiIdentifier - API UUID or identifier
        moesifPlanList - list of Moesif plan information
        inputContext - revenue context (timeRange, currency, etc.)
        Returns:
        revenue data
        Throws:
        MonetizationException - if revenue retrieval fails
      • syncBillingUser

        default void syncBillingUser​(String billingCustomerId,
                                     String userEmail,
                                     String organization,
                                     String env)
                              throws MonetizationException
        Syncs a billing user to the monetization engine.
        Parameters:
        billingCustomerId - billing customer ID
        userEmail - user email
        organization - organization
        env - environment
        Throws:
        MonetizationException - if user sync fails
      • disableBillingEngineSetup

        default void disableBillingEngineSetup​(String organization,
                                               String engineName,
                                               String env)
                                        throws MonetizationException
        Disables the billing engine setup for an organization.
        Parameters:
        organization - tenant/org id
        engineName - billing engine name (e.g. "STRIPE")
        env - environment
        Throws:
        MonetizationException - if disabling setup fails