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);
}
<?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 createAutoBill($account, $merchantPaymentMethodId, $merchantAutoBillId, $merchantBillingPlanId, $merchantProductId, $currency)
{
    $autobill = new AutoBill();
    $autobill->setAccount($account);
    # same Account
    # AutoBills can have multiple products each in an AutoBillItem as an array:
    $item = new AutoBillItem();
    $item->setIndex(0);
    # set product to an existing product
    $product = new Product();
    $product->setMerchantProductId($merchantProductId);
    $item->setProduct($product);
    # set the Product in the AutoBillItem
    # WSDL AutoBill.items data member is set using PHP method AutoBill.setItems()
    $response = $autobill->setItems(array($item));
    # print_r ($response);
    $autobill->setMerchantAutoBillId($merchantAutoBillId);
    $autobill->setCustomerAutoBillName($merchantAutoBillId);
    # use same PaymentMethod that just validated successfully
    $pm = new PaymentMethod();
    $pm->setMerchantPaymentMethodId($merchantPaymentMethodId);
    $autobill->setPaymentMethod($pm);
    $autobill->setCurrency($currency);
    # set billing plan to existing billing plan
    $billingplan = new BillingPlan();
    $billingplan->setMerchantBillingPlanId($merchantBillingPlanId);
    $autobill->setBillingPlan($billingplan);
    # AutoBill.update() method parameters:
    $validate = false;
    // through 8.0
    $fraudScore = 100;
    // Use this to accept cards involved in chargeback (i.e. Fraud Score=100)
    $minChargebackProbability = $fraudScore;
    $ignoreAvsPolicy = true;
    $ignoreCvnPolicy = true;
    $campaignCode = "";
    $dryrun = false;
    # 9.0 parameters
    $immediateAuthFailurePolicy = 'doNotSaveAutoBill';
    $validateForFuturePayment = $validate;
    print "\nmerchantAccountId=" . $account->getMerchantAccountId() . "\n";
    print "\tmerchantAutoBillId={$merchantAutoBillId}\n";
    print "\t\tmerchantProductId={$product->merchantProductId},";
    print "\tmerchantBillingPlanId={$merchantBillingPlanId}\n";
    print "\tminChargeBackProbability={$minChargebackProbability}\n\n";
    $response = $autobill->update('SucceedIgnore', $validate, $minChargebackProbability, $ignoreAvsPolicy, $ignoreCvnPolicy, $campaignCode, $dryrun);
    // 5.0+
    # $response = $autobill->update($immediateAuthFailurePolicy, $validateForFuturePayment,
    #					$minChargebackProbability,
    # 					$ignoreAvsPolicy, $ignoreCvnPolicy,
    #					$campaignCode, $dryrun);	// 9.0
    echo "\n";
    # print_r ($response);
    $createAutoBill_soapId = $response['data']->return->soapId;
    print "createAutoBill(): soapId = " . $createAutoBill_soapId;
}
<?php

