Reseller and Customer subscriptions in Braintree

123 views
Skip to first unread message

Admin

unread,
Mar 24, 2017, 12:49:37 AM3/24/17
to 2600hz-dev
Hey guys,

Anyone have experience with the Reseller/Customer billing relationship, as it pertains to subscriptions using Service Plans and Braintree? I am wondering if the following is expected behavior?

The following describes the setup (I am skipping some config details to save time):
  • 3 tier setup on my dev server (i.e. Super Duper Admin -> Reseller -> Customer).
  • Reseller account was promoted to the reseller role.
  • Applied a service plan to the Reseller (by creating it on the Super Duper Admin account), and similarly, created and applied a service plan to the Customer (by creating it on the Reseller account).
  • Braintree is setup and enabled in a sandbox environment.
  • I added a credit card on the Reseller account, and different credit card on the Customer account.
  • I am able to add credit to the Reseller account.
  • I am NOT able to add credit to the Customer account. I receive a 500 Forbidden error back from Braintree.
  • After adding SIP devices and DIDs to the Reseller account, I see a subscription for the reseller account in Braintree.
  • After adding SIP devices and DIDs to the Customer account, I do NOT see a subscription in Braintree for the Customer account.
Based on the above setup, I have the following puzzling question:

Does anyone know if the Braintree module is supposed to create individual subscriptions for Resellers AND their customers? Or is the module designed in a way that it only creates a subscription for each Reseller, requiring the Reseller in turn to bill his customers separately? The latter seems to be the behavior I am seeing and describing above.

I purposefully did not use the "Cascading": true key/value pair in the service plan, because from my understanding, when it is set to TRUE the billable items from the Customer accounts get rolled up into the Resellers account, which is behavior I do not want (for example, Reseller has 1 SIP device and 1 DID, Customer has 3 SIP devices and 3 DIDs, if Cascade is set to TRUE the Reseller will end up paying for 4 SIP devices and 4 DIDs instead of the Reseller paying for his own 1 SIP device and 1 DID, and the Customer paying for his own 3 SIP devices and 3 DIDs). I would like the Customer to pay for his own billable items, and similarly the Reseller to pay for his own items. Is this currently possible with Braintree?

Thanks for any input.
Amit

Kirill Sysoev

unread,
Mar 24, 2017, 11:03:53 AM3/24/17
to 2600h...@googlegroups.com
Hi Amit,

I believe this piece of code should answer your questions:
https://github.com/2600hz/kazoo/blob/master/core/kazoo_services/src/kz_services.erl#L588-L597

Here you can see that non-direct master account's children, i.e. sub-reseller's ones, assigned to local bookkeeper only.

Besides that, I can't resist to remind about recent Darren's comment about Braintree:
https://groups.google.com/forum/#!topic/2600hz-dev/qXUWQup6TDc

I use Braintree for accounts topup only, but manage subscriptions logic at Kazoo locally, therefore don't feel described by Darren inconvenience with Braintree personally.

I didn't touched subresellers logic yet (coming soon), but to achieve needs you described, I believe first of all you need to:
- patch bookkeeper selection logic;
- (maybe you'll want to) patch braintree module in order to make resellers able to use their own braintree merchant accounts to bill its children, I doubt such PR will be accepted.

This way you probably will still be able to use Braintree subscriptions management feature (who knows).

(IMHO!!!) Using Braintree subscriptions management feature was implemented in Kazoo as an easy way just for fast start.

In my opinion it is better to implement your very own bookeeper and kazoo_app to manage subscriptions.

Implementing of your own bookkeeper could start from making changes to kz_bookkeeper_braintree.erl

Here is an example of mine: https://github.com/onnet/onbill/blob/master/src/misc/kz_bookkeeper_onbill.erl

Some differencies from out of the box billing implementation:

- all MRC and ProratedMRC withdrawls are made from local account balance (not from credit card);
- withdrawls are made immediately after purchase to get a bit closer to realtime balance (still account could go negative a bit);
- you can select to charge MRC on monthly or on daily basis;
- etc

Hope some ideas will be usefull for you.

Regards,
Kirill
--
You received this message because you are subscribed to the Google Groups "2600hz-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to 2600hz-dev+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Eamon

unread,
Mar 24, 2017, 11:03:54 AM3/24/17
to 2600hz-dev
login with the reseller account and add credit to the customer 

Admin

unread,
Mar 28, 2017, 11:59:41 PM3/28/17
to 2600hz-dev
Thanks Eamon,

Your suggestion does work but not good for my use case.

Admin

unread,
Mar 28, 2017, 11:59:41 PM3/28/17
to 2600hz-dev
Hi Kirill,

Thanks for the great reply! So based on the code, it looks like the Braintree module does not have the desired behavior for my use case. 

I think I will take Darrens and your advice about this module and invest my time elsewhere. No sense in using a service that makes it difficult to get merchant accounts associated with VoIP.

Thanks for the help!
Amit

Matt - nurango (VCCS)

unread,
Apr 25, 2017, 9:23:42 AM4/25/17
to 2600hz-dev
Hi Krill. do you know off hand if we can pass different merchant IDs per plan? I have 2 currencies but by default kazoo uses the default set merchant ID. There seems like room to manipulate based on the top-up example "merchant_account_id": "romanat", on https://github.com/2600hz/kazoo/blob/master/applications/crossbar/doc/braintree.md

Thanks in advance for any info you might have.
MAtt

kirill.sysoev

unread,
Apr 25, 2017, 10:05:29 AM4/25/17
to 2600hz-dev
Hi Matt,

Does 2 currencies per plan = 2 currencies by acconunt?
Looks too complex to me.. :)

My plan is to have 1 currency per reseller.
This means each reseller should be able to use its own Braintree merchant ID.
Having that, reseller's children could be able to pay in currency configured within reseller's merchant account.
These payments should be isolated from upper reseller level.
And at the same time reseller could pay to master account in currency configured at master account merchant ID...
To implement that, Kazoo should allow subresellers to use bookkeeper other than kz_bookkeeper_local.
Here is a PR allowing that: https://github.com/2600hz/kazoo/pull/3598
In case it will be accepted, I'll probably try to add per reseller merchant ID feature.
We could cooperate in case you'll see it could be useful for you too..

Regards,
Kirill    

вторник, 25 апреля 2017 г., 16:23:42 UTC+3 пользователь Matt - nurango (VCCS) написал:

Matt - nurango (VCCS)

unread,
Apr 25, 2017, 11:44:56 AM4/25/17
to 2600hz-dev
Hey, yes I mean to send the currency along with the plan details, otherwise the default account currency is used. I didn't realize this was even the case until yesterday as I thought it was based on the plan setting...In your scenario I could theoretically create my own sub account with the currency I want. 

The only draw back I can see is that everyone can get a stripe or paypal account but most people will have the issue of getting a BT account. For those of us already setup I dont mind continuing to build from the BT API though.

I'll find you on git.
Reply all
Reply to author
Forward
0 new messages