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; } }
<?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'; $ccnum = $argv[1]; $pm = new PaymentMethod(); $pm->setType('CreditCard'); $cc = new CreditCard(); $cc->setAccount($ccnum); $pm->setCreditCard($cc); $acct = new Account(); $page = 0; $pageSize = 1000; // max 1000 records per page do { $count = 0; $response = $acct->fetchByPaymentMethod('', $pm, $page, $pageSize); $return_code = $response['returnCode']; print "Return Code is: {$return_code} \n"; print_r($response); if ($return_code == 200) { $accounts = $response['data']->accounts; //$count = sizeof($accounts); foreach ($accounts as $account) { // process each account found here print "Found account with id: " . $account->getMerchantAccountId() . "\n"; $acct_name = $account->getname(); $acct_zip = $account->paymentMethods[0]->billingAddress->postalCode;