require_once 'Vindicia/Soap/Vindicia.php';
require_once 'Vindicia/Soap/Const.php';
$ab = $argv[1];
$pmId = $argv[2];
print "autobill is {$ab}\n";
$paypal = new PayPal();
$paypal->setReturnUrl('http://localhost:8888/success.php');
$paypal->setCancelUrl('http://localhost:8888/cancellation.php');
$paypal->setRequestReferenceId(1);
$pm = new PaymentMethod();
$pm->setMerchantPaymentMethodId($pmId);
$pm->setType('PayPal');
$pm->setPayPal($paypal);
$autobill = new AutoBill();
$autobill->setMerchantAutoBillId($ab);
$autobill->setPaymentMethod($pm);
$immediateAuthFailurePolicy = 'doNotSaveAutoBill';
$validateForFuturePayment = 0;
$fraudScore = 100;
$ignoreAVS = 1;
$ignoreCVN = 1;
$dryrun = 1;
$dryrun = $argv[3];
$coupon = NULL;
$response = $autobill->update('', $immediateAuthFailurePolicy, $validateForFuturePayment, $fraudScore, $ignoreAVS, $ignoreCVN, $coupon, $dryrun, '');
print_r($response);
$return_code = $response['returnCode'];
$return_string = $response['returnString'];
print "Return code is {$return_code} \n";
function createTransaction($account, $merchantPaymentMethodId, $merchantTransactionId)
{
    #-----------------------------------------------------------------------------------
    # Process Transaction, setting Line Items so they will be helpful in providing
    # a clear indication of what was being purchased, the cost per item and the
    # price for each item, to be used for the first step in collecting information
    # needed for Chargeback defense.
    #
    # 1) Line Item Detail (at time of transaction):
    #
    # a) Line Item Detail for One Time Transactions:
    #
    # First, note that at the time of the transaction, you are already logging Line Item
    # information in TransactionItem entries on the Transaction in realtime.
    #
    # This function demonstrates setting of these Line Items in preparation for use as
    # part of Chargeback defense, used in conjunction with the Activity Reporting which
    # is subsequent sent to CashBox once Usage by the Cardholder has occurred.
    #
    #-----------------------------------------------------------------------------------
    $transaction = new Transaction();
    $transaction->setCurrency('USD');
    # Specify Account to use:
    $transaction->setAccount($account);
    # Specify PaymentMethod to use:
    # use a sparse local PaymentMethod object, only specify an identifier for CashBox
    # to locate existing PaymentMethod:
    $pm = new PaymentMethod();
    $pm->setMerchantPaymentMethodId($merchantPaymentMethodId);
    $transaction->setSourcePaymentMethod($pm);
    # Specify merchantTransactionId to use:
    $transaction->setMerchantTransactionId($merchantTransactionId);
    # Considerations for Line Time Detail:
    #
    # 1) Descriptive name for the Product/SKU, ideally readable text clearly indicating:
    #		- Product name
    #		- Duration it is valid
    #		- What the Product/SKU applies to
    #
    # 2) Description field, set in the API as TransactionItem.name field, indicating:
    #		- How much it cost for 1 item
    #		- For what period the purchase is applicable
    #		- League or other identifying information.
    #
    # 3) Quantity should show how many were purchased.
    # 4) The Amount for a single unit should be indicated in the Line Item.
    #
    # This will result in CashBox automatically setting the Transaction Amount to be
    # the total of the extended price for each Line Item from the product of Quantity
    # & Amount from each Line Item.
    # Use a single Line Item for this sample:
    $tx_lineItem0 = new TransactionItem();
    $tx_lineItem0->setSku('WIDGET200');
    # 1) Descriptive name
    $tx_lineItem0->setName('600 Widgets ($3.30 for 200)');
    # 2) Description field
    $tx_lineItem0->setQuantity('3');
    # 3) Quantity: how many were purchased
    $tx_lineItem0->setPrice('3.30');
    # 4) Amount for a single unit
    # CashBox automatically computes extended price (3 X $3.30) & sets the
    # Transaction amount to be the result, $9.90.
    # Campaign Code can be assigned to each individual line item:
    # $transaction_lineItem0->setCampaignCode('promo2');
    $lineitems = array($tx_lineItem0);
    $transaction->setTransactionItems($lineitems);
    # we can choose to send email for one-time transactions, or not
    $sendEmailNotification = true;
    # use the default CashBox AVS and CVN policy
    $ignoreAvsPolicy = false;
    $ignoreCvnPolicy = false;
    # Campaign Code can also be passed in to the call as a param to apply to all eligible items
    $campaign = '';
    # 'promo2';
    $dryrun = false;
    $response = $transaction->authCapture($sendEmailNotification, $ignoreAvsPolicy, $ignoreCvnPolicy, $campaign, $dryrun);
    print_r($response);
    $return_code = $response['returnCode'];
    print "Transaction.authCapture Return Code is: {$return_code} \n";
    $return_string = $response['returnString'];
    print "Transaction.authCapture Return String is: {$return_string} \n";
    $txAuthCapture_SoapId = $response['data']->return->soapId;
    print "Transaction.authCapture soapId: " . $txAuthCapture_SoapId . PHP_EOL . PHP_EOL;
    $txStatus = $response['data']->transaction->statusLog[0];
    $status = $txStatus->status;
    print "Transaction.authCapture status: " . $status . PHP_EOL;
    $vinAVS = $txStatus->vinAVS;
    print "Transaction.authCapture vinAVS: " . $vinAVS . PHP_EOL;
    $ccStatus = $txStatus->creditCardStatus;
    print_r($ccStatus);
    $authCode = $ccStatus->authCode;
    print "Transaction.authCapture authCode: " . $authCode . PHP_EOL;
    $avsCode = $ccStatus->avsCode;
    print "Transaction.authCapture avsCode: " . $avsCode . PHP_EOL;
    $cvnCode = $ccStatus->cvnCode;
    print "Transaction.authCapture cvnCode: " . $cvnCode . PHP_EOL;
    $extendedCardAttributes = $ccStatus->extendedCardAttributes;
    print "Transaction.authCapture extendedCardAttributes: " . PHP_EOL;
    print_r($extendedCardAttributes);
}