function Step2CreateCreditCard($merchantAccountId)
{
    //    $account = get_account_by_merchantAccountId($merchantAccountId);
    //To save a soap call, you can use sparse objects.
    $account = new Account();
    $account->merchantAccountId = $merchantAccountId;
    $merchantPaymentMethodId = $merchantAccountId;
    $paymentMethod = new PaymentMethod();
    $cc = new CreditCard();
    $paymentMethod->setBillingAddress($account->shippingAddress);
    $paymentMethod->setMerchantPaymentMethodId($merchantPaymentMethodId);
    // Use Test cards only in ProdTest.  Use Real cards only in Production.
    $cc->setAccount("4112344112344113");
    $cc->setExpirationDate("201811");
    $paymentMethod->setType('CreditCard');
    $paymentMethod->setCreditCard($cc);
    // Do not check AVS, CVN.  Do not validate.
    $replaceOnAutoBills = true;
    $updateBehavior = "Update";
    $ignoreAvsPolicy = true;
    $ignoreCvnPolicy = true;
    $srd = '';
    $response = $account->updatePaymentMethod($srd, $paymentMethod, $replaceOnAutoBills, $updateBehavior, $ignoreAvsPolicy, $ignoreCvnPolicy);
    // Log soap id for each API call.
    //    $log->addDebug('Method = Account.updatePaymentMethod' . 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;
    }
}
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 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);
}
$postalcode = "94002";
$country = "US";
$email = "parent-" . rand(10000, 99999) . "@vindicia.com";
$pAddress = new Address();
$pAddress->setName($name);
$pAddress->setAddr1($addr1);
$pAddress->setCity($city);
$pAddress->setDistrict($state);
$pAddress->setPostalCode($postalcode);
$pAddress->setCountry($country);
$cc = new CreditCard();
$cc->setAccount('4485983356242217');
$cc->setExpirationDate('201710');
$pm = new PaymentMethod();
$pm->setType('CreditCard');
$pm->setBillingAddress($pAddress);
$pm->setCreditCard($cc);
$pm->setActive(1);
$pm_array = array($pm);
$pAccountId = "parent-" . rand(1000, 9999) . "-" . rand(1000, 999999);
$account = new Account();
$account->setMerchantAccountId($pAccountId);
$account->setEmailAddress($email);
$account->setShippingAddress($pAddress);
$account->setEmailTypePreference('html');
$account->setWarnBeforeAutoBilling(false);
$account->setName($name);
$account->setPaymentMethods($pm_array);
$name = "Child One";
$addr1 = "19 Davis Dr";
$city = "Belmont";