Creating a custom billing frequency
The following is how you would go about adding a custom Billing Frequency type, such as bi-monthly.
Step 1. Extend BillingFrequencyType
public class MyBillingFrequencyType extends BillingFrequencyType {
public static final BillingFrequencyType BIMONTHLY = new BillingFrequencyType("BIMONTHLY", "Bimonthly");
}
Step 2. Override methods in Subscription Service for using the new type
public class MySubscriptionServiceImpl extends SubscriptionServiceImpl {
@Override
public Integer overrideGetNextPeriod(BillingFrequencyType frequencyType, LocalDate startSubscriptionDate,
LocalDate today) {
if (frequencyType.equals(MyBillingFrequencyType.BIMONTHLY)) {
//return the current period for bi-monthly frequency
}
return super.overrideGetNextPeriod(frequencyType, startSubscriptionDate, today);
}
@Override
public Calendar overrideGetCalendarForNextBillingDate(BillingFrequencyType freqType, Calendar returnDate,
Integer relativePeriod) {
if (MyBillingFrequencyType.BIMONTHLY.equals(freqType)) {
//return the returnDate with the appropriate amount of "BIMONTHLY" frequencies added
}
return super.overrideGetCalendarForNextBillingDate(freqType, returnDate, relativePeriod);
}
}
Step 3. For the final step, set up your Subscription Product according to the following doc Subscription Product Tutorial