<?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'; $abId = $argv[1]; $bpId = $argv[2]; $effectiveDate = 'today'; $prorate = $argv[3]; $dryrun = $argv[4]; print "Modifying to use billing plan {$bpId} \n"; print "dryrun is {$dryrun} \n"; $autobill = new AutoBill(); $return = $autobill->fetchByMerchantAutoBillId($abId); $autobillVID = $return['data']->autobill->VID; print "VID is {$autobillVID} \n"; $modAutoBill = new AutoBill(); $modAutoBill->setVID($autobillVID); $changeBillingPlanTo = new BillingPlan(); $changeBillingPlanTo->setMerchantBillingPlanId($bpId); $response = $modAutoBill->modify('', $prorate, $effectiveDate, $changeBillingPlanTo, NULL, $dryrun, ''); print_r($response);
$autobillAPI = new AutoBill(); logCall('Autobill->fetchByAccount ' . $merchantAccountId); $response = $autobillAPI->fetchByAccount($account, true); if (isCallSuccessful($response)) { print "Found account with id: " . $merchantAccountId . PHP_EOL; $fetchedAutoBills = $response['data']->autobills; foreach ($fetchedAutoBills as $autobill) { // process each autobill found here print "Found autobill with id: " . $autobill->getMerchantAutoBillId() . PHP_EOL; print "Start Date: " . $autobill->startTimestamp . PHP_EOL; print "NextBilling: " . PHP_EOL; print "Date: " . $autobill->nextBilling->getTimestamp() . " "; print "Amount: " . $autobill->nextBilling->getAmount() . PHP_EOL; $autobillVid = $autobill->VID; $autobill = new AutoBill(); $autobill->setVID($autobillVid); $numberOfFutureRebillsToFetch = 24; logCall('Autobill->fetchFutureRebills ' . $merchantAccountId); $response = $autobill->fetchFutureRebills($numberOfFutureRebillsToFetch); if (isCallSuccessful($response)) { $futureTxns = $response['data']->transactions; print "Fetched " . $numberOfFutureRebillsToFetch . " future rebills." . PHP_EOL; print "This subscription will be billed at the following dates and amounts:" . PHP_EOL; foreach ($futureTxns as $futureTxn) { print "Date: " . $futureTxn->getTimestamp() . " "; print "Amount: " . $futureTxn->getAmount() . PHP_EOL; } } } } $transactionAPI = new Transaction();
$autobillVID = $return['data']->autobill->VID; print "VID is {$autobillVID} \n"; $modAutoBill = new AutoBill(); $modAutoBill->setVID($autobillVID); $remProduct = new Product(); $remProduct->setMerchantProductId($remID); $remItem = new AutoBillItem(); $remItem->setProduct($remProduct); $addProduct = new Product(); $addProduct->setMerchantProductId($addID); $addItem = new AutoBillItem(); $addItem->setProduct($addProduct); //$addItem->setCampaignCode('promo10'); $replaceModification = new AutoBillItemModification(); $replaceModification->setRemoveAutoBillItem($remItem); $replaceModification->setAddAutoBillItem($addItem); $response = $modAutoBill->modify('', $prorate, $effectiveDate, $changeBillingPlanTo, $replaceModification, $dryrun); print_r($response); if ($response['returnCode'] == 200) { // Now we can force this autobill to show up in autobill.fetchDeltaSince for this time block print "Forcing FDS return by resetting nextBilling date"; $autobill = new AutoBill(); $autobillVID = $response['data']->autobill->VID; $autobillNextBillDate = $response['data']->autobill->nextBilling->timestamp; echo "VID is {$autobillVID} \n"; echo "nextBill is {$autobillNextBillDate} \n"; $autobill = new AutoBill(); $autobill->setVID($autobillVID); $response = $autobill->delayBillingToDate('', $autobillNextBillDate, true); print_r($response); }
<?php $app->get('/wsfinalizeautobillupdatepaidtrialstepuppricing', function (Request $request) use($app) { $webSession = new WebSession(); $websession_id = $request->query->get('vin_WebSession_VID'); $webSession->setVID($websession_id); $response = $webSession->finalize(); // Add error checking and logging of soap ids // Check all the response codes, log soap id. $autobillVid = $response['data']->session->apiReturnValues->autoBillUpdate->autobill->VID; $modAutoBill = new AutoBill(); $modAutoBill->setVID($autobillVid); $remID = 'Video'; $remProduct = new Product(); $remProduct->setMerchantProductId($remID); $remItem = new AutoBillItem(); $remItem->setProduct($remProduct); $addID = 'VideoPricingSteppedUp'; $addProduct = new Product(); $addProduct->setMerchantProductId($addID); $addItem = new AutoBillItem(); $addItem->setProduct($addProduct); $replaceModification = new AutoBillItemModification(); $replaceModification->setRemoveAutoBillItem($remItem); $replaceModification->setAddAutoBillItem($addItem); $effectiveDate = 'nextBill'; $prorate = 0; $changeBillingPlanTo = null; $dryrun = false; $response = $modAutoBill->modify($prorate, $effectiveDate, $changeBillingPlanTo, $replaceModification, $dryrun); });