Using Usage!

427 views
Skip to first unread message

husam.it

unread,
Mar 30, 2015, 4:36:04 PM3/30/15
to killbill...@googlegroups.com
Hello,


I have 2 plans Bronze (with default pageviews = 10000) and Golden (with default pageviews=20000), and if the user exceeds the limit of pageviews of his subscribed plan he has to charge to get extra pageviews, as shown bellow
<units>
<unit name="pageviews"/>
</units>
<plan name="bronze-monthly">
<product>Bronze</product>
<finalPhase type="EVERGREEN">
<duration>
<unit>UNLIMITED</unit>
</duration>
<recurring>
<billingPeriod>MONTHLY</billingPeriod>
<recurringPrice>
<price>
<currency>USD</currency>
<value>100</value>
</price>
</recurringPrice>
</recurring>
<usages>
<usage name="bronze-monthly-pageviews" billingMode="IN_ADVANCE" usageType="CONSUMABLE">
<billingPeriod>NO_BILLING_PERIOD</billingPeriod>
<blocks>
<block>
<unit>pageviews</unit>
<size>1000</size>
<prices>
<price>
<currency>USD</currency>
<value>5</value>
</price>
</prices>
</block>
</blocks>
</usage>
</usages>
</finalPhase>
</plan>
<plan name="golden-monthly">
<product>Gloden</product>
<finalPhase type="EVERGREEN">
<duration>
<unit>UNLIMITED</unit>
</duration>
<recurring>
<billingPeriod>MONTHLY</billingPeriod>
<recurringPrice>
<price>
<currency>USD</currency>
<value>200</value>
</price>
</recurringPrice>
</recurring>
<usages>
<usage name="golden-monthly-pageviews" billingMode="IN_ADVANCE" usageType="CONSUMABLE">
<billingPeriod>NO_BILLING_PERIOD</billingPeriod>
<blocks>
<block>
<unit>pageviews</unit>
<size>1000</size>
<prices>
<price>
<currency>USD</currency>
<value>7</value>
</price>
</prices>
</block>
</blocks>
</usage>
</usages>
</finalPhase>
</plan>

1- I need to ensure that my catalog design is correct according to my case, so any comments or thoughts would be appreciated!.

2- If the client exceeds his pageviews limit, and his billing period is still valid; so what is the endpoint that i have to use to charge extra pageviews (which is 1000 in my case)?! 


--
Best Regards,
Husam

stephane brossier

unread,
Mar 30, 2015, 10:01:03 PM3/30/15
to husam.it, killbill...@googlegroups.com
I am not seeing any limits defined in your catalog, so i am not sure how that would work. Have you looked at one of our usage catalog example? Some other good resources are the usage tutorial and the usage integration tests which demo the api your are asking about.

Hopefully that should clarify your question, if not (and after reading all that), let us know what is not clear.

Stéphane



--
You received this message because you are subscribed to the Google Groups "Kill Bill users mailing-list" group.
To unsubscribe from this group and stop receiving emails from it, send an email to killbilling-us...@googlegroups.com.
To post to this group, send email to killbill...@googlegroups.com.
Visit this group at http://groups.google.com/group/killbilling-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/killbilling-users/CAME56TYUTU5P3D0z%3D0np8r%3DWc8C8-ERuWBSCn6hmEp_9D4HbMw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Husam Otri

unread,
Mar 31, 2015, 2:22:12 AM3/31/15
to killbill...@googlegroups.com

Yeah, exactly, i followed up this sample (plan name is: consumable-in-advance-prepay-credit-monthly ) , and there is no limit there!

And actually i couldn't get the point, what's the difference between the use of usage in both cases -in same sample -
consumable-in-advance-prepay-credit-monthly-usage1 and 
consumable-in-advance-topup-usage1



and also i couldn't use this sample
http://killbill.io/tutorials/usage-consumable-arrear/ because it uses billingMode="IN_ARREAR", and in my case i need to use "IN_ADVACE" billing mode.


