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; } }
$addr1 = "19 Davis Dr"; $city = "Belmont"; $state = "CA"; $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);