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;
}
<?php

require_once "Vindicia/Soap/Vindicia.php";
require_once "Vindicia/Soap/Const.php";
$account = new Account();
// existing customer's Account ID. Tax will be added based on shippingAddress populated on this Account
$account->setMerchantAccountId("jdoe101");
$pm = new PaymentMethod();
$pm->setMerchantPaymentMethodId('VINTESTPM-' . rand(10000, 99999));
// Unique payment method id
$pm->setType('HostedPage');
$hostedPageInfo = new HostedPage();
$hostedPageInfo->setCountryCode('MY');
$hostedPageInfo->setLanguage('en');
$hostedPageInfo->setReturnUrl('http://www.mysite.co.my/PaymentReturn.php');
// specify a page on your site customer will be redirected to after completing the MOLPay payment
$hostedPageInfo->setProcessorPaymentMethodId('all');
// Customer can choose any payment method type at MOLPay
$provider = new PaymentProvider();
$provider->setName('MOLPay');
$hostedPageInfo->setPaymentProvider($provider);
$pm->setHostedPage($hostedPageInfo);
$transaction = new Transaction();
$transaction->setCurrency('MYR');
// Unique transaction ID, use prefix to tell transactions apart from the subscription transactions
$transaction->setMerchantTransactionId('VINTEST-' . rand(10000, 99999));
$transaction->setAccount($account);
$transaction->setSourcePaymentMethod($pm);
//Create purchase line items. This can also be created by looking up a CashBox Product
$transaction_lineItem0 = new TransactionItem();
$transaction_lineItem0->setSku('MYPRODUCT001');
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);
}
<?php

