function subscribedata($instance, $chargeIds, $rateplancharges, $rateplanId) { global $Name; global $FirstName; global $LastName; global $WorkEmail; global $WorkPhone; global $Address1; global $Address2; global $City; global $State; global $Country; global $PostalCode; global $CreditCardHolderName; global $CreditCardNumber; global $CreditCardExpirationMonth; global $CreditCardExpirationYear; global $CreditCardType; global $CreditCardPostalCode; $subscriptionName = getPostValue($Name) . " New Signup (" . time() . ")"; $account = makeAccount(getPostValue($Name), 'USD', 'Draft'); $contact = makeContact(getPostValue($FirstName), getPostValue($LastName), getPostValue($Address1), getPostValue($Address2), getPostValue($City), getPostValue($State), getPostValue($Country), getPostValue($PostalCode), getPostValue($WorkMail), getPostValue($WorkPhone)); $paymentmethod = makePaymentMethod(getPostValue($CreditCardHolderName), getPostValue($Address1), getPostValue($Address2), getPostValue($City), getPostValue($State), getPostValue($Country), getPostValue($PostalCode), getPostValue($CreditCardType), getPostValue($CreditCardNumber), getPostValue($CreditCardExpirationMonth), getPostValue($CreditCardExpirationYear)); $subscription = makeSubscription($subscriptionName, null); $zSubscriptionData = makeSubscriptionData($subscription, $chargeIds, $rateplancharges, $rateplanId); $zSubscribeOptions = new Zuora\Soap\SubscribeOptions(false, false); $result = $instance->subscribe($account, $contact, $paymentmethod, $zSubscriptionData, $zSubscribeOptions); createMessage($result); }
break; default: $creditCardType = "Visa"; break; } // Build the Account object $RetAcct[0] = makeAccount($gFullName, "USD", "Draft", $_SESSION['URLLoc']); // Create the Account in Zuora, it returns an object to indicate success $result2 = $instance->create($RetAcct); // Check if successful if (isset($result2)) { // Successful account create if ($result2->result->Success) { $CreateStatus = "Account created for " . $gFullName . "<br>"; // If we have the id to the account then build a paymentmethod object $PaymentMethod[0] = makePaymentMethod($gFullName, $creditCardType, $gCreditCardNumber, $gCreditCardExpirationMonth, $gCreditCardExpirationYear, $result2->result->Id); // $gCreditCardNumber // Now create the PaymentMethod in Zuora and attach it to the account // the call returns the id of the paymentMethod to be passed to the account create $result = $instance->create($PaymentMethod); if (isset($result)) { // Sccessful payment method create if ($result->result->Success) { $CreateStatus = $CreateStatus . "Payment Method created for " . $gFullName . "<br>"; // Now create a contact so we can make the account active //function makeContact($ firstName,$lastName,$address1,$address2,$city,$state,$country,$postalCode,$workMail,$workPhone,$accountId=null,$WorkEmail){ $RetContact[0] = makeContact($gFirstName, $gLastName, $fieldsValue['Address1'], '', $fieldsValue['City'], $fieldsValue['State'], 'USA', $fieldsValue['PostalCode'], '', '', $result2->result->Id, $fieldsValue[$WorkEmail]); $resultCreateContact = $instance->create($RetContact); if ($resultCreateContact->result->Success) { // createMessage($resultCreateContact); // Now update the account to active
function subscribe($instance, $ProductRatePlan, $GeneratePayments = true, $GenerateInvoice = true, $accountName = null, $subscriptionName = null) { $ProductRatePlanId = $ProductRatePlan->Id; # SUBSCRIBE $zAccount = makeAccount(isset($accountName) ? $accountName : 'Robert Smith', 'USD', 'Active'); $zPaymentMethod = makePaymentMethod('Firstly Lastly', '52 Vexford Lane', null, 'Anaheim', 'California', 'United States', '22042', 'Visa', '5105105105105100', '12', '2012'); $zBillToContact = makeContact('Robert', 'Smith', '4901 Morena Blvd', null, 'San Diego', 'Virginia', 'United States', '92117', '*****@*****.**', null); $zSubscription = makeSubscription(isset($subscriptionName) ? $subscriptionName : "Name" . time(), null); $zSubscriptionData = makeSubscriptionData($zSubscription, array(), array(), $ProductRatePlanId); $zSubscribeOptions = new Zuora_SubscribeOptions($GenerateInvoice, $GeneratePayments); $result = $instance->subscribe($zAccount, $zSubscriptionData, $zBillToContact, $zPaymentMethod, $zSubscribeOptions); return $result; }