function execute() { $payment = Request::get('payment'); $method = Payment::factory($payment, 'connection'); if (!$method) { echo 'error'; } $model = new connectionUserBalanceModel(); $result = $method->callback($model); if ($method->callback($model)) { $model->where(array('id' => (int) $result))->update(array('param' => $_POST)); $model->success((int) $result); return 'success'; } else { return 'error'; } }
private function stepPurse($step) { $order = new Order(); if (!in_array($step, $order->getStepList())) { $this->sendPurseData(array('error' => '[`Title undefined step purse`]')); } switch ($step) { case 'price': $price = $order->getPrice(Request::post('payment')); $this->sendPurseData(array('prices' => $price)); break; case 'confirmation': $data = $order->create(Request::post('payment'), Request::post('price')); $method = Payment::factory(Request::post('payment'), 'connection'); if (!$method) { $this->sendPurseData(array('error' => '[`Title undefined payment method`]')); } $this->sendPurseData(array('result' => $method->payment($data))); break; } }
/** * Return an array of all existing objects of this type in the database */ public static function getAllPayments() { $sql = 'select `classname` from cart_payment where status=1'; $results = Database::singleton()->query_fetch_all($sql); foreach ($results as &$result) { $result = Payment::factory($result['classname']); } return $results; }
public static function initSessionVariables() { //This function initializes the values stored in the session IF THEY DON'T ALREADY EXIST //For example, the shipping object, payment, etc if (!isset($_SESSION['authenticated_user'])) { $_SESSION['authenticated_user'] = new User(); } if (!isset($_SESSION['cart_basket'])) { $_SESSION['cart_basket'] = array(); } if (!isset($_SESSION['cart_checkout']['shipping'])) { $_SESSION['cart_checkout']['shipping'] = Shipping::factory('EAndA'); //Always set the shipping to EAndA } if (!isset($_SESSION['cart_checkout']['payment'])) { $_SESSION['cart_checkout']['payment'] = Payment::factory('Paypal'); } if (!isset($_SESSION['cart_checkout']['address']['shipping_address'])) { $_SESSION['cart_checkout']['address']['shipping_address'] = new Address(); } if (!isset($_SESSION['cart_checkout']['address']['billing_address'])) { $_SESSION['cart_checkout']['address']['billing_address'] = new Address(); } if (!isset($_SESSION['cart_checkout']['order'])) { $_SESSION['cart_checkout']['order'] = new CartOrder(); } if (!isset($_SESSION['cart_checkout']['orderFailureReason'])) { $_SESSION['cart_checkout']['orderFailureReason'] = ""; } }