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'; $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";