Thanks ,
Husam

Husam Otri

unread,
Mar 31, 2015, 2:36:13 AM3/31/15
to killbill...@googlegroups.com, en.h...@gmail.com


On Tuesday, March 31, 2015 at 5:01:03 AM UTC+3, stephane wrote:
I am not seeing any limits defined in your catalog, so i am not sure how that would work. Have you looked at one of our usage catalog example? Some other good resources are the usage tutorial and the usage integration tests which demo the api your are asking about.

And could you please link me to endpoint from here : http://killbill.io:8080/api.html, instead  usage integration tests 

stephane brossier

unread,
Mar 31, 2015, 11:55:19 AM3/31/15
to Husam Otri, killbill...@googlegroups.com
Husam,

The usage IN_ADVANCE mode has not been implemented yet. We worked on the catalog configuration piece, but the invoicing system does not support it yet (only consumable in arrear). If you are interested to chime in we can help you out with design.

Stéphane


--
You received this message because you are subscribed to the Google Groups "Kill Bill users mailing-list" group.
To unsubscribe from this group and stop receiving emails from it, send an email to killbilling-us...@googlegroups.com.
To post to this group, send email to killbill...@googlegroups.com.
Visit this group at http://groups.google.com/group/killbilling-users.

husam.it

unread,
Mar 31, 2015, 4:24:27 PM3/31/15
to stephane brossier, killbill...@googlegroups.com
Yeah, sure, i'm interested, so i have designed the plans again as the following:

<plans>
    <plan name="bronze-monthly">
<product>Bronze</product>
<finalPhase type="EVERGREEN">
<duration>
<unit>UNLIMITED</unit>
</duration>
<recurring>
<billingPeriod>MONTHLY</billingPeriod>
<recurringPrice>
<price>
<currency>USD</currency>
<value>100</value>
</price>
</recurringPrice>
</recurring>
<usages>
                <usage name="bronze-monthly-pageviews" billingMode="IN_ARREAR" usageType="CONSUMABLE">
<billingPeriod>MONTHLY</billingPeriod>
<tiers>
<tier>
<blocks>
<tieredBlock>
<unit>pageviews</unit>
<size>10000</size> <------ pageviews that included in plan
                                    <prices>
<price>
<currency>USD</currency>
                                            <value>0</value>       <-------  0 because the plan already included 10000 pageviews
</price>
</prices>
<max>10000</max> <--- if user exceeds this limit, he has to charge for 5$ (as shown in next tier)
</tieredBlock>
</blocks>
</tier>
<tier>
<blocks>
<tieredBlock>
<unit>pageviews</unit>
<size>1000</size> <------ number of pageviews that taken once charged for 5$

<prices>
<price>
<currency>USD</currency>
                                            <value>5</value>  <------ the cost for 1000 pageviews
</price>
</prices>
<max>11000</max> <--- new pageviews limit upon user charged for 5$
</tieredBlock>
</blocks>
</tier>
</tiers>
                </usage>
</usages>
</finalPhase>
</plan>
<plan name="golden-monthly">
<product>Gloden</product>
<finalPhase type="EVERGREEN">
<duration>
<unit>UNLIMITED</unit>
</duration>
<recurring>
<billingPeriod>MONTHLY</billingPeriod>
<recurringPrice>
<price>
<currency>USD</currency>
<value>200</value>
</price>
</recurringPrice>
</recurring>
<usages>
                <usage name="golden-monthly-pageviews" billingMode="IN_ARREAR" usageType="CONSUMABLE">
<billingPeriod>NO_BILLING_PERIOD</billingPeriod>
<tiers>
<tier>
<blocks>
<tieredBlock>
<unit>pageviews</unit>
<size>10000</size>
                                    <prices>
<price>
<currency>USD</currency>
                                            <value>0</value>
</price>
</prices>
<max>10000</max>
</tieredBlock>
</blocks>
</tier>
<tier>
<blocks>
<tieredBlock>
                                    <unit>pageviews</unit>
