Happy Business Starts Here

Master

Python quickstart

I'm brand new to Zuora, and it took me many hours to get this going, and I found that much of the content at https://knowledgecenter.zuora.com/DC_Developers/SOAP_API/AB_Getting_started_with_the__SOAP_API is obsolete.

 

Here's a brief script that accesses the Zuora SOAP API, from python. Hopefully it saves the next newbie some time.

 

#!/usr/local/bin/python3.4

import sys
import zeep
from zeep import xsd
import datetime as dt     


wsdl_url ="file:///Users/bo/Dropbox/Canonical/zuora/zuora.a.78.0.wsdl"
USERNAME = 'zuora_api_user@canonical.com.apisandbox'
PASSWORD = sys.argv[1]

client = zeep.Client(wsdl=wsdl_url)
response = client.service.login(USERNAME, PASSWORD)
sessionid = response.Session


calloptions_cls = client.get_element('ns2:CallOptions')
calloptions = calloptions_cls(useSingleTransaction=False)

sessioheader_cls = client.get_element('ns2:SessionHeader')
sessionheader = sessioheader_cls(session=sessionid)


payment_type = client.get_type('ns1:Payment')
payment = payment_type(Type= 'External',
        Status= 'Processed',
        EffectiveDate= dt.date.today(),
        AccountId= '2c92c0f955e2bcfc0155e96053a00a44',
        InvoiceNumber= 'INV00000004',
        Amount= 1234.56,
        AppliedInvoiceAmount= 1234.56,
        PaymentMethodId= '2c92c0f85529afda01552c2247c23c1f')


client.service.create(zObjects=[payment], _soapheaders={'CallOptions': calloptions, 'SessionHeader': sessionheader})

  

Added 2018-09-08:

 

See also https://github.com/bolaurent/Pandas-for-Zuora for how to use zuora api with Pandas and Jupyter data analytics tools.

Tags (1)
3 REPLIES 3
Zuora Alumni

Re: Python quickstart

Hi @bolaurent - Thanks for sharing this information! I'll pass this along to the documentation team. We appreciate you sharing your solutions with the Community Smiley Happy

Master

Re: Python quickstart

Master

Re: Python quickstart

I see that this post gets a lot of views, but I can't tell if anyone is actually using the code that I posted. If it's useful to you, could you let me know? If it's not useful, could you tell me why not?