ini_set('include_path', '/usr/local');
ini_set('display_errors', 1);
error_reporting(E_ALL | E_STRICT);
require_once 'Vindicia/Soap/Vindicia.php';
require_once 'Vindicia/Soap/Const.php';
// This example uses an existing Account
$accountID = $argv[1];
print "accountID is {$accountID} \n";
$account = new Account();
$account->setMerchantAccountId($accountID);
// must be an existing Product
$productID = $argv[2];
print "productID is {$productID} \n";
$product = new Product();
$product->setMerchantProductId($productID);
// AutoBills may have multiple products (AutoBill Items)
$item = new AutoBillItem();
// You can apply a Campaign Code to the product here:
$item->setCampaignCode('1MonthBonusPromo');
// set the Product in the AutoBillItem
$item->setProduct($product);
// must be an existing BillingPlan
$billingplanID = $argv[3];
print "billingplanID is {$billingplanID} \n";
$billingplan = new BillingPlan();
$billingplan->setMerchantBillingPlanId($billingplanID);
// Create a random ID for our testing - This should be much more unique in a production env.
$autobillID = 'ab-random' . rand(1000, 9999999);
print "autobillID is {$autobillID} \n";
#
#		Pre-Condition:
#
#			Customer account identified (in $merchantAccountId below)
#
#		Files Used:
#
#				Requires functionality for HOA Account_UpdatePaymentMethod
#				in file hoaAccountUpdatePaymentMethod.php
#
#-----------------------------------------------------------------------------------
require_once "hoaAccountUpdatePaymentMethod.php";
$merchantAccountId = 'testaccount5861';
# $merchantAccountId = 'TestAccount-88663';
$account = new Account();
$account->setMerchantAccountId($merchantAccountId);
$autobill = new AutoBill();
$response = $autobill->fetchByAccount($account, false);
print_r($response);
if ($response['returnCode'] == 200) {
    $targetAutoBill = $response['data']->autobills[0];
    $paymentMethod = $targetAutoBill->paymentMethod;
    $merchantPaymentMethodId = $paymentMethod->merchantPaymentMethodId;
    print "\$merchantPaymentMethodId={$merchantPaymentMethodId}" . PHP_EOL;
    $results = hoaAccountUpdatePaymentMethod($merchantAccountId, $merchantPaymentMethodId);
    $apiReturnCode = $results['apiReturnCode'];
    $validated = $results['validated'];
    print "results: apiReturnCode={$apiReturnCode}, validated={$validated}" . PHP_EOL;
    if ($apiReturnCode == '200' && $validated == '1') {
        print "Card successfully validated when updated.  Now check if AutoBill re-activated:" . PHP_EOL;
        $entitlement = new Entitlement();
$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);
<?php

require_once 'Vindicia/Soap/Vindicia.php';
require_once 'Vindicia/Soap/Const.php';
$parentID = $argv[1];
$child1ID = $argv[2];
$child2ID = $argv[3];
print "parent: {$parentID} \n";
print "child1: {$child1ID} \n";
print "child2: {$child2ID} \n";
$parent = new Account();
$parent->setMerchantAccountId($parentID);
$parentNvp = new NameValuePair();
$parentNvp->setName('parentAccountId');
$parentNvp->setValue($parentID);
$child1 = new Account();
$child1->setMerchantAccountId($child1ID);
$child1->setNameValues(array($parentNvp));
$child2 = new Account();
$child2->setMerchantAccountId($child2ID);
$child2->setNameValues(array($parentNvp));
// use the force flag to remove these children from a previous parent
// and assign them to this new one
//$force=true;
$force = false;
// use payerReplacementBehavior 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, $child2), $force, $payerReplacementBehavior);
print_r($response);
<?php

require_once 'Vindicia/Soap/Vindicia.php';
require_once 'Vindicia/Soap/Const.php';
$testId = rand(1, 1000000);
// random number for some unique IDs
$tx = new Transaction();
$tx->setMerchantTransactionId('DRYRUN-' . $testId);
$acct = new Account();
$acct->setMerchantAccountId('jdoe101');
// existing customer account ID
$tx->setAccount($acct);
$tx->setCurrency('USD');
$txItem1 = new TransactionItem();
$txItem1->setSku('ppv-movie-us-prem');
$txItem1->setName('Premium Pay-per-view movie (English)');
$txItem1->setPrice(5.99);
$txItem1->setQuantity(1);
$txItem1->setTaxClassification('DM030000');
$txItem1->setCampaignCode('PPV2015US');
$txItem2 = new TransactionItem();
$txItem2->setSku('smAccess2015');
$txItem2->setName('Social Media Chat Access');
$txItem2->setPrice(2.0);
$txItem2->setQuantity(1);
$txItem2->setTaxClassification('D0000000');
$tx->setTransactionItems(array($txItem1, $txItem2));
$addr = new Address();
$addr->setAddr1('809 Cuesta Dr');
$addr->setCity('Mountain View');
$addr->setDistrict('CA');
$addr1 = "19 Davis Dr";
$city = "Belmont";
$state = "CA";
$postalcode = "94002";
$country = "US";
$email = "childAccount" . rand(10000, 99999) . "@vindicia.com";
$cAddress = new Address();
$cAddress->setName($name);
$cAddress->setAddr1($addr1);
$cAddress->setCity($city);
$cAddress->setDistrict($state);
$cAddress->setPostalCode($postalcode);
$cAddress->setCountry($country);
$cAccountId = "childAccount" . rand(1000, 9999) . "-" . rand(1000, 999999);
$child1 = new Account();
$child1->setMerchantAccountId($cAccountId);
$child1->setEmailAddress($email);
$child1->setShippingAddress($cAddress);
$child1->setEmailTypePreference('html');
$child1->setWarnBeforeAutoBilling(false);
$child1->setName($name);
// use the force flag to remove these children from a previous parent
// and assign them to this new one
$force = false;
//$force=true;
// 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='ReplaceOnlyFutureAutoBills';
$payerReplacementBehavior = 'ReplaceOnlyFutureAutoBills';
$response = $account->addChildren(array($child1), $force, $payerReplacementBehavior);
print_r($response);