Jump to content

tdphong

Members
  • Posts

    31
  • Joined

  • Last visited

Posts posted by tdphong

  1. Hi naja7host,

     

    Here is my code :

     

    class AdminManagePlugin extends AppController {

        /**
         * Performs necessary initialization
         */
        private function init() {
            // Require login
            $this->parent->requireLogin();

            Language::loadLang("myGateway_manage_plugin", null, PLUGINDIR . "myGateway" . DS . "language" . DS);

            $this->uses(array("myGateway.myGatewayOrder", "Transactions", "Services", "Packages"));
            // Use the parent data helper, it's already configured properly
            $this->Date = $this->parent->Date;

            $this->plugin_id = isset($this->get[0]) ? $this->get[0] : null;

            // Set the page title
            $this->parent->structure->set("page_title", Language::_("myGatewayManagePlugin." . Loader::fromCamelCase($this->action ? $this->action : "index") . ".page_title", true));

            return $this->renderAjaxWidgetIfAsync(isset($this->get['sort']) ? true : (isset($this->get[1]) || isset($this->get[0]) ? false : null));
        }

        /**
         * Returns the view to be rendered when managing this plugin
         */
        public function index() {

            $this->init();

            $status = (isset($this->get['status']) ? $this->get['status'] : "pending");
            $page = (isset($this->get[1]) ? (int) $this->get[1] : 1);
            $sort = (isset($this->get['sort']) ? $this->get['sort'] : "date_added");
            $order_sort = (isset($this->get['order']) ? $this->get['order'] : "desc");
            //print_r($status);exit;
            if (isset($this->get[0]))
                $status = $this->get[0];

            // If no page set, fetch counts
            if (!isset($this->get[1])) {
                $status_count = array(
                    'pending' => $this->myGatewayOrder->getListCount("pending"),
                    'accepted' => $this->myGatewayOrder->getListCount("accepted"),
                    'fraud' => $this->myGatewayOrder->getListCount("fraud"),
                    'canceled' => $this->myGatewayOrder->getListCount("canceled"),
                );
            }

            $statuses = $this->myGatewayOrder->getStatuses();
            unset($statuses[$status]);

            $order = array();

            $total_results = $this->myGatewayOrder->getListCount(null);

            $order['order'] = $this->myGatewayOrder->getList(null, $page, array($sort => $order_sort));

            $feeds = $this->myGatewayOrder->getDefaultFeeds(Configure::get("Blesta.company_id"));

            // Overwrite default pagination settings
            $settings = array_merge(Configure::get("Blesta.pagination"), array(
                'total_results' => $total_results,
                'uri' => $this->base_uri . "settings/company/plugins/manage/" . $this->plugin_id . "/[p]/",
                'params' => array('sort' => $sort, 'order' => $order_sort),
                )
            );
            //$this->uses(array("Transactions", "Services", "Packages"));
            // print_r($this->Transactions->getApplied(null, $order['order'][0]->id));exit;
            $vars = array(
                'feeds' => $feeds,
                'plugin_id' => $this->plugin_id,
                'status_count' => $status_count,
                'orders' => $order['order'],
                //'transaction_types' => $this->Transactions->transactionTypeNames()
            );

            $this->helpers(array("Pagination" => array($this->get, $settings)));
            $this->Pagination->setSettings(Configure::get("Blesta.pagination_ajax"));

            // Set the view to render for all actions under this controller
            $this->view->setView(null, "myGateway.default");
            return $this->partial("admin_manage_plugin", $vars);
        }

    }

     

    Please help me! :)

    Thanks,

  2. Hi all,

     

    Currently, I am develop a payment method (a non-merchant). Here is the scenario:

    1. In the checkout step, I send the data to the payment gateway using "buildProcess()" function.

    2. After the payment processed, it will redirect to URL as below to run the "validate()" function:
    http://localhost/blesta/callback/gw/1/mygateway/?client_id=1&invoice=121=600.0000¤t_currency=USD&default_currency=AUD

     

    3. The "validate()" function will validate the gateway response to see the transaction is successful or failed.

    Now I want in the case of successful payment it will redirect to the success page, otherwise it will redirect to the error page.

    I see in the "validate()" function, it will return an array to log the transaction in DB. So how can I handle the redirect here?

     

    Thanks,

    Phong

×
×
  • Create New...