Package io.meeds.billing.service
Class BillingService
java.lang.Object
io.meeds.billing.service.BillingService
-
Constructor Summary
ConstructorsConstructorDescriptionBillingService(HubBilling hubBilling, SubscriptionEmailReminderService subscriptionEmailReminderService, org.exoplatform.social.core.space.spi.SpaceService spaceService, HubSettingService hubSettingService) -
Method Summary
Modifier and TypeMethodDescriptionvoidcancelSubscription(long spaceId, String userName) Cancels an active Stripe subscription.voidcancelSubscription(String subscriptionId) Cancels an active Stripe subscription.createCustomer(org.exoplatform.social.core.space.model.Space space, org.exoplatform.social.core.identity.model.Identity identity) Creates a new Stripe customer for the given spacecreateCustomerPortalSession(long spaceId, String userName) Creates a Stripe Billing Portal session for the given customer.createCustomerPortalSession(String customerId) Creates a Stripe Billing Portal session for the given customer.com.stripe.model.PricegetPriceById(String id) Retrieves a StripePriceobject by its unique identifier.com.stripe.model.SubscriptiongetSubscription(String subscriptionId) voidnotifyAdminsOnPlanChange(long spaceId) Sends an email to the administrators about the hub plan change.voidnotifyAdminsOnSubscriptionCancellation(String authenticatedUser, long spaceId) voidnotifyHubAdminsOnSubscriptionStatus(HubBillingSettings hubBillingSettings, String authenticatedUser) Sends an email to the hub administrator about the current subscription status.voidnotifyHubAdminsOnUsersLimitExceeded(String authenticatedUser, long spaceId) Sends an email to the administrator about the max of users exceeded.voidnotifyOnSubscriptionStatus(long spaceId, String authenticatedUser, boolean maxOfUsersExceeded) Sends an email about the current subscription status.voidreportMembersCount(HubBillingSettings hubBillingSettings) Reports the current number of members in a space to Stripe as a metered event.com.stripe.model.SubscriptionCreates a new Stripe subscription for the given customer (space).
-
Constructor Details
-
BillingService
public BillingService(HubBilling hubBilling, SubscriptionEmailReminderService subscriptionEmailReminderService, org.exoplatform.social.core.space.spi.SpaceService spaceService, HubSettingService hubSettingService)
-
-
Method Details
-
createCustomer
public String createCustomer(org.exoplatform.social.core.space.model.Space space, org.exoplatform.social.core.identity.model.Identity identity) throws com.stripe.exception.StripeException Creates a new Stripe customer for the given space- Parameters:
space-identity-- Returns:
- stripe customer ID
- Throws:
com.stripe.exception.StripeException
-
subscribe
public com.stripe.model.Subscription subscribe(org.exoplatform.social.core.space.model.Space space, String customerId, String priceId) throws com.stripe.exception.StripeException Creates a new Stripe subscription for the given customer (space).- Parameters:
space-customerId-- Returns:
- the created Stripe
Subscription - Throws:
com.stripe.exception.StripeException
-
createCustomerPortalSession
public String createCustomerPortalSession(long spaceId, String userName) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException Creates a Stripe Billing Portal session for the given customer.- Parameters:
spaceId-userName-- Returns:
- the stripe customer portal url
- Throws:
org.exoplatform.commons.exception.ObjectNotFoundExceptionIllegalAccessException
-
createCustomerPortalSession
Creates a Stripe Billing Portal session for the given customer.- Parameters:
customerId-- Returns:
- the stripe customer portal url
-
cancelSubscription
public void cancelSubscription(long spaceId, String userName) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException Cancels an active Stripe subscription.- Parameters:
spaceId-userName-- Throws:
org.exoplatform.commons.exception.ObjectNotFoundExceptionIllegalAccessException
-
cancelSubscription
Cancels an active Stripe subscription.- Parameters:
subscriptionId-
-
getSubscription
- Throws:
Exception
-
notifyOnSubscriptionStatus
public void notifyOnSubscriptionStatus(long spaceId, String authenticatedUser, boolean maxOfUsersExceeded) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException Sends an email about the current subscription status.- Parameters:
spaceId-authenticatedUser-- Throws:
IllegalAccessExceptionorg.exoplatform.commons.exception.ObjectNotFoundException
-
notifyHubAdminsOnSubscriptionStatus
public void notifyHubAdminsOnSubscriptionStatus(HubBillingSettings hubBillingSettings, String authenticatedUser) Sends an email to the hub administrator about the current subscription status.- Parameters:
hubBillingSettings-authenticatedUser-
-
notifyHubAdminsOnUsersLimitExceeded
Sends an email to the administrator about the max of users exceeded.- Parameters:
authenticatedUser-
-
notifyAdminsOnPlanChange
public void notifyAdminsOnPlanChange(long spaceId) Sends an email to the administrators about the hub plan change.- Parameters:
spaceId-
-
notifyAdminsOnSubscriptionCancellation
-
getPriceById
Retrieves a StripePriceobject by its unique identifier.- Parameters:
id- the unique identifier of the Stripe price to retrieve- Returns:
- the
Priceobject if found;nullif an error occurs or the price cannot be retrieved - Throws:
com.stripe.exception.StripeException
-
reportMembersCount
Reports the current number of members in a space to Stripe as a metered event.This method retrieves the associated Stripe meter event name from the configured meter ID, counts the members in the corresponding space, and sends a metered usage event to Stripe with the count value.
- Parameters:
hubBillingSettings- the billing settings containing the meter ID, customer ID, and space ID- Throws:
org.exoplatform.commons.exception.ObjectNotFoundException- if the space corresponding to the given space ID is not foundException- if an error occurs while communicating with Stripe or retrieving meter details
-