Mechanism to keep BillingAccountContact data in sync with Zuora

Problem

In Creation of the BillingAccountContact model (#6066 - closed), the BillingAccountContact model was introduced to cache Zuora Account Contacts locally in CDot. We need to make sure the data stored in this new model is kept in sync with the Single Source of Truth, Zuora.

Proposal

In this issue, we need to work with @gitlab-com/business-technology/enterprise-apps/zuora-architects to build the mechanism for ensuring changes to Zuora Contacts are synced to CustomersDot.

We've engaged the Finsys team via https://gitlab.com/gitlab-com/business-technology/enterprise-apps/financeops/finance-systems/-/issues/1255. In that issue, the Finsys team will create a Custom Event for Zuora Contact updates which will send a callout notification to CustomersDot. It will also involve adjusting the existing Account Update custom event to include changes to the BillToId and SoldToId as triggers.

In this issue, we will be responsible for creating a new API endpoint for updating a BillingAccountContact record based on this callout notification. This can function similarly to the existing sync_account endpoint.

The ZuoraCallout::SyncResource::AccountWorker will also need to be updated to save updates for the BillToId and the SoldToId. These saves happen here on the BillingAccount model. This will actually be saving the reference to the BillingAccountContact in CDot rather than the contact ID (reference from Zuora), so this will perform a BillingAccountContact lookup to based on a matching contact id. If the BillingAccountContact does not exist, it could create the contact from Zuora data.

The worker responsible for processing this new contact callout should include logic to create a CDot Customer/User for the SoldTo Contact email if it doesn't already exist. This way the Sold To Contact will have access to manage the Subscriptions for the Billing Account in CDot. This would likely use the FindOrCreateCustomerService similar to existing Zuora callouts.

Checklist
  • Add new API endpoint to enqueue sync account contact background job
    • https://gitlab.com/gitlab-org/customers-gitlab-com/-/merge_requests/7263
  • Add sync account contact worker to update BillingAccountContact with Zuora Contact data
    • https://gitlab.com/gitlab-org/customers-gitlab-com/-/merge_requests/7263
  • Adjust sync account logic to save bill_to_id and sold_to_id. Create the contact if missing.
    • https://gitlab.com/gitlab-org/customers-gitlab-com/-/merge_requests/7326
  • Create BillingAccount if not found in ContactWorker
    • https://gitlab.com/gitlab-org/customers-gitlab-com/-/merge_requests/7372
  • Update clear_missing_zuora_account_ids.rake task to also delete BillingAccountContacts
    • https://gitlab.com/gitlab-org/customers-gitlab-com/-/merge_requests/7434
  • Create CDot Customer/User for the SoldTo Contact email if it doesn't already exist
    • https://gitlab.com/gitlab-org/customers-gitlab-com/-/merge_requests/7498
  • Update documentation in doc/zuora/zuora_callouts.md
    • https://gitlab.com/gitlab-org/customers-gitlab-com/-/merge_requests/7520
Edited Oct 18, 2023 by Tyler Amos
Assignee Loading
Time tracking Loading