当前位置: 首页>>代码示例>>PHP>>正文


PHP Page_Controller::getCurrentCreditCard方法代码示例

本文整理汇总了PHP中Page_Controller::getCurrentCreditCard方法的典型用法代码示例。如果您正苦于以下问题:PHP Page_Controller::getCurrentCreditCard方法的具体用法?PHP Page_Controller::getCurrentCreditCard怎么用?PHP Page_Controller::getCurrentCreditCard使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Page_Controller的用法示例。


在下文中一共展示了Page_Controller::getCurrentCreditCard方法的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();
//.........这里部分代码省略.........
开发者ID:hemant-chakka,项目名称:awss,代码行数:101,代码来源:DataAdmin.php


注:本文中的Page_Controller::getCurrentCreditCard方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。