Create BillingAccount and BillingAccountMembership after purchase

Proposal

The SubscribeService and Zuora::Orders::PostCreationService should be updated to create a BillingAccount and BillingAccountMembership at the same time zuora_account_id is set on the Customer (to be renamed User).

Feature flag

This logic will be feature flagged in the short term using the :account_data_persistence flag. Here is the rollout issue for it: [Feature flag] Persist Billing Account related ... (#5060 - closed). Once we confirm the data is being created as expected and doesn't have any negative effects with the existing creation behavior, we will remove this feature flag.

As this is just creating data in the new models but not using it yet, we shouldn't need to use the :account_data_structure feature flag for this logic. Eventually, the code setting customer.zuora_account_id will be removed but for now both will be set. This will allow us to roll out changes more efficiently without worry of breaking existing functionality.

Delivery plan

  • Restrict the validations in BillingAccountMembership to allow a single account per Customer: https://gitlab.com/gitlab-org/customers-gitlab-com/-/merge_requests/5622
  • Create a service that given a customer will update (if necessary) the BillingAccount and BillingAccountMembership records to reflect the same association the customer is holding: https://gitlab.com/gitlab-org/customers-gitlab-com/-/merge_requests/5660

Plug in the service in the places the customer's zuora_account_id set / updated?

  • FindOrCreateCustomerService: https://gitlab.com/gitlab-org/customers-gitlab-com/-/merge_requests/5807
  • SubscribeService: https://gitlab.com/gitlab-org/customers-gitlab-com/-/merge_requests/5807
  • Zuora::Orders::PostSubscriptionCreationService: https://gitlab.com/gitlab-org/customers-gitlab-com/-/merge_requests/5810
  • clear_missing_zuora_account_ids task: https://gitlab.com/gitlab-org/customers-gitlab-com/-/merge_requests/5811
  • ❗ Rails Admin allows the update to the customer zuora_account_id, there is no code in CDot for this as this update uses the RailsAdmin default logic. Make sure the BillingAccount and BillingAccountMemberships are properly updated base on that: https://gitlab.com/gitlab-org/customers-gitlab-com/-/merge_requests/5832
  • Create an issue for QA pointing to the service so the associated objects are created in the QA context as well: #5128 (closed)
    • PostZuoraRefreshTask
    • OrderApiClient
    • QA::Resource::Subscription
Edited Nov 17, 2022 by Tyler Amos
Assignee Loading
Time tracking Loading