本文整理汇总了PHP中Page_Controller::getSubscriptionNextBillDate方法的典型用法代码示例。如果您正苦于以下问题:PHP Page_Controller::getSubscriptionNextBillDate方法的具体用法?PHP Page_Controller::getSubscriptionNextBillDate怎么用?PHP Page_Controller::getSubscriptionNextBillDate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Page_Controller
的用法示例。
在下文中一共展示了Page_Controller::getSubscriptionNextBillDate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: changeSubscription
public function changeSubscription($data, $form)
{
//Get the record ID
$id = Controller::curr()->request->param('ID');
// Get the subscription
$subscription = Subscription::get()->byID($id);
//Get the new product ID
$newProductID = $data['ProductID'];
if ($subscription->ProductID == $newProductID) {
$form->sessionMessage("Please select a new subscription.", 'bad');
return $this->edit(Controller::curr()->getRequest());
}
// Get the Page controller
$Pg_Ctrl = new Page_Controller();
// Get InfusionSoft Api
$app = $Pg_Ctrl->getInfusionSoftApi();
// Get AttentionWizard member
$member = Member::get()->byID($data['MemberID']);
// Get IndusionSoft contact ID
$isConID = $member->ISContactID;
//Get current date
$curdate = $app->infuDate(date('j-n-Y'));
//Get old order
$oldOrder = $subscription->Order();
//Get new product
$product = Product::get()->byID($newProductID);
$credits = $product->Credits;
$isProductID = $product->ISInitialProductID;
// Get the current InfusionSoft credit card ID
$creditCard = $Pg_Ctrl->getCurrentCreditCard($member->ID);
if (!$creditCard) {
$form->sessionMessage("The user does not have a Credit Card on account, please add a credit card.", 'bad');
return $this->edit(Controller::curr()->getRequest());
}
$ccID = $creditCard->ISCCID;
$subscriptionID = $Pg_Ctrl->createISSubscription($isConID, $product->ISProductID, $product->RecurringPrice, $ccID, 30);
if ($subscriptionID && is_int($subscriptionID)) {
// Create an order
$order = new Order();
$order->OrderStatus = 'P';
$order->Amount = $product->RecurringPrice;
$order->MemberID = $member->ID;
$order->ProductID = $newProductID;
$order->CreditCardID = $creditCard->ID;
$orderID = $order->write();
//Create an infusionsoft order
$config = SiteConfig::current_site_config();
$invoiceId = $app->blankOrder($isConID, $product->Name, $curdate, 0, 0);
$orderItem = $app->addOrderItem($invoiceId, $isProductID, 9, floatval($product->RecurringPrice), 1, $product->Name, $product->Name);
$result = $app->chargeInvoice($invoiceId, $product->Name, $ccID, $config->MerchantAccount, false);
if ($result['Successful']) {
$nextBillDate = $Pg_Ctrl->getSubscriptionNextBillDate($subscriptionID);
$expireDate = date('Y-m-d H:i:s', strtotime($nextBillDate));
$startDate = date('Y-m-d H:i:s', strtotime($expireDate . "-30 days"));
//Set the current subscription to Inactive
$Pg_Ctrl->setSubscriptionStatus($subscription->SubscriptionID, 'Inactive');
//Remove trial tag if exists
$app->grpRemove($isConID, 2216);
//get old Tag ID
if ($Pg_Ctrl->isTrialMember($member->ID)) {
$oldISTagID = 2216;
} else {
$oldISTagID = $Pg_Ctrl->getISTagIdByProduct($oldOrder->ProductID);
}
//Remove old tag ID
$app->grpRemove($isConID, $oldISTagID);
$newISTagID = $Pg_Ctrl->getISTagIdByProduct($newProductID);
//Add new tag ID
$app->grpAssign($isConID, $newISTagID);
//Add a note
$conActionDat = array('ContactId' => $isConID, 'ActionType' => 'UPDATE', 'ActionDescription' => "Payment made for AW service", 'CreationDate' => $curdate, 'ActionDate' => $curdate, 'CompletionDate' => $curdate, 'CreationNotes' => "{$product->Name} Subscription", 'UserID' => 1);
$app->dsAdd("ContactAction", $conActionDat);
$returnFields = array('_AWofmonths');
$conData = $app->loadCon($isConID, $returnFields);
$conDat = array('_AWofmonths' => (isset($conData['_AWofmonths']) ? $conData['_AWofmonths'] : 0) + 1, '_AttentionWizard' => 'Paid and Current');
$app->updateCon($isConID, $conDat);
//Create a new Subscription
$newSubscription = new Subscription();
$newSubscription->StartDate = $startDate;
$newSubscription->ExpireDate = $expireDate;
$newSubscription->SubscriptionID = $subscriptionID;
$newSubscription->Status = 1;
$newSubscription->IsTrial = 0;
$newSubscription->SubscriptionCount = 1;
$newSubscription->MemberID = $member->ID;
$newSubscription->ProductID = $newProductID;
$newSubscription->OrderID = $orderID;
$newSubscription->write();
// Create a MemberCredits record
$memberCredits = new MemberCredits();
$memberCredits->Credits = $credits;
$memberCredits->Expire = 1;
$memberCredits->ExpireDate = $expireDate;
$memberCredits->MemberID = $member->ID;
$memberCredits->ProductID = $newProductID;
$memberCredits->SubscriptionID = $newSubscription->ID;
$memberCredits->write();
// Update order
$order->OrderStatus = 'c';
$order->write();
//.........这里部分代码省略.........