Inheritance: extends Page
Example #1
0
 /**
  * Automatically create an AccountPage if one is not found
  * on the site at the time the database is built (dev/build).
  */
 function requireDefaultRecords()
 {
     parent::requireDefaultRecords();
     if (!DataObject::get_one('AccountPage')) {
         $page = new AccountPage();
         $page->Title = 'Account';
         $page->Content = '';
         $page->URLSegment = 'account';
         $page->ShowInMenus = 0;
         $page->writeToStage('Stage');
         $page->publish('Stage', 'Live');
         DB::alteration_message('Account page \'Account\' created', 'created');
     }
 }
 /**
  * Automatically create an AccountPage if one is not found
  * on the site at the time the database is built (dev/build).
  */
 function requireDefaultRecords()
 {
     parent::requireDefaultRecords();
     if (!DataObject::get_one('AccountPage')) {
         $page = new AccountPage();
         $page->Title = 'Account';
         $page->Content = '';
         $page->URLSegment = 'account';
         $page->ShowInMenus = 0;
         $page->writeToStage('Stage');
         $page->publish('Stage', 'Live');
         DB::alteration_message('Account page \'Account\' created', 'created');
     }
     //Create a new group for customers
     $allGroups = DataObject::get('Group');
     $existingCustomerGroup = $allGroups->find('Title', 'Customers');
     if (!$existingCustomerGroup) {
         $customerGroup = new Group();
         $customerGroup->Title = 'Customers';
         $customerGroup->setCode($customerGroup->Title);
         $customerGroup->write();
     }
 }
 public function testGlobals()
 {
     $this->assertFalse($this->accountpage->canCreate(), "account page exists");
     $this->assertEquals(Director::baseURL() . "account/", AccountPage::find_link());
     $this->assertEquals(Director::baseURL() . "account/order/10", AccountPage::get_order_link(10));
 }
 /**
  * work out the options for the user
  **/
 protected function workOutMessagesAndActions()
 {
     if (!$this->workedOutMessagesAndActions) {
         $this->actionLinks = new ArrayList(array());
         //what order are we viewing?
         $viewingRealCurrentOrder = $this->CurrentOrderIsInCart();
         $currentUserID = Member::currentUserID();
         //Continue Shopping
         if (isset($this->ContinueShoppingLabel) && $this->ContinueShoppingLabel) {
             if ($viewingRealCurrentOrder) {
                 if ($this->isCartPage()) {
                     $continueLink = $this->ContinueShoppingLink();
                     if ($continueLink) {
                         $this->actionLinks->push(new ArrayData(array("Title" => $this->ContinueShoppingLabel, "Link" => $continueLink)));
                     }
                 }
             }
         }
         //Proceed To CheckoutLabel
         if (isset($this->ProceedToCheckoutLabel) && $this->ProceedToCheckoutLabel) {
             if ($viewingRealCurrentOrder) {
                 if ($this->isCartPage()) {
                     $checkoutPageLink = CheckoutPage::find_link();
                     if ($checkoutPageLink && $this->currentOrder && $this->currentOrder->getTotalItems()) {
                         $this->actionLinks->push(new ArrayData(array("Title" => $this->ProceedToCheckoutLabel, "Link" => $checkoutPageLink)));
                     }
                 }
             }
         }
         //view account details
         if (isset($this->ShowAccountLabel) && $this->ShowAccountLabel) {
             if ($this->isOrderConfirmationPage() || $this->isCartPage()) {
                 if (AccountPage::find_link()) {
                     if ($currentUserID) {
                         $this->actionLinks->push(new ArrayData(array("Title" => $this->ShowAccountLabel, "Link" => AccountPage::find_link())));
                     }
                 }
             }
         }
         //go to current order
         if (isset($this->CurrentOrderLinkLabel) && $this->CurrentOrderLinkLabel) {
             if ($this->isCartPage()) {
                 if (!$viewingRealCurrentOrder) {
                     $this->actionLinks->push(new ArrayData(array("Title" => $this->CurrentOrderLinkLabel, "Link" => ShoppingCart::current_order()->Link())));
                 }
             }
         }
         //Save order - we assume only current ones can be saved.
         if (isset($this->SaveOrderLinkLabel) && $this->SaveOrderLinkLabel) {
             if ($viewingRealCurrentOrder) {
                 if ($currentUserID && $this->currentOrder->MemberID == $currentUserID) {
                     if ($this->isCartPage()) {
                         if ($this->currentOrder && $this->currentOrder->getTotalItems() && !$this->currentOrder->IsSubmitted()) {
                             $this->actionLinks->push(new ArrayData(array("Title" => $this->SaveOrderLinkLabel, "Link" => $this->Link("saveorder") . "/" . $this->currentOrder->ID . "/")));
                         }
                     }
                 }
             }
         }
         //load order
         if (isset($this->LoadOrderLinkLabel) && $this->LoadOrderLinkLabel) {
             if ($this->isCartPage() && $this->currentOrder) {
                 if (!$viewingRealCurrentOrder) {
                     $this->actionLinks->push(new ArrayData(array("Title" => $this->LoadOrderLinkLabel, "Link" => $this->Link("loadorder") . "/" . $this->currentOrder->ID . "/")));
                 }
             }
         }
         //delete order
         if (isset($this->DeleteOrderLinkLabel) && $this->DeleteOrderLinkLabel) {
             if ($this->isCartPage() && $this->currentOrder) {
                 if (!$viewingRealCurrentOrder) {
                     $this->actionLinks->push(new ArrayData(array("Title" => $this->DeleteOrderLinkLabel, "Link" => $this->Link("deleteorder") . "/" . $this->currentOrder->ID . "/")));
                 }
             }
         }
         //Start new order
         //Strictly speaking this is only part of the
         //OrderConfirmationPage but we put it here for simplicity's sake
         if (isset($this->StartNewOrderLinkLabel) && $this->StartNewOrderLinkLabel) {
             if ($this->isOrderConfirmationPage()) {
                 $this->actionLinks->push(new ArrayData(array("Title" => $this->StartNewOrderLinkLabel, "Link" => CartPage::new_order_link($this->currentOrder->ID))));
             }
         }
         //copy order
         //Strictly speaking this is only part of the
         //OrderConfirmationPage but we put it here for simplicity's sake
         if (isset($this->CopyOrderLinkLabel) && $this->CopyOrderLinkLabel) {
             if ($this->isOrderConfirmationPage() && $this->currentOrder->ID) {
                 $this->actionLinks->push(new ArrayData(array("Title" => $this->CopyOrderLinkLabel, "Link" => OrderConfirmationPage::copy_order_link($this->currentOrder->ID))));
             }
         }
         //actions from modifiers
         if ($this->isOrderConfirmationPage() && $this->currentOrder->ID) {
             $modifiers = $this->currentOrder->Modifiers();
             if ($modifiers->count()) {
                 foreach ($modifiers as $modifier) {
                     $array = $modifier->PostSubmitAction();
                     if (is_array($array) && count($array)) {
                         $this->actionLinks->push(new ArrayData($array));
                     }
                 }
             }
         }
         //log out
         //Strictly speaking this is only part of the
         //OrderConfirmationPage but we put it here for simplicity's sake
         if (Member::currentUser()) {
             if ($this->isOrderConfirmationPage()) {
                 $this->actionLinks->push(new ArrayData(array("Title" => _t("CartPage.LOGOUT", "log out"), "Link" => "/Security/logout/")));
             }
         }
         //no items
         if ($this->currentOrder) {
             if (!$this->currentOrder->getTotalItems()) {
                 $this->message = $this->NoItemsInOrderMessage;
             }
         } else {
             $this->message = $this->NonExistingOrderMessage;
         }
         $this->workedOutMessagesAndActions = true;
         //does nothing at present....
     }
 }
 protected function addPages()
 {
     if ($checkoutPage = CheckoutPage::get()->First()) {
         $this->getPageDefinitions($checkoutPage);
         $this->definitions["Pages"]["CheckoutPage"] = "Page where customers finalise (checkout) their order. This page is required.<br />" . ($checkoutPage ? "<a href=\"/admin/pages/edit/show/" . $checkoutPage->ID . "/\">edit</a>" : "Create one in the <a href=\"/admin/pages/add/\">CMS</a>");
         $this->configs["Pages"]["CheckoutPage"] = $checkoutPage ? "view: <a href=\"" . $checkoutPage->Link() . "\">" . $checkoutPage->Title . "</a><br />" . $checkoutPage->configArray : " NOT CREATED!";
         $this->defaults["Pages"]["CheckoutPage"] = $checkoutPage ? $checkoutPage->defaultsArray : "[add page first to see defaults]";
         $this->databaseValues["Pages"]["CheckoutPage"] = true;
     }
     if ($orderConfirmationPage = OrderConfirmationPage::get()->First()) {
         $this->getPageDefinitions($orderConfirmationPage);
         $this->definitions["Pages"]["OrderConfirmationPage"] = "Page where customers review their order after it has been placed. This page is required.<br />" . ($orderConfirmationPage ? "<a href=\"/admin/pages/edit/show/" . $orderConfirmationPage->ID . "/\">edit</a>" : "Create one in the <a href=\"/admin/pages/add/\">CMS</a>");
         $this->configs["Pages"]["OrderConfirmationPage"] = $orderConfirmationPage ? "view: <a href=\"" . $orderConfirmationPage->Link() . "\">" . $orderConfirmationPage->Title . "</a><br />" . $orderConfirmationPage->configArray : " NOT CREATED!";
         $this->defaults["Pages"]["OrderConfirmationPage"] = $orderConfirmationPage ? $orderConfirmationPage->defaultsArray : "[add page first to see defaults]";
         $this->databaseValues["Pages"]["OrderConfirmationPage"] = true;
     }
     if ($accountPage = AccountPage::get()->First()) {
         $this->getPageDefinitions($accountPage);
         $this->definitions["Pages"]["AccountPage"] = "Page where customers can review their account. This page is required.<br />" . ($accountPage ? "<a href=\"/admin/pages/edit/show/" . $accountPage->ID . "/\">edit</a>" : "Create one in the <a href=\"/admin/pages/add/\">CMS</a>");
         $this->configs["Pages"]["AccountPage"] = $accountPage ? "view: <a href=\"" . $accountPage->Link() . "\">" . $accountPage->Title . "</a><br />" . $accountPage->configArray : " NOT CREATED!";
         $this->defaults["Pages"]["AccountPage"] = $accountPage ? $accountPage->defaultsArray : "[add page first to see defaults]";
         $this->databaseValues["Pages"]["AccountPage"] = true;
     }
     if ($cartPage = CartPage::get()->Filter(array("ClassName" => "CartPage"))->First()) {
         $this->getPageDefinitions($cartPage);
         $this->definitions["Pages"]["CartPage"] = "Page where customers review their cart while shopping. This page is optional.<br />" . ($cartPage ? "<a href=\"/admin/pages/edit/show/" . $cartPage->ID . "/\">edit</a>" : "Create one in the <a href=\"/admin/pages/add/\">CMS</a>");
         $this->configs["Pages"]["CartPage"] = $cartPage ? "view: <a href=\"" . $cartPage->Link() . "\">" . $cartPage->Title . "</a>, <a href=\"/admin/pages/edit/show/" . $cartPage->ID . "/\">edit</a><br />" . $cartPage->configArray : " NOT CREATED!";
         $this->defaults["Pages"]["CartPage"] = $cartPage ? $cartPage->defaultsArray : "[add page first to see defaults]";
         $this->defaults["Pages"]["CartPage"] = $cartPage ? $cartPage->defaultsArray : "[add page first to see defaults]";
         $this->databaseValues["Pages"]["CartPage"] = true;
     }
 }
