SAAS app with existing payment and subscription flow looking to post every payment as an invoice into zoho books. This should be implemented as an instance method, scheduled by an after_create callback and executed as a sidekiq worker. It should create the customer in zoho books, create the invoice with the corresponding item (plan) and mark it as payed. If the customer is an existing customer (created by this method), it should reference the existing customer.
Currently only user email is recorded but additional fields are expected to be added directly into the zoho books customer at the request of the end users (customers). For example, legal name and taxpayer identification number. Subsequent purchases by the end-user must not overwrite customer data in zoho books.
Currently every payment has an associated Payable model. The association is polymorphic but it is only being used for one model currently, Subscriptions. The Subscription model has a plan_type attribute which will be exposed as a payble_item_id attribute through the Payable. Zoho Items IDs should be mapped to a payable_item_id. This mapping should be defined in an initializer.
Zoho auth vars should be included as env vars.