本文整理汇总了PHP中Page_Controller::getISTagIdByPaymentCode方法的典型用法代码示例。如果您正苦于以下问题:PHP Page_Controller::getISTagIdByPaymentCode方法的具体用法?PHP Page_Controller::getISTagIdByPaymentCode怎么用?PHP Page_Controller::getISTagIdByPaymentCode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Page_Controller
的用法示例。
在下文中一共展示了Page_Controller::getISTagIdByPaymentCode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createSubscription
public function createSubscription($data, $form)
{
//Get member id
$memberId = $data['MemberID'];
//Get product id
$productId = $data['ProductID'];
// Get the Page controller
$Page_Ctrl = new Page_Controller();
//Get InfusionSoft Api
$app = $Page_Ctrl->getInfusionSoftApi();
// Get curent date
$curdate = $app->infuDate(date('j-n-Y'));
$member = Member::get()->byID($memberId);
//Find or create the 'user' group and add the member to the group
if (!($userGroup = DataObject::get_one('Group', "Code = 'customers'"))) {
$userGroup = new Group();
$userGroup->Code = "customers";
$userGroup->Title = "Customers";
$userGroup->Write();
$userGroup->Members()->add($member);
} else {
$userGroup->Members()->add($member);
}
$isConID = $member->ISContactID;
$product = Product::get()->byID($productId);
// Get existing credit card ID
$creditCard = $Page_Ctrl->getCurrentCreditCard($memberId);
// Get the current InfusionSoft credit card ID
$ccID = $creditCard->ISCCID;
//Get siteconfig object
$config = SiteConfig::current_site_config();
//Process non-expiring heatmaps purchase
if ($productId == 4 || $productId == 5 || $productId == 6 || $productId == 7) {
if (!$data['Quantity']) {
$form->addErrorMessage('Quantity', "Quantity is required for non-expiring products.", 'bad');
return $this->edit(Controller::curr()->getRequest());
}
// Create an Infusionsoft order
$invoiceId = $app->blankOrder($isConID, $product->Name, $curdate, 0, 0);
$orderItem = $app->addOrderItem($invoiceId, intval($Page_Ctrl->getNonExpiringIsProductId($data['ProductID'])), 3, floatval($product->Price), intval($data['Quantity']), $product->Name, $product->Name);
$result = $app->chargeInvoice($invoiceId, $product->Name, $ccID, $config->MerchantAccount, false);
// Create an order
$order = new Order();
$order->OrderStatus = 'P';
$order->Amount = $product->Price * $data['Quantity'];
$order->MemberID = $member->ID;
$order->ProductID = $data['ProductID'];
$order->CreditCardID = $creditCard->ID;
$orderID = $order->write();
if ($result['Successful']) {
// Add tag Paid member - prepaid
$app->grpAssign($isConID, 2290);
$conDat = array('ContactType' => 'AW Customer');
$returnFields = array('_AttentionWizard');
$conDat1 = $app->loadCon($isConID, $returnFields);
if (isset($conDat1['_AttentionWizard']) && $conDat1['_AttentionWizard'] != 'Paid and Current' && $conDat1['_AttentionWizard'] != 'Free') {
$conDat['_AttentionWizard'] = 'Prepaid only - no subscription';
}
if (!isset($conDat1['_AttentionWizard'])) {
$conDat['_AttentionWizard'] = 'Prepaid only - no subscription';
}
$conID = $app->updateCon($isConID, $conDat);
// Note is added
$conActionDat = array('ContactId' => $isConID, 'ActionType' => 'UPDATE', 'ActionDescription' => "Purchased AW Prepaid Credits", 'CreationDate' => $curdate, 'ActionDate' => $curdate, 'CompletionDate' => $curdate, 'UserID' => 1);
$conActionID = $app->dsAdd("ContactAction", $conActionDat);
// Update order
$order->OrderStatus = 'c';
$order->write();
// Create a Subscription record
$subscription = new Subscription();
$subscription->StartDate = date("Y-m-d H:i:s");
$subscription->MemberID = $member->ID;
$subscription->ProductID = $data['ProductID'];
$subscription->OrderID = $orderID;
$subscription->write();
// Create a MemberCredits record
$memberCredits = new MemberCredits();
$memberCredits->Credits = $product->Credits * $data['Quantity'];
$memberCredits->MemberID = $member->ID;
$memberCredits->ProductID = $product->ID;
$memberCredits->SubscriptionID = $subscription->ID;
$memberCredits->write();
$form->sessionMessage("Purchased non-expiring heatmaps successfully.", 'good');
return Controller::curr()->redirect("admin/manage-data/Subscription/EditForm/field/Subscription/item/{$subscription->ID}/edit");
} else {
// Add an AW prospect tag
$app->grpAssign($isConID, $Page_Ctrl->getISTagIdByPaymentCode(strtoupper($result['Code'])));
// Add a note
$conActionDat = array('ContactId' => $isConID, 'ActionType' => 'UPDATE', 'ActionDescription' => "Unsuccessful attempt to purchase prepaid plan", 'CreationDate' => $curdate, 'ActionDate' => $curdate, 'CompletionDate' => $curdate, 'UserID' => 1);
$conActionID = $app->dsAdd("ContactAction", $conActionDat);
$form->sessionMessage("Sorry,the payment failed,please update the user credit card.", 'bad');
return $this->edit(Controller::curr()->getRequest());
}
}
//Process subscriptions
if ($productId == 1 || $productId == 2 || $productId == 3) {
$credits = $product->Credits;
$subscriptionID = $Page_Ctrl->createISSubscription($isConID, $product->ISProductID, $product->RecurringPrice, $ccID, 30);
if ($subscriptionID && is_int($subscriptionID)) {
if ($productId == 1 && !$Page_Ctrl->isCCUsedForTrial($creditCard->CreditCardNumber)) {
//.........这里部分代码省略.........