ENG-18651 - Billing callout from Zuora sets wrong plan
#+roam_alias: ENG-18651
Description
STEPS TO REPRODUCE:
1. Sign up for a trial company https://my.staging.15five.com/sign-up-ps/info/?dwft_plg_account_creation
2. Go to Zuora and create account for this company
3. Create subscription (I created with Focus product ()) -> Create Subscription callout is sent to 15Five
4. Check plan and pricing on company billing info in Django or in app
ACTUAL RESULT:
Wrong plan with wrong pricing
EXPECTED RESULT:
Valid plan should be set
Timeline
- Note taken on
After lunch, looking around for evidence of what could be happening I discovered a surprising lack of instrumentation around the logic. The event logs from the Recurly version of the subscription upgrade function was not copied to Zuora and there's little to no logging. That makes it really hard to figure out what's going on.
To make matters worse, there's also no tests for this subscription upgrade function. So I'm going spend the afternoon adding tests and see if I can figure out exactly what's happening. My suspicion right now is that their was an assumption that the plan would be changed by this function, but I don't see any logic that actually changes the company's plan in the billing info. So that seems like a good place to start, but first I need tests.
- Note taken on
Okay. Maybe I wasn't being patient enough. Waited about 10 minutes and I get a whole bunch of helpful logs:
#+begin_quote
Aug 24, 2021 @ 10:44:25.607 zuora_subscription_cancellation_callout - subscription for company ID 37768 successfully processed
Aug 24, 2021 @ 10:44:25.487 Updating the high_water_mark_count for company 37768 to 1
Aug 24, 2021 @ 10:44:25.474 Updating the high_water_user_count for company 37768 to 1
Aug 24, 2021 @ 10:44:25.473 update_high_water_user_count: 37768 billable_user_count is 1
Aug 24, 2021 @ 10:44:22.980 zuora_subscription_creation_callout - creating or updating zuora account for company ID 37768
#+end_quote
And now I can see how the plan was not changed, though the high water mark for users was updated.
- Note taken on
Okay, so the ZuoraAccount instance was created successfully. Going to try deleting that order and creating a new one now that I have a ZuoraAccount.
That did not work. Adding a new order this time (third time) did not trigger a callout at all :(
Going to try deleting the ZuoraAccount instance for my staging test company.
- Note taken on
Steps to create account:
1. Create the account with a complete, valid US address (for taxes)
2. Grab Company ID from django admin and amend the account with the 15Five Company ID
3. Create an order with default terms
4. Click next and add `Focus` as the product at the ` Tiered Pricing Billed Up Front (Non-Profit)` option
5. Add 20 quantity (users)
6. Activate the order to "confirm" it
From there I get the following error:
#+begin_quote
Can not upgrade company 37768 because the billing plan for subscription
A-S00016222 could not be found NoneType: None
#+end_quote
Created another order:
1. Create an order with default terms
2. Click next and add `Focus` as product at the `Tiered Pricing with Monthly Billing` option
3. Add 20 quantity
4. Activate the order to confirm
This time I got:
#+begin_quote
Could not create a Zuora account for company ID 37768
#+end_quote
This seems to have to do with the https://github.com/15five/fifteen5/blob/dev/ff/mods/billing/views.py#L1212 where we check if there's a ZuoraAccount created for this account. I think I may have to create that ... but you'd think creating that account would happen automatically for a trial account upgrading via a created Zuora account?
Oh, but I have an account: https://admin.staging.15five.com/admin/dj/billing/zuoraaccount/104/change/ 🤔
Going to take a quick break.
- Note taken on
Just getting to this this morning and am trying to reproduce the bug. Zuora's
dashboard kind of sucks.