Class SubscriptionPricingContext
- All Implemented Interfaces:
Serializable
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanbooleanMiscellaneous attributes that can be added to the context in order to provide more information.The fullCancellationPolicyfor thesubscriptionRootItemif any.com.broadleafcommerce.cart.client.domain.CartgetCart()TheCartcontaining subscriptions.javax.money.CurrencyUnitCurrency of this subscriptionGets the current subscription period definition.intGets the current subscription period number.The customer's timezone.The date at which the subscription's terms will expire.The existingSubscriptionif any.getExistingSubscriptionItem(String existingSubscriptionItemId) The existingSubscriptionif any.Map ofSubscriptionItem.getId()to the existing SubscriptionItem's quantity.getExistingSubscriptionItemQuantity(String subscriptionItemId) javax.money.MonetaryAmountgetExistingSubscriptionItemSubtotal(String subscriptionItemId) javax.money.MonetaryAmountgetExistingSubscriptionItemUnitPrice(String subscriptionItemId) Map ofSubscriptionItem.getId()to the existing SubscriptionItem's unit price.getFlow()Describes the subscription action flow that is being executed.The end date of the free trial for this subscription, if applicable, null if none applied.Describes the next time that the customer will be billed.The number of billing periods left in a term beyond the current period, if there are terms.Declares that payments made against a subscription are going towards the goods/services rendered in the previous vs current period.getPeriodDefinition(Integer period) Describes upcoming subscription billing periods, including the start date, end date, & when the customer will be billed.intThe frequency with which the recurring price should be charged., e.g., a value of 1 combined withperiodTypeof MONTH would indicate to a subscription service that the price should be charged every 1 month.The period type for the price, e.g.The frequency with which the recurring price should be charged., e.g., a value of 1 combined withperiodTypeof MONTH would indicate to a subscription service that the price should be charged every 1 month.The period type for the price, e.g.The list ofAdjustmentsbeing removed due to the proposed changes.List ofSubscriptionItemsthat are not on the cart.The date at which the subscription's terms will begin.The timestamp at which the subscription action was taken.com.broadleafcommerce.cart.client.domain.CartItemTheCartItemrepresenting the rootSubscriptionItem.protected ZoneIdReturns theZoneIdfor the given customer timezone string.booleanbooleanDetermines if the subscription has a free trial still applied.inthashCode()booleanhasTerm()booleanDetermines whether the action being performed is within the free trial timeframe, only relevant forsubscription modification flowswhen free trial is involved.booleanisCurrentPeriod(Integer periodNumber) Determines whether the given period number is the current subscription period.booleanDetermines whether an existing free trial was expired.booleanDetermines whether an existing free trial was lost, different fromexpired, due to the subscription modification.booleanvoidsetAdditionalAttributes(Map<String, Object> additionalAttributes) Miscellaneous attributes that can be added to the context in order to provide more information.voidsetCancellationPolicy(CancellationPolicy cancellationPolicy) The fullCancellationPolicyfor thesubscriptionRootItemif any.voidsetCancellationPolicyDetail(CancellationPolicyDetail cancellationPolicyDetail) voidsetCart(com.broadleafcommerce.cart.client.domain.Cart cart) TheCartcontaining subscriptions.voidsetCurrency(javax.money.CurrencyUnit currency) Currency of this subscriptionvoidsetCustomerTimezone(String customerTimezone) The customer's timezone.voidsetEndOfTermDate(Instant endOfTermDate) The date at which the subscription's terms will expire.voidsetExistingSubscription(Subscription existingSubscription) The existingSubscriptionif any.voidsetExistingSubscriptionItemById(Map<String, SubscriptionItem> existingSubscriptionItemById) The existingSubscriptionif any.voidsetExistingSubscriptionItemQuantities(Map<String, Integer> existingSubscriptionItemQuantities) Map ofSubscriptionItem.getId()to the existing SubscriptionItem's quantity.voidsetExistingSubscriptionItemUnitPrices(Map<String, javax.money.MonetaryAmount> existingSubscriptionItemUnitPrices) Map ofSubscriptionItem.getId()to the existing SubscriptionItem's unit price.voidDescribes the subscription action flow that is being executed.voidsetFreeTrialEndDate(Instant freeTrialEndDate) The end date of the free trial for this subscription, if applicable, null if none applied.voidsetNextBillDate(Instant nextBillDate) Describes the next time that the customer will be billed.voidsetNumberOfPeriodsLeftInTerm(Long numberOfPeriodsLeftInTerm) The number of billing periods left in a term beyond the current period, if there are terms.voidsetPaymentStrategy(String paymentStrategy) Declares that payments made against a subscription are going towards the goods/services rendered in the previous vs current period.voidsetPeriodDefinitions(Map<Integer, PeriodDefinition> periodDefinitions) Describes upcoming subscription billing periods, including the start date, end date, & when the customer will be billed.voidsetPeriodFrequency(int periodFrequency) The frequency with which the recurring price should be charged., e.g., a value of 1 combined withperiodTypeof MONTH would indicate to a subscription service that the price should be charged every 1 month.voidsetPeriodType(String periodType) The period type for the price, e.g.voidsetPriorPeriodFrequency(Integer priorPeriodFrequency) The frequency with which the recurring price should be charged., e.g., a value of 1 combined withperiodTypeof MONTH would indicate to a subscription service that the price should be charged every 1 month.voidsetPriorPeriodType(String priorPeriodType) The period type for the price, e.g.voidsetRemovedAdjustments(List<RemovedAdjustment> removedAdjustments) The list ofAdjustmentsbeing removed due to the proposed changes.voidsetRemovedSubscriptionItems(List<SubscriptionItem> removedSubscriptionItems) List ofSubscriptionItemsthat are not on the cart.voidsetStartOfTermDate(Instant startOfTermDate) The date at which the subscription's terms will begin.voidsetSubscriptionActionDate(Instant subscriptionActionDate) The timestamp at which the subscription action was taken.voidsetSubscriptionInGracePeriod(boolean subscriptionInGracePeriod) voidsetSubscriptionRootItem(com.broadleafcommerce.cart.client.domain.CartItem subscriptionRootItem) TheCartItemrepresenting the rootSubscriptionItem.booleanDetermines whether the bill dates (e.g.toString()
-
Constructor Details
-
SubscriptionPricingContext
public SubscriptionPricingContext()
-
-
Method Details
-
getActionDateAtBeginningOfDay
-
getPeriodDefinition
-
getExistingSubscriptionItemSubtotal
@Nullable public javax.money.MonetaryAmount getExistingSubscriptionItemSubtotal(@Nullable String subscriptionItemId) -
getExistingSubscriptionItems
-
getExistingSubscriptionItem
@Nullable public SubscriptionItem getExistingSubscriptionItem(@Nullable String existingSubscriptionItemId) -
getExistingSubscriptionItemUnitPrice
@Nullable public javax.money.MonetaryAmount getExistingSubscriptionItemUnitPrice(@Nullable String subscriptionItemId) -
getExistingSubscriptionItemQuantity
-
getExistingSubscriptionId
-
getCancellationPolicyOptionally
-
getCancellationPolicyDetailAndValidate
-
getCancellationStrategy
-
getCancellationChargeStrategy
-
hasTerm
public boolean hasTerm() -
hasFreeTrial
public boolean hasFreeTrial()Determines if the subscription has a free trial still applied.For
subscription modification flows, this also check if the free trial was lost viaisFreeTrialLost().- Returns:
- true if the subscription has a free trial, false otherwise
- See Also:
-
freeTrialEndDateisFreeTrialLost()
-
isFreeTrialLost
public boolean isFreeTrialLost()Determines whether an existing free trial was lost, different fromexpired, due to the subscription modification.For example, the free trial
Adjustmentcould be lost due to the offer requirement no longer matches from the changes against the subscription.This is only relevant to
subscription modification flows.- Returns:
- true if the subscription free trial has been lost, false otherwise
-
isFreeTrialExpired
public boolean isFreeTrialExpired()Determines whether an existing free trial was expired.- Returns:
- true if the subscription free trial has expired, false otherwise
-
isActionDuringFreeTrial
public boolean isActionDuringFreeTrial()Determines whether the action being performed is within the free trial timeframe, only relevant forsubscription modification flowswhen free trial is involved.- Returns:
- true if the action is during the free trial, false otherwise
-
shouldRoundUpBillDates
public boolean shouldRoundUpBillDates()Determines whether the bill dates (e.g. bill date, period start date, and period end date) should be rounded up to the end of the month.For existing subscriptions, it's determined from the existing
Subscription.getInternalAttributes(), unless the free trial is lost as a result of the subscription modification, in which case it's determined based on whether the action date is on a day that is not available every month, e.g. 29th, 30th, and 31st.For create flow, it's determined based on whether the
Note that ifsubscriptionActionDateis on a day that is not available every month, e.g. 29th, 30th, and 31stfree trial is lost, the bill dates should not be rounded up for the first period. -
isCurrentPeriod
Determines whether the given period number is the current subscription period. When the period number isnull, it indicates DueNow, and DueNow is considered the current period if the payment strategy isDefaultSubscriptionPaymentStrategy.PREPAIDor if the flow isDefaultSubscriptionActionFlow.CANCEL. -
getCurrentSubscriptionPeriod
public int getCurrentSubscriptionPeriod()Gets the current subscription period number.For
DefaultSubscriptionActionFlow.CREATE, this is the first period. -
hasBillingFrequencyChange
public boolean hasBillingFrequencyChange() -
getCurrentPeriodDefinition
Gets the current subscription period definition. -
getZoneId
Returns theZoneIdfor the given customer timezone string. If the timezone is null, it defaults toZoneOffset.UTC.- Parameters:
customerTimezone- the customer's timezone ID- Returns:
- the resolved
ZoneId - Throws:
IllegalArgumentException- if the provided timezone ID is invalid
-
getCart
public com.broadleafcommerce.cart.client.domain.Cart getCart()TheCartcontaining subscriptions. -
getFlow
Describes the subscription action flow that is being executed.- See Also:
-
getSubscriptionRootItem
public com.broadleafcommerce.cart.client.domain.CartItem getSubscriptionRootItem()TheCartItemrepresenting the rootSubscriptionItem. -
getSubscriptionActionDate
The timestamp at which the subscription action was taken. In most pricing contexts, the action has not been formally submitted, so we'll use today's date for making pricing calculations. -
getPaymentStrategy
Declares that payments made against a subscription are going towards the goods/services rendered in the previous vs current period.- See Also:
-
getNextBillDate
Describes the next time that the customer will be billed. -
getPeriodType
The period type for the price, e.g. MONTHLY, QUARTERLY, ANNUALLY- See Also:
-
periodFrequency
-
getPeriodFrequency
public int getPeriodFrequency()The frequency with which the recurring price should be charged., e.g., a value of 1 combined withperiodTypeof MONTH would indicate to a subscription service that the price should be charged every 1 month.- See Also:
-
periodType
-
getPriorPeriodType
The period type for the price, e.g. MONTHLY, QUARTERLY, ANNUALLY- See Also:
-
priorPeriodFrequency
-
getPriorPeriodFrequency
The frequency with which the recurring price should be charged., e.g., a value of 1 combined withperiodTypeof MONTH would indicate to a subscription service that the price should be charged every 1 month.- See Also:
-
priorPeriodType
-
getStartOfTermDate
The date at which the subscription's terms will begin. -
getEndOfTermDate
The date at which the subscription's terms will expire. -
getPeriodDefinitions
Describes upcoming subscription billing periods, including the start date, end date, & when the customer will be billed. Map keys are upcoming period numbers, with 1 being the first period. For creation flows, the first period represents the first time that subscription billing will be engaged (i.e. the first bill following the initial purchase). For other flows that act upon the subscription in the middle of a period, the first period definition reflects when the next subscription billing will take place. A key nuance is that this differs for theDefaultSubscriptionPaymentStrategy.POSTPAIDvsDefaultSubscriptionPaymentStrategy.PREPAIDpayment strategies. In the case of Postpaid, the first period includes the active period. The action may include a due now amount, but billing for the subscription itself won't happen until the period has ended. In the case ofDefaultSubscriptionPaymentStrategy.PREPAID, the first period represents the next period to be billed. Actions against anDefaultSubscriptionPaymentStrategy.PREPAIDsubscription can expect to have a due now amount. For example, in the case of an upgrade, the customer has paid for the period at a lower amount, then increases the amount along with the upgrade. This difference in price should be due now. -
getCancellationPolicy
The fullCancellationPolicyfor thesubscriptionRootItemif any. -
getCancellationPolicyDetail
-
getExistingSubscription
The existingSubscriptionif any. This is most relevant for subscription action flows that are modifying an existing subscription. -
isSubscriptionInGracePeriod
public boolean isSubscriptionInGracePeriod() -
getExistingSubscriptionItemById
The existingSubscriptionif any. This is most relevant for subscription action flows that are modifying an existing subscription. -
getExistingSubscriptionItemUnitPrices
Map ofSubscriptionItem.getId()to the existing SubscriptionItem's unit price. -
getExistingSubscriptionItemQuantities
Map ofSubscriptionItem.getId()to the existing SubscriptionItem's quantity. -
getRemovedSubscriptionItems
List ofSubscriptionItemsthat are not on the cart. -
getRemovedAdjustments
The list ofAdjustmentsbeing removed due to the proposed changes.For example, an
Adjustmentcould be lost due to the offer requirement no longer matches from the changes against the subscription. -
getCurrency
public javax.money.CurrencyUnit getCurrency()Currency of this subscription -
getNumberOfPeriodsLeftInTerm
The number of billing periods left in a term beyond the current period, if there are terms. If changing billing frequency, then the current period is shortened, so this may include a shortened final period in the terms. -
getFreeTrialEndDate
The end date of the free trial for this subscription, if applicable, null if none applied.For
create flow, this is from the applied free trial offer.For
subscription modification flows, this is from the existing free trial already applied to the existing subscription. -
getCustomerTimezone
The customer's timezone. It's an optional field used to truncate the dates to the beginning of the day in customer's timezone. If null, UTC time is used. -
getAdditionalAttributes
Miscellaneous attributes that can be added to the context in order to provide more information. -
setCart
public void setCart(com.broadleafcommerce.cart.client.domain.Cart cart) TheCartcontaining subscriptions. -
setFlow
Describes the subscription action flow that is being executed.- See Also:
-
setSubscriptionRootItem
public void setSubscriptionRootItem(com.broadleafcommerce.cart.client.domain.CartItem subscriptionRootItem) TheCartItemrepresenting the rootSubscriptionItem. -
setSubscriptionActionDate
The timestamp at which the subscription action was taken. In most pricing contexts, the action has not been formally submitted, so we'll use today's date for making pricing calculations. -
setPaymentStrategy
Declares that payments made against a subscription are going towards the goods/services rendered in the previous vs current period.- See Also:
-
setNextBillDate
Describes the next time that the customer will be billed. -
setPeriodType
The period type for the price, e.g. MONTHLY, QUARTERLY, ANNUALLY- See Also:
-
periodFrequency
-
setPeriodFrequency
public void setPeriodFrequency(int periodFrequency) The frequency with which the recurring price should be charged., e.g., a value of 1 combined withperiodTypeof MONTH would indicate to a subscription service that the price should be charged every 1 month.- See Also:
-
periodType
-
setPriorPeriodType
The period type for the price, e.g. MONTHLY, QUARTERLY, ANNUALLY- See Also:
-
priorPeriodFrequency
-
setPriorPeriodFrequency
The frequency with which the recurring price should be charged., e.g., a value of 1 combined withperiodTypeof MONTH would indicate to a subscription service that the price should be charged every 1 month.- See Also:
-
priorPeriodType
-
setStartOfTermDate
The date at which the subscription's terms will begin. -
setEndOfTermDate
The date at which the subscription's terms will expire. -
setPeriodDefinitions
Describes upcoming subscription billing periods, including the start date, end date, & when the customer will be billed. Map keys are upcoming period numbers, with 1 being the first period. For creation flows, the first period represents the first time that subscription billing will be engaged (i.e. the first bill following the initial purchase). For other flows that act upon the subscription in the middle of a period, the first period definition reflects when the next subscription billing will take place. A key nuance is that this differs for theDefaultSubscriptionPaymentStrategy.POSTPAIDvsDefaultSubscriptionPaymentStrategy.PREPAIDpayment strategies. In the case of Postpaid, the first period includes the active period. The action may include a due now amount, but billing for the subscription itself won't happen until the period has ended. In the case ofDefaultSubscriptionPaymentStrategy.PREPAID, the first period represents the next period to be billed. Actions against anDefaultSubscriptionPaymentStrategy.PREPAIDsubscription can expect to have a due now amount. For example, in the case of an upgrade, the customer has paid for the period at a lower amount, then increases the amount along with the upgrade. This difference in price should be due now. -
setCancellationPolicy
The fullCancellationPolicyfor thesubscriptionRootItemif any. -
setCancellationPolicyDetail
-
setExistingSubscription
The existingSubscriptionif any. This is most relevant for subscription action flows that are modifying an existing subscription. -
setSubscriptionInGracePeriod
public void setSubscriptionInGracePeriod(boolean subscriptionInGracePeriod) -
setExistingSubscriptionItemById
public void setExistingSubscriptionItemById(Map<String, SubscriptionItem> existingSubscriptionItemById) The existingSubscriptionif any. This is most relevant for subscription action flows that are modifying an existing subscription. -
setExistingSubscriptionItemUnitPrices
public void setExistingSubscriptionItemUnitPrices(Map<String, javax.money.MonetaryAmount> existingSubscriptionItemUnitPrices) Map ofSubscriptionItem.getId()to the existing SubscriptionItem's unit price. -
setExistingSubscriptionItemQuantities
public void setExistingSubscriptionItemQuantities(Map<String, Integer> existingSubscriptionItemQuantities) Map ofSubscriptionItem.getId()to the existing SubscriptionItem's quantity. -
setRemovedSubscriptionItems
List ofSubscriptionItemsthat are not on the cart. -
setRemovedAdjustments
The list ofAdjustmentsbeing removed due to the proposed changes.For example, an
Adjustmentcould be lost due to the offer requirement no longer matches from the changes against the subscription. -
setCurrency
public void setCurrency(javax.money.CurrencyUnit currency) Currency of this subscription -
setNumberOfPeriodsLeftInTerm
The number of billing periods left in a term beyond the current period, if there are terms. If changing billing frequency, then the current period is shortened, so this may include a shortened final period in the terms. -
setFreeTrialEndDate
The end date of the free trial for this subscription, if applicable, null if none applied.For
create flow, this is from the applied free trial offer.For
subscription modification flows, this is from the existing free trial already applied to the existing subscription. -
setCustomerTimezone
The customer's timezone. It's an optional field used to truncate the dates to the beginning of the day in customer's timezone. If null, UTC time is used. -
setAdditionalAttributes
Miscellaneous attributes that can be added to the context in order to provide more information. -
equals
-
canEqual
-
hashCode
public int hashCode() -
toString
-