Example #6
0
 /**
  * Get the link for finishing order processing.
  */
 public function Link()
 {
     if (Member::currentUser()) {
         return Controller::join_links(AccountPage::find_link(), 'order', $this->ID);
     }
     return CheckoutPage::find_link(false, "order", $this->ID);
 }
 function run($request)
 {
     $update = array();
     // ACCOUNT PAGE
     $accountPage = DataObject::get_one('AccountPage');
     if (!$accountPage) {
         $accountPage = new AccountPage();
         $accountPage->Title = 'Account';
         $accountPage->MenuTitle = 'Account';
         $accountPage->MetaTitle = 'Account';
         $accountPage->Content = '<p>This is the account page. It is used for shop users to login and change their member details if they have an account.</p>';
         $accountPage->URLSegment = 'account';
         $accountPage->ShowInMenus = 0;
         $accountPage->writeToStage('Stage');
         $accountPage->publish('Stage', 'Live');
         DB::alteration_message('Account page \'Account\' created', 'created');
     } else {
         DB::alteration_message('No need to create an account page, it already exists.');
     }
     //CHECKOUT PAGE
     //CHECKOUT PAGE
     $checkoutPage = DataObject::get_one('CheckoutPage');
     if (!$checkoutPage) {
         $checkoutPage = new CheckoutPage();
         $checkoutPage->Content = '<p>This is the checkout page. You can edit all the messages in the Content Management System.</p>';
         $checkoutPage->Title = 'Checkout';
         $checkoutPage->TermsAndConditionsMessage = 'You must agree with the terms and conditions to proceed. ';
         $checkoutPage->MetaTitle = 'Checkout';
         $checkoutPage->MenuTitle = 'Checkout';
         $checkoutPage->URLSegment = 'checkout';
         $update[] = 'Checkout page \'Checkout\' created';
         $checkoutPage->ShowInMenus = 0;
         DB::alteration_message('new checkout page created.', 'created');
     } else {
         DB::alteration_message('No need to create an checkout page, it already exists.');
     }
     if ($checkoutPage) {
         if ($checkoutPage->TermsPageID == 0 && ($termsPage = DataObject::get_one('Page', "\"URLSegment\" = 'terms-and-conditions'"))) {
             $checkoutPage->TermsPageID = $termsPage->ID;
             DB::alteration_message('terms and conditions page linked.', "created");
         } else {
             DB::alteration_message('No terms and conditions page linked.');
         }
         $checkoutPage->writeToStage('Stage');
         $checkoutPage->publish('Stage', 'Live');
         DB::alteration_message('Checkout page saved');
         if (!DataObject::get_one('OrderConfirmationPage')) {
             $orderConfirmationPage = new OrderConfirmationPage();
             $orderConfirmationPage->ParentID = $checkoutPage->ID;
             $orderConfirmationPage->Title = 'Order confirmation';
             $orderConfirmationPage->MenuTitle = 'Order confirmation';
             $orderConfirmationPage->MetaTitle = 'Order confirmation';
             $orderConfirmationPage->Content = '<p>This is the order confirmation page. It is used to confirm orders after they have been placed in the checkout page.</p>';
             $orderConfirmationPage->URLSegment = 'order-confirmation';
             $orderConfirmationPage->ShowInMenus = 0;
             $orderConfirmationPage->writeToStage('Stage');
             $orderConfirmationPage->publish('Stage', 'Live');
             DB::alteration_message('Order Confirmation created', 'created');
         } else {
             DB::alteration_message('No need to create an Order Confirmation Page. It already exists.');
         }
     }
     $update = array();
     $ecommerceConfig = EcommerceDBConfig::current_ecommerce_db_config();
     if ($ecommerceConfig) {
         if (!$ecommerceConfig->ReceiptEmail) {
             $ecommerceConfig->ReceiptEmail = Email::getAdminEmail();
             if (!$ecommerceConfig->ReceiptEmail) {
                 user_error("you must set an AdminEmail (Email::setAdminEmail)", E_USER_NOTICE);
             }
             $update[] = "created default entry for ReceiptEmail";
         }
         if (!$ecommerceConfig->NumberOfProductsPerPage) {
             $ecommerceConfig->NumberOfProductsPerPage = 12;
             $update[] = "created default entry for NumberOfProductsPerPage";
         }
         if (count($update)) {
             $ecommerceConfig->write();
             DB::alteration_message($ecommerceConfig->ClassName . " created/updated: " . implode(" --- ", $update), 'created');
         }
     }
 }
 /**
  * Return the {@link Order} details for the current
  * Order ID that we're viewing (ID parameter in URL).
  *
  * @return array of template variables
  */
 function order($request)
 {
     Requirements::themedCSS('Order');
     Requirements::themedCSS('Order_print', 'print');
     $memberID = Member::currentUserID();
     $accountPageLink = AccountPage::find_link();
     if ($orderID = $request->param('ID')) {
         if ($order = DataObject::get_one('Order', "\"Order\".\"ID\" = '{$orderID}' AND \"Order\".\"MemberID\" = '{$memberID}'")) {
             $paymentform = $order->TotalOutstanding() > 0 ? $this->CancelForm() : null;
             return array('Order' => $order, 'Form' => $paymentform);
         } else {
             return array('Order' => false, 'Message' => 'You do not have any order corresponding to this ID. However, you can <a href="' . $accountPageLink . '">edit your own personal details and view your orders.</a>.');
         }
     } else {
         return array('Order' => false, 'Message' => 'There is no order by that ID. You can <a href="' . $accountPageLink . '">edit your own personal details and view your orders.</a>.');
     }
 }
 /**
  * Return the {@link Order} details for the current
  * Order ID that we're viewing (ID parameter in URL).
  *
  * @return array of template variables
  */
 function order($request)
 {
     Requirements::themedCSS('Order');
     Requirements::themedCSS('Order_print', 'print');
     $memberID = Member::currentUserID();
     $accountPageLink = AccountPage::find_link();
     if ($orderID = $request->param('ID')) {
         if ($order = DataObject::get_one('Order', "Order.ID = '{$orderID}' AND MemberID = '{$memberID}'")) {
             return array('Order' => $order);
         } else {
             return array('Order' => false, 'Message' => 'You do not have any order corresponding to this ID. However, you can <a href="' . $accountPageLink . '">edit your own personal details and view your orders.</a>.');
         }
     } else {
         return array('Order' => false, 'Message' => 'There is no order by that ID. You can <a href="' . $accountPageLink . '">edit your own personal details and view your orders.</a>.');
     }
 }
