Invoking the subscribe Call
From API Documentation
For information on this topic, see subscribe. The basic workflow is that you begin by populating all of the data (account, contact, payment method, etc.), then you call subscribe.
Both the create and subscribe calls will create a new account. The following are the differences between the two calls:
- If you want to create an account without creating a subscription, use the create call. However, you will then need to use either the subscribeWithExistingAccount call or, for WSDL v11+, subscribe call with an Account ID.
- If you want to create the account along with the subscription and the initial payment information, use the subscribe call.
To use the subscribe call,
- Populate all the required fields for the Account object.
- Populate all the required fields for the Contact object to be used as the BillTo.
- Populate all the required fields for the Contact object to be used as the SoldTo. If this is not set,the BillTo will also be used as the SoldTo contact.
- Populate all the required fields for the PaymentMethod object.
- Populate all the required fields for the SubscriptionData object. This includes the following tasks:
- Populate all the required fields for the Subscription object.
- Populate all the required fields for the RatePlan object. Use a valid ID for ProductRatePlanId.
- Populate all the required fields for the RatePlanCharge objects:
- For WSDL v1-v10: use a valid ID for ProductRatePlanChargeId. If no RatePlanCharge objects are passed, the default RatePlanCharges will copied from the RatePlan object whose ID is passed in the RatePlan object in step 5.2.
- For WSDL v11+: Pass in a valid RatePlanChargeData object. Again, if no RatePlanChargeData objects are passed, the default RatePlanCharges will copied from the RatePlan object whose ID is passed in the RatePlan object in step 5.2.
- Create a SubscribeRequest object and set all the objects created in the previous steps.
- Call the subscribe method, passing in the SubscribeRequest object and the SessionHeader object returned by the login call.
- A SubscribeResponse object is returned. Get the SubscribeResult object from the returned response object and check for the value of the success field.
- If the success value is true, read the other values returned in the SubscribeResult such as the AccountId, AccountNumber, SubscriptionId, SubscriptionNumber, InvoiceNumber, PaymentTransactionNumber.
- If the success value is false, then process the Errors by getting the Code and Message from the Error objects.
Example
<!-- sample subscribe call --> <ns2:subscribe> <ns2:subscribes> <ns2:Account> <ns1:AccountNumber>t-1246636315.4928</ns1:AccountNumber> <!-- Set AutoPay to true for automatic payments via Zuora --> <ns1:AutoPay>false</ns1:AutoPay> <ns1:Batch>Batch1</ns1:Batch> <!-- Usually you will want BillCycleDay to be the same as when the subscription starts See "Working With Dates" for caveats--> <ns1:BillCycleDay>1</ns1:BillCycleDay> <ns1:CrmId>SFDC-1230273269317</ns1:CrmId> <ns1:Currency>USD</ns1:Currency> <ns1:CustomerServiceRepName>CSR Dude</ns1:CustomerServiceRepName> <ns1:Name>Company XYZ, Inc.</ns1:Name> <ns1:PaymentTerm>Due Upon Receipt</ns1:PaymentTerm> <ns1:PurchaseOrderNumber>PO-1230273269317</ns1:PurchaseOrderNumber> <ns1:SalesRepName>Sales Person</ns1:SalesRepName> </ns2:Account> <ns2:PaymentMethod> <ns1:CreditCardAddress1>123 Main</ns1:CreditCardAddress1> <ns1:CreditCardCity>San Francisco</ns1:CreditCardCity> <ns1:CreditCardCountry>United States</ns1:CreditCardCountry <ns1:CreditCardExpirationMonth>1</ns1:CreditCardExpirationMonth> <ns1:CreditCardExpirationYear>2011</ns1:CreditCardExpirationYear> <ns1:CreditCardHolderName>Test Name</ns1:CreditCardHolderName> <!-- Using test MasterCard number --> <ns1:CreditCardNumber>5105105105105100</ns1:CreditCardNumber> <ns1:CreditCardPostalCode>94109</ns1:CreditCardPostalCode> <ns1:CreditCardState>California</ns1:CreditCardState> <ns1:CreditCardType>MasterCard</ns1:CreditCardType> <ns1:Type>CreditCard</ns1:Type> </ns2:PaymentMethod> <ns2:BillToContact> <ns1:Address1>123 Main</ns1:Address1> <ns1:Address2>APT 1</ns1:Address2> <ns1:City>San Francisco</ns1:City> <ns1:Country>United States</ns1:Country> <ns1:FirstName>Erik</ns1:FirstName> <ns1:LastName>Nordstrom</ns1:LastName> <ns1:PostalCode>94109</ns1:PostalCode> <ns1:State>California</ns1:State> <ns1:WorkEmail>test@email.com</ns1:WorkEmail> <ns1:WorkPhone>4155551212</ns1:WorkPhone> </ns2:BillToContact> <ns2:SubscribeOptions> <ns2:GenerateInvoice>true</ns2:GenerateInvoice> <ns2:ProcessPayments>true</ns2:ProcessPayments> </ns2:SubscribeOptions> <ns2:SubscriptionData> <ns2:Subscription> <ns1:AutoRenew>true</ns1:AutoRenew> <!-- See Working With Dates - All datetimes are converted to GMT-08:00 --> <ns1:ContractAcceptanceDate>2009-07-03T08:07:55-07:00</ns1:ContractAcceptanceDate> <ns1:ContractEffectiveDate>2009-07-03T08:07:55-07:00</ns1:ContractEffectiveDate> <ns1:InitialTerm>12</ns1:InitialTerm> <ns1:Name>A-S00000020090703080755</ns1:Name> <ns1:RenewalTerm>12</ns1:RenewalTerm> <ns1:ServiceActivationDate>2009-07-03T08:07:55-07:00</ns1:ServiceActivationDate> <ns1:TermStartDate>2009-07-03T08:07:55-07:00</ns1:TermStartDate> </ns2:Subscription> <ns2:RatePlanData> <ns2:RatePlan> <ns1:ProductRatePlanId>4028e6991f863ecb011fb8b7904141a6</ns1:ProductRatePlanId> <!-- No need for RatePlanCharges unless you want to specifically override the default prices, quantities and/or description--> </ns2:RatePlan> </ns2:RatePlanData> </ns2:SubscriptionData> </ns2:subscribes> </ns2:subscribe>
How to call subscribe() for an existing account
<!-- sample subscribe call for an account that already exists --> <!-- Valid for version 11.0+ of the Zuora WSDL --> <ns2:subscribe> <ns2:subscribes> <ns2:Account> <!-- Set ID to the Account you want to create a subscription for--> <ns1:Id></ns1:Id> </ns2:Account> <ns2:SubscribeOptions> <ns2:GenerateInvoice>true</ns2:GenerateInvoice> <ns2:ProcessPayments>true</ns2:ProcessPayments> </ns2:SubscribeOptions> <ns2:SubscriptionData> <ns2:Subscription> <ns1:AutoRenew>true</ns1:AutoRenew> <!-- See Working With Dates - All datetimes are converted to GMT-08:00 --> <ns1:ContractAcceptanceDate>2009-07-03T08:07:55-07:00</ns1:ContractAcceptanceDate> <ns1:ContractEffectiveDate>2009-07-03T08:07:55-07:00</ns1:ContractEffectiveDate> <ns1:InitialTerm>12</ns1:InitialTerm> <ns1:Name>A-S00000020090703080755</ns1:Name> <ns1:RenewalTerm>12</ns1:RenewalTerm> <ns1:ServiceActivationDate>2009-07-03T08:07:55-07:00</ns1:ServiceActivationDate> <ns1:TermStartDate>2009-07-03T08:07:55-07:00</ns1:TermStartDate> </ns2:Subscription> <ns1:RatePlanData> <ns1:RatePlan xsi:type="ns2:RatePlan"> <!-- Set ID to the ProductRatePlan you want to subscribe to --> <ns2:ProductRatePlanId></ns2:ProductRatePlanId> </ns1:RatePlan> <!-- example of how to set quantity of with RatePlanChargeData --> <ns1:RatePlanChargeData> <ns1:RatePlanCharge xsi:type="ns2:RatePlanCharge"> <!-- Set ID to the ProductRatePlan you want to subscribe to, and specify any other information you want to override or set- like quantity, charge number, etc --> <ns2:ProductRatePlanChargeId></ns2:ProductRatePlanChargeId> <ns2:Quantity>19</ns2:Quantity> </ns1:RatePlanCharge> </ns1:RatePlanChargeData> </ns1:RatePlanData> </ns2:SubscriptionData> </ns2:subscribes> </ns2:subscribe>
