function create_ecp_PaymentMethod()
{
    $uniqueValue = get_unique_value();
    $merchantAccountId = 'account-' . $uniqueValue;
    $merchantPaymentMethodId = 'pm-' . $uniqueValue;
    $email = get_unique_value() . '@nomail.com';
    $successUrl = 'http://good.com/';
    //need a trailing slash
    $errorUrl = 'http://bad.com/';
    //need a trailing slash
    $name = 'John Vindicia';
    $addr1 = '303 Twin Dolphin Drive';
    $city = 'Redwood City';
    $district = 'CA';
    $postalCode = '94065';
    $country = 'US';
    $address = new Address();
    $address->setName($name);
    $address->setAddr1($addr1);
    $address->setCity($city);
    $address->setDistrict($district);
    $address->setPostalCode($postalCode);
    $address->setCountry($country);
    $paymentmethod = new PaymentMethod();
    $paymentmethod->setType('ECP');
    $paymentmethod->setAccountHolderName($name);
    $paymentmethod->setBillingAddress($address);
    $paymentmethod->setMerchantPaymentMethodId($merchantPaymentMethodId);
    $paymentmethod->setCurrency('USD');
    $ecp = new ECP();
    $ecp->setAccount('495958930');
    $ecp->setRoutingNumber('611111111');
    $ecp->setAllowedTransactionType('Inbound');
    $ecp->setAccountType('ConsumerChecking');
    $paymentmethod->setECP($ecp);
    $account = new Account();
    $account->setMerchantAccountId($merchantAccountId);
    $account->setEmailAddress($email);
    $account->setShippingAddress($address);
    $account->setEmailTypePreference('html');
    $account->setName($name);
    $account->setPaymentMethods(array($paymentmethod));
    return $account;
}
function CreateAccount($merchantAccountId, $email)
{
    $account = new Account();
    $account->setName('Migrated Customer');
    $account->setMerchantAccountId($merchantAccountId);
    // Be conscious that using real email addresses in ProdTest depending on configuration will
    // have live emails triggered and sent on billing events for the Account.
    // It is recommended that when testing in ProdTest be certain to mask real email addresses.
    $account->setEmailAddress($email);
    $account->setEmailTypePreference('html');
    $account->setWarnBeforeAutoBilling(true);
    $anyOtherHelpfulDataForCSRsWhenLookingUpAccount = new NameValuePair();
    $anyOtherHelpfulDataForCSRsWhenLookingUpAccount->setName('HelpfulData');
    $anyOtherHelpfulDataForCSRsWhenLookingUpAccount->setValue('BestCustomerEver');
    $account->setNameValues(array($anyOtherHelpfulDataForCSRsWhenLookingUpAccount));
    $address = new Address();
    $address->setAddr1('303 Twin Dolphin Drive');
    $address->setAddr2('Suite 200');
    $address->setCity('Redwood City');
    $address->setDistrict('CA');
    $address->setPostalCode('94065');
    $address->setCountry('US');
    $address->setPhone('123-456-7890');
    $srd = '';
    $account->setShippingAddress($address);
    $response = $account->update($srd);
    // Log soap id for each API call.
    //    $log->addDebug('Method = Account.update' . PHP_EOL);
    //    $log->addDebug('Soap Id = ' . $response['data']->return->soapId . PHP_EOL);
    //    $log->addDebug('Return Code = ' . $response['returnCode'] . PHP_EOL);
    //    $log->addDebug('Return String = ' . $response['returnString'] . PHP_EOL);
    if ($response['returnCode'] == 200) {
        print "Call succeeded" . PHP_EOL;
    } else {
        print "Call failed" . PHP_EOL;
        print_r($response);
    }
}
function create_paypal_PaymentMethod()
{
    $uniqueValue = get_unique_value();
    $merchantAccountId = 'account-' . $uniqueValue;
    $merchantPaymentMethodId = 'pm-' . $uniqueValue;
    $email = get_unique_value() . '@nomail.com';
    $successUrl = 'http://good.com/';
    //need a trailing slash
    $errorUrl = 'http://bad.com/';
    //need a trailing slash
    $name = 'John Vindicia';
    $addr1 = '303 Twin Dolphin Drive';
    $city = 'Redwood City';
    $district = 'CA';
    $postalCode = '94065';
    $country = 'US';
    $address = new Address();
    $address->setName($name);
    $address->setAddr1($addr1);
    $address->setCity($city);
    $address->setDistrict($district);
    $address->setPostalCode($postalCode);
    $address->setCountry($country);
    $paymentmethod = new PaymentMethod();
    $paymentmethod->setType('PayPal');
    $paymentmethod->setAccountHolderName($name);
    $paymentmethod->setBillingAddress($address);
    $paymentmethod->setMerchantPaymentMethodId($merchantPaymentMethodId);
    $paymentmethod->setCurrency('USD');
    $paypal = new PayPal();
    $paypal->setReturnUrl($successUrl);
    $paypal->setCancelUrl($errorUrl);
    $paymentmethod->setPaypal($paypal);
    $account = new Account();
    $account->setMerchantAccountId($merchantAccountId);
    $account->setEmailAddress($email);
    $account->setShippingAddress($address);
    $account->setEmailTypePreference('html');
    $account->setName($name);
    //$account->setPaymentMethods(array($paymentmethod));
    //return $account;
    return array('account' => $account, 'paymentmethod' => $paymentmethod);
}
$state = "CA";
$postalcode = "94002";
$country = "US";
$email = "childAccount" . rand(10000, 99999) . "@vindicia.com";
$address = new Address();
$address->setName($name);
$address->setAddr1($addr1);
$address->setCity($city);
$address->setDistrict($state);
$address->setPostalCode($postalcode);
$address->setCountry($country);
$accountID = "childAccount" . rand(1000, 9999) . "-" . rand(1000, 999999);
$child1 = new Account();
$child1->setMerchantAccountId($accountID);
$child1->setEmailAddress($email);
$child1->setShippingAddress($address);
$child1->setEmailTypePreference('html');
$child1->setWarnBeforeAutoBilling(false);
$child1->setName($name);
$parent = new Account();
$parent->setMerchantAccountId($parentID);
// use the force flag to remove these children from a previous parent
// and assign them to this new one
//$force=true;
$force = false;
// use payerReplace to determine if any existing autobills of these children
// should use the parents payment method, or only autobills created from here in should.
//$payerReplacementBehavior='ReplaceOnAllAutoBills';
$payerReplacementBehavior = 'ReplaceOnlyFutureAutoBills';
$response = $parent->addChildren(array($child1), $force, $payerReplacementBehavior);
print_r($response);
$address->setName($name);
$address->setAddr1($addr1);
$address->setCity($city);
$address->setDistrict($state);
$address->setPostalCode($postalcode);
$address->setCountry($country);
$accountID = "map-" . rand(1000, 9999) . "-" . rand(1000, 999999);
$map = new MerchantAcceptedPayment();
$pm = new PaymentMethod();
$pm->setType('MerchantAcceptedPayment');
$pm->setMerchantAcceptedPayment($map);
$pm_array = array($pm);
$account = new Account();
$account->setMerchantAccountId($accountID);
$account->setEmailAddress($email);
$account->setShippingAddress($address);
$account->setEmailTypePreference('html');
$account->setWarnBeforeAutoBilling(false);
$account->setName($name);
$account->setPaymentMethods($pm_array);
// must be an existing Product
$productID = $argv[1];
print "productID is {$productID} \n";
$product = new Product();
$product->setMerchantProductId($productID);
// AutoBills may have multiple products
// each in an AutoBillItem as an array:
$item = new AutoBillItem();
// set the Product in the AutoBillItem
$item->setProduct($product);
$item->setMerchantAutoBillItemId('myAutoBillItem-' . rand(00, 99999));