Example #10
0
 /**
  * Form action handler for Order_CancelForm.
  *
  * Take the order that this was to be change on,
  * and set the status that was requested from
  * the form request data.
  *
  * @param array $data The form request data submitted
  * @param Form $form The {@link Form} this was submitted on
  */
 function doCancel($data, $form)
 {
     $SQL_data = Convert::raw2sql($data);
     $order = DataObject::get_by_id('Order', $SQL_data['OrderID']);
     $order->Status = 'MemberCancelled';
     $order->write();
     //TODO: notify people via email?? Make it optional.
     if (self::$email_notification) {
         $email = new Email(Email::getAdminEmail(), Email::getAdminEmail(), sprintf(_t('Order.CANCELSUBJECT', 'Order #%d cancelled by member'), $order->ID), $order->renderWith('Order'));
         $email->send();
     }
     if (Member::currentUser() && ($link = AccountPage::find_link())) {
         //TODO: set session message "order successfully cancelled".
         Director::redirect($link);
         //TODO: can't redirect to account page when not logged in
     } else {
         $form->Controller()->setSessionMessage(_t("OrderForm.ORDERCANCELLED", "Order sucessfully cancelled"), 'warning');
         //assumes controller has OrderManipulation extension
         Director::redirectBack();
     }
     return;
 }
    private function collateexamplepages()
    {
        $this->addExamplePages(0, "Checkout page", CheckoutPage::get()->First());
        $this->addExamplePages(0, "Order Confirmation page", OrderConfirmationPage::get()->First());
        $this->addExamplePages(0, "Cart page (review cart without checkout)", CartPage::get()->where("ClassName = 'CartPage'")->First());
        $this->addExamplePages(0, "Account page", AccountPage::get()->First());
        //$this->addExamplePages(1, "Donation page", AnyPriceProductPage::get()->First());
        $this->addExamplePages(1, "Products that can not be sold", Product::get()->where("\"AllowPurchase\" = 0 AND ClassName = 'Product'")->First());
        $this->addExamplePages(1, "Product group with short product display template", ProductGroup::get()->where("\"DisplayStyle\" = 'Short'")->First());
        $this->addExamplePages(1, "Product group with medium length product display template", ProductGroup::get()->where("\"DisplayStyle\" = ''")->First());
        $this->addExamplePages(1, "Product group with more detail product display template", ProductGroup::get()->where("\"DisplayStyle\" = 'MoreDetail'")->First());
        //$this->addExamplePages(1, "Quick Add page", AddToCartPage::get()->first());
        //$this->addExamplePages(1, "Shop by Tag page ", ProductGroupWithTags::get()->first());
        $this->addExamplePages(2, "Delivery options (add product to cart first)", CheckoutPage::get()->First());
        $this->addExamplePages(2, "Taxes (NZ based GST - add product to cart first)", CheckoutPage::get()->first());
        $this->addExamplePages(2, "Discount Coupon (try <i>AAA</i>)", CheckoutPage::get()->First());
        $this->addExamplePages(4, "Products with zero price", Product::get()->where("\"Price\" = 0 AND ClassName = 'Product'")->First());
        //$this->addExamplePages(5, "Corporate Account Order page", AddUpProductsToOrderPage::get()->First());
        $html = '
		<h2>Some Interesting Features</h2>
		<p>
			Below are some features of this e-commerce application that may be of interest to you:
		</p>
		<ul>
			<li>customised search for users with search history graphs for admins</li>
			<li>ability to check-out with or without adding a password (creating an account)</li>
			<li>easy to use CMS</li>
			<li>very fast product listings, making extensive use of caching</li>
			<li>many ways to display products, allowing the content editor to set things like <i>products per page</i>, <i>product selctions</i>, <i>sorting orders</i></li>
			<li>multi-currency options and currency conversions</li>
			<li>step-by-step system for completed orders leading them from being submitted to archived via very steps.  This allows the admin to review orders where needed, add extra information, such as tracking codes for delivery, etc...</li>
			<li>code that is very easy to customise and adjust for your needs</li>
			<li>a ton of additional modules are available - you can add them directly to your e-commece install or use these as examples for building your own extensions </li>
			<li>geo-coding for addresses</li>
			<li>extensive developer assistance through various tools and personalised help</li>
		</ul>
		<h2>examples shown on this demo site</h2>';
        foreach ($this->examplePages as $key => $exampleGroups) {
            $html .= "<h3>" . $exampleGroups["Title"] . "</h3><ul>";
            foreach ($exampleGroups["List"] as $examplePages) {
                $html .= '<li><span class="exampleTitle">' . $examplePages["Title"] . '</span>' . $examplePages["List"] . '</li>';
            }
            $html .= "</ul>";
        }
        $html .= '
		<h2>API Access</h2>
		<p>
			E-commerce allows you to access its model using the built-in Silverstripe API.
			This is great for communication with third party applications.
			Access examples are listed below:
		</p>
		<ul>
			<li><a href="/api/v1/Order/">view all orders</a></li>
			<li><a href="/api/v1/Order/1">view order with ID = 1</a></li>
		</ul>
		<p>
			For more information on the restful server API, you can visit the modules home: <a href="https://github.com/silverstripe/silverstripe-restfulserver">https://github.com/silverstripe/silverstripe-restfulserver</a> to find out more on this topic.
		</p>
		';
        $featuresPage = Page::get()->where("URLSegment = 'features'")->First();
        $featuresPage->Content .= $html;
        $featuresPage->write();
        $featuresPage->Publish('Stage', 'Live');
        $featuresPage->flushCache();
    }
 /**
  * Returns the link to the AccountPage on this site
  * @return String (URLSegment)
  */
 public static function find_link()
 {
     $page = AccountPage::get()->filter(array("ClassName" => "AccountPage"))->First();
     if ($page) {
         return $page->Link();
     }
 }
 /**
  * @return String (URLSegment)
  **/
 public function AccountPageLink()
 {
     return AccountPage::find_link();
 }
 /**
  * Standard SS method
  * Sets the days available for repeating orders.
  */
 function onBeforeWrite()
 {
     parent::onBeforeWrite();
     $days = explode(",", $this->OrderDays);
     $cleanDays = array();
     if (count($days)) {
         foreach ($days as $day) {
             $day = trim($day);
             if (count(self::$week_days)) {
                 foreach (self::$week_days as $perfectDay) {
                     if (strtolower($day) == strtolower($perfectDay)) {
                         $cleanDays[$perfectDay] = $perfectDay;
                     }
                 }
             }
         }
     }
     if (count($cleanDays)) {
         $this->OrderDays = implode(",", $cleanDays);
     } else {
         $this->OrderDays = implode(",", self::$week_days);
     }
 }
 /**
  * This can be used by admins to log in as customers
  * to place orders on their behalf...
  * @param SS_HTTPRequest
  * @return REDIRECT
  */
 function loginas(SS_HTTPRequest $request)
 {
     if (Permission::check("ADMIN") || Permission::check(EcommerceConfig::get("EcommerceRole", "admin_group_code"))) {
         $newMember = Member::get()->byID(intval($request->param("ID")));
         if ($newMember) {
             $oldMember = Member::currentUser();
             if ($oldMember) {
                 $oldMember->logout();
                 $newMember->login();
                 if ($accountPage = AccountPage::get()->first()) {
                     return $this->redirect($accountPage->Link());
                 } else {
                     return $this->redirect(Director::baseURL());
                 }
             } else {
                 echo "Another error occurred.";
             }
         } else {
             echo "Can not find this member.";
         }
     } else {
         echo "please <a href=\"Security/login/?BackURL=" . urlencode($this->config()->get("url_segment") . "/debug/") . "\">log in</a> first.";
     }
 }
 /**
  * React to DSP response triggered by {@link processPayment()}.
  */
 public function processResponse()
 {
     if (preg_match('/^PXHOST/i', $_SERVER['HTTP_USER_AGENT'])) {
         $dpsDirectlyConnecting = 1;
     }
     //$pxaccess = new PxAccess($PxAccess_Url, $PxAccess_Userid, $PxAccess_Key, $Mac_Key);
     $pxpay = new PxPay(DPSHostedPayment::$pxPay_Url, DPSHostedPayment::get_px_pay_userid(), DPSHostedPayment::get_px_pay_key());
     $enc_hex = $_REQUEST["result"];
     $rsp = $pxpay->getResponse($enc_hex);
     if (isset($dpsDirectlyConnecting) && $dpsDirectlyConnecting) {
         // DPS Service connecting directly
         $success = $rsp->getSuccess();
         # =1 when request succeeds
         echo $success == '1' ? "success" : "failure";
     } else {
         // Human visitor
         $paymentID = $rsp->getTxnId();
         $SQL_paymentID = (int) $paymentID;
         $payment = DataObject::get_one('DPSHostedPayment', "`TxnID` = '{$SQL_paymentID}'");
         if (!$payment) {
             // @todo more specific error messages
             return array('RedirectLink' => AccountPage::find_link());
         }
         $success = $rsp->getSuccess();
         if ($success == '1') {
             // @todo Use AmountSettlement for amount setting?
             $payment->TxnRef = $rsp->getDpsTxnRef();
             $payment->Status = "Success";
             $payment->AuthorizationCode = $rsp->getAuthCode();
         } else {
             $payment->Message = $rsp->getResponseText();
             $payment->Status = "Failure";
         }
         $payment->write();
         //TODO: this needs to be generalised in Payment??
         $redirectURL = $payment->PaidObject() && $payment->PaidObject()->Link() ? $payment->PaidObject()->Link() : 'home';
         Director::redirect($redirectURL);
         return null;
     }
 }
Example #17
0
 /**
  * @TODO Why do we need to get this from the AccountPage class?
  */
 function Link()
 {
     return AccountPage::get_order_link($this->ID);
 }