<size>1000</size>
<prices>
<price>
<currency>USD</currency>
<value>7</value>
</price>
</prices>
                                    <max>11000</max>
</tieredBlock>
</blocks>
</tier>
</tiers>
</usage>
</usages>
</finalPhase>
</plan>
</plans>

1- Please let me know if i did some mistakes in designing plans above.
2- If the user exceeds the plan limit, what's the endpoint that i have to call it to charge cost for 1K pageviews? 


Thanks,
Husam
--
Best Regards,
Eng Husam Al-Otri
Software Engineering

stephane brossier

unread,
Mar 31, 2015, 9:50:29 PM3/31/15
to husam.it, killbill...@googlegroups.com
You catalog looks fine. However you told me you were interested to charge in ADVANCE and now you send me a new catalog to charge in ARREAR?

 
2- If the user exceeds the plan limit, what's the endpoint that i have to call it to charge cost for 1K pageviews? 




That is not how it works. Again i spent a great deal of time writing a tutorial which explains all that (including the endpoint you are asking about),  so let me repeat what it says:


"Kill Bill’s usage module provides an API that can be used to record the per customer’s usage. For instance, in order to record 1 unit of chocolate-videos, one would use the API POST /1.0/kb/usages with the following json body:
---
{"subscriptionId":"365987b2-5443-47e4-a467-c8962fc6995c",
 "unitUsageRecords":[
   {"unitType": "chocolate-videos",
    "usageRecords": [{
    "recordDate": "2014-03-14T04:32:25+00:00",
    "amount": 1
   }]}]} 
---


=> This is the API you are looking for...


The calls to record usage are made per subscription, but they can include multiple unitTypes (if the catalog had defined them), and for each unit they can specify as many records as desired; the records themselves specify a date of when those units were consumed.
In our example, the online store could directly make the call to Kill Bill using that API to record each video as they are consumed.
Note that in scenarios where the consumption is much higher (for e.g in the case of a telecom company offering cell-phone minutes), one would need to use a metering system that would first aggregate the units on a daily granularity before making the call to Kill Bill. You can check the initial implementation of our metering module that provides that aggregation functionality."


So to put it differently, you will have to call that api to record the usage, and when it is time to generate an invoice, the system will compute the usage items based on usage that was recorded and your usage definition (tiers).

Is that clearer?

Stéphane

husam.it

unread,
Apr 2, 2015, 10:11:09 AM4/2/15
to stephane brossier, killbill...@googlegroups.com
Hi Stéphane,


 - You mentioned that IN_ADVANCE has not implemented yet, and invoicing system just supports consumable in arrear, 
    so as -i understand- i can't use  IN_ADVANCE right now, therefor i have changed the catalog to ARREAR mode, and might be i will       change billing mode to IN_ADVANCE when it will be implemented.

 
2- If the user exceeds the plan limit, what's the endpoint that i have to call it to charge cost for 1K pageviews? 




That is not how it works. Again i spent a great deal of time writing a tutorial which explains all that (including the endpoint you are asking about),  so let me repeat what it says:


"Kill Bill’s usage module provides an API that can be used to record the per customer’s usage. For instance, in order to record 1 unit of chocolate-videos, one would use the API POST /1.0/kb/usages with the following json body:
---
{"subscriptionId":"365987b2-5443-47e4-a467-c8962fc6995c",
 "unitUsageRecords":[
   {"unitType": "chocolate-videos",
    "usageRecords": [{
    "recordDate": "2014-03-14T04:32:25+00:00",
    "amount": 1
   }]}]} 
---


=> This is the API you are looking for...


The calls to record usage are made per subscription, but they can include multiple unitTypes (if the catalog had defined them), and for each unit they can specify as many records as desired; the records themselves specify a date of when those units were consumed.
In our example, the online store could directly make the call to Kill Bill using that API to record each video as they are consumed.
Note that in scenarios where the consumption is much higher (for e.g in the case of a telecom company offering cell-phone minutes), one would need to use a metering system that would first aggregate the units on a daily granularity before making the call to Kill Bill. You can check the initial implementation of our metering module that provides that aggregation functionality."


So to put it differently, you will have to call that api to record the usage, and when it is time to generate an invoice, the system will compute the usage items based on usage that was recorded and your usage definition (tiers).

Is that clearer?
 
Yeah, its clear, thanks for this explanation; 
So the record has been saved in db "rolled_up_usage"  when i used this endpoint POST /1.0/kb/usages -with correct payload- BUT the system didn't create any new invoice when the pageviews exceeds the limit!! - i am using KB version: 0.13.5 - and i share my catalog please find the attachment - so am i doing a mistake? what do you think?

Thanks



--
Best Regards,
Husam Al-Otri
Software Engineering
catalog-3.xml

stephane brossier

unread,
Apr 6, 2015, 10:44:27 PM4/6/15
to husam.it, killbill...@googlegroups.com

stephane brossier

unread,
Apr 6, 2015, 10:46:16 PM4/6/15
to husam.it, killbill...@googlegroups.com
[...] 
So to put it differently, you will have to call that api to record the usage, and when it is time to generate an invoice, the system will compute the usage items based on usage that was recorded and your usage definition (tiers).

Is that clearer?
 
Yeah, its clear, thanks for this explanation; 
So the record has been saved in db "rolled_up_usage"  when i used this endpoint POST /1.0/kb/usages -with correct payload- BUT the system didn't create any new invoice when the pageviews exceeds the limit!! - i am using KB version: 0.13.5 - and i share my catalog please find the attachment - so am i doing a mistake? what do you think?



The invoice system will generate the invoice when this is 'time' to invoice, which for a a monthly plan would be every month (at the renewal date), for a yearly, every year, ... Does that make sense?

husam.it

unread,
Apr 10, 2015, 4:58:59 PM4/10/15
to stephane brossier, killbill...@googlegroups.com
Yea; it makes sense; and its working now; great thanks!

But i just wondered; when IN_ADVANCE billing mode will be implemented 


Thanks,
Husam



stephane brossier

unread,
Apr 10, 2015, 9:45:53 PM4/10/15
to husam.it, killbill...@googlegroups.com
On Fri, Apr 10, 2015 at 1:58 PM, husam.it <en.h...@gmail.com> wrote:
Yea; it makes sense; and its working now; great thanks!


Great...
 
But i just wondered; when IN_ADVANCE billing mode will be implemented 



We don't have short end plans to implement that feature, but we are looking for contributors... Interested?

valin...@gmail.com

unread,
May 20, 2015, 4:26:52 PM5/20/15
to killbill...@googlegroups.com, en.h...@gmail.com
The metering module seems to no longer be on maven. Is there anywhere else I can just grab a jar?

Pierre-Alexandre Meyer

unread,
May 22, 2015, 3:16:02 AM5/22/15
to Miao Liu, killbill...@googlegroups.com
Are you referring to the Metering plugin (https://github.com/killbill/killbill-meter-plugin)?

Previous artifacts are actually still on Maven (http://search.maven.org/#artifactdetails%7Ccom.ning.billing%7Ckillbill-meter%7C0.1.52%7Cjar) but they are not compatible with the current stable version of Kill Bill - you would need to upgrade the plugin first. We can provide guidance if you are interested in contributing.

On Wed, May 20, 2015 at 4:26 PM, <valin...@gmail.com> wrote:
The metering module seems to no longer be on maven.  Is there anywhere else I can just grab a jar?
--
You received this message because you are subscribed to the Google Groups "Kill Bill users mailing-list" group.
To unsubscribe from this group and stop receiving emails from it, send an email to killbilling-us...@googlegroups.com.
To post to this group, send email to killbill...@googlegroups.com.
Visit this group at http://groups.google.com/group/killbilling-users.

For more options, visit https://groups.google.com/d/optout.



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