Reminder notification for subscription renewal and upcoming invoice

278 views
Skip to first unread message

v.sri...@gmail.com

unread,
Mar 20, 2014, 3:20:45 AM3/20/14
to killbill...@googlegroups.com
Hi Pierre,

If I were to add reminders for subscription expiry and upcoming invoices, what would be the best way to go about it? I would like to send out an email notification to the user about these forthcoming events, say 1 or 2 days before. Do I create additional bus events and provide a corresponding implementation(this would require a lot of code change to the killbill engine) or do you suggest some other better way?

Thanks.

-Sri

Pierre-Alexandre Meyer

unread,
Mar 21, 2014, 7:26:16 AM3/21/14
to v.sri...@gmail.com, killbill...@googlegroups.com
On Thu, Mar 20, 2014 at 3:20 AM, <v.sri...@gmail.com> wrote:
If I were to add reminders for subscription expiry and upcoming invoices, what would be the best way to go about it?  I would like to send out an email notification to the user about these forthcoming events, say 1 or 2 days before.

Kill Bill already supports email notifications on invoices (not subscription expiry), but only when the invoice is posted. If you need to send a reminder a couple of days before, a custom plugin is the way to go.

Your plugin needs to track subscription effective cancellation dates and invoices posting dates by listening to bus events, and schedule itself to send the email a couple of days before.

If you are writing the plugin in Java, you can re-use the killbill queue library (https://github.com/killbill/killbill-commons/tree/master/queue) to handle the scheduling for you. An example on how to do it can be found in the Kill Bill Analytics plugin: https://github.com/killbill/killbill-analytics-plugin/blob/master/src/main/java/com/ning/billing/osgi/bundles/analytics/reports/scheduler/JobsScheduler.java#L171

You can even reuse the code to send the actual email from the killbill-util jar (https://github.com/killbill/killbill/blob/master/util/src/main/java/org/killbill/billing/util/email/DefaultEmailSender.java).

When you are about to send the actual email, you should make sure to query Kill Bill for the latest state, in case the subscription has been re-activated and/or there is no invoice to generate.

Regarding bus events, you should have what you need regarding future subscriptions cancellations (a SUBSCRIPTION_CANCEL event will be sent on the external bus when the subscription is future cancelled). I don't think we send an event when scheduling an invoice generation though, but this is something we could add (I've tracked it here: https://github.com/killbill/killbill/issues/166). In the meantime, you could listen to INVOICE_CREATION events instead and compute the next billing date manually.

--
Pierre
Reply all
Reply to author
Forward
0 new messages