Happy Business Starts Here

Valued Scholar

Is there any API I can use to fetch all billing accounts by CRM_ID?

Is there any API I can use to fetch all billing accounts by CRM_ID? the result billing accounts should have the same CRM_ID.

1 REPLY 1
Master

Re: Is there any API I can use to fetch all billing accounts by CRM_ID?

Use the query api. The following is a fragment from a working python script. (The script uses https://github.com/bolaurent/zuora_restful_python).

 

    for accountid, account in sfdc_account_by_id.items():
        zaccounts = zuora.query_all("""
                select Id, AccountNumber, Name, CrmId, DefaultPaymentMethodId, Balance
                from Account 
                where CrmId = '{}' and Currency = 'USD'
            """.format(accountid))
        if not zaccounts:
            zaccount = zuora.create_account(account)
            zuora_account_by_sfdc_id[accountid] = zaccount
            logger.info("Created account {} {}".format(account['Name'], account['Id']))
            pass
        elif len(zaccounts) > 1:
            logger.error("Multiple zuora accounts for SFDC account {} {}".format(account['Name'], account['Id']))
        else:
            zaccount = zaccounts[0]
            zuora_account_by_sfdc_id[accountid] = zaccount