Exemple #1
0
 function updateAction()
 {
     $model = new Profile();
     if (isset($_POST['ajax'])) {
         // Add method to profile
         if (isset($_POST['model']) && $_POST['model'] == 'profiles_methods') {
             $profileMethod = new ProfileMethod();
             @$this->performAjaxValidation($profileMethod);
             // Uncomment the line if AJAX validation is needed
             if ($_POST['action'] == 'create') {
                 $profileMethod->fillFromArray($_POST, TRUE);
             } elseif ($_POST['action'] == 'update') {
                 $methodID = (int) AF::get($_POST, 'method_id');
                 $profileID = (int) AF::get($_POST, 'profile_id');
                 $profileMethod = ProfileMethod::model()->findByPk(array('method_id' => $methodID, 'profile_id' => $profileID));
                 $profileMethod->fillFromArray($_POST);
             }
             if ($profileMethod->method_id == Method::METHOD_CC) {
                 if (isset($_POST['flags']['filter']) && $_POST['flags']['filter']) {
                     if (!$profileMethod->flags) {
                         $profileMethod->flags = '';
                     }
                     @$profileMethod->addFlags('filter');
                 } else {
                     $profileMethod->removeFlags('filter');
                 }
             }
             if (!$profileMethod->flags) {
                 $profileMethod->flags = '';
             }
             if ($profileMethod->save()) {
                 $link = AF::link(array('profiles' => 'update'), array('id' => $profileMethod->profile_id));
                 Message::echoJson('success', array('redirect' => $link));
             } else {
                 Message::echoJsonError(__('profile_method_not_' . $_POST['action'] . 'd') . '. ' . $profileMethod->errors2string);
             }
         }
         if (isset($_POST['getprofilemethodinfo'])) {
             $methodID = (int) AF::get($_POST, 'method_id');
             $profileID = (int) AF::get($_POST, 'profile_id');
             $methods = Method::model()->cache()->findAllInArray();
             //$model = ProfileMethod::model()->find("profiles_methods_id=:profiles_methods_id", array(':profiles_methods_id'=>$id));
             $model = ProfileMethod::model()->findByPk(array('method_id' => $methodID, 'profile_id' => $profileID));
             echo $this->view->includeFile('_methods_form', array('application', 'views', 'profiles'), array('action' => 'update', 'ajax' => TRUE, 'popup' => TRUE, 'methodModel' => $model, 'methods' => $methods));
             die;
         }
     }
     if (isset($_POST['model'])) {
         // Change profile_name
         if ($_POST['model'] == 'profile') {
             if (isset($_POST['ajax'])) {
                 $this->performAjaxValidation($model);
                 // Uncomment the line if AJAX validation is needed
                 $model->fillFromArray($_POST, FALSE);
                 $model->user_id_updated = $this->user->user_id;
                 $model->updated = 'NOW():sql';
                 $model->model_uset_id = $this->user->user_id;
                 if ($model->save()) {
                     $link = AF::link(array('profiles' => 'update'), array('id' => $model->PkValue));
                     Message::echoJson('success', array('redirect' => $link));
                 } else {
                     Message::echoJsonError(__('profile_no_updated'));
                 }
                 die;
             }
             $this->redirect();
             die;
         }
         // Add gateway to profile
         if ($_POST['model'] == 'profiles_gateways') {
             $profileGateway = new ProfileGateway();
             $this->performAjaxValidation($profileGateway);
             // Uncomment the line if AJAX validation is needed
             $profileGateway->fillFromArray($_POST, TRUE);
             $profileGateway->addGateway();
         }
     }
     $id = AF::get($this->params, 'id', FALSE);
     $pagination = new Pagination(array('action' => $this->action, 'controller' => $this->controller, 'params' => $this->params));
     $models = AFActiveDataProvider::models('ProfileGateway', $this->params, $pagination);
     $profile_methods = ProfileMethod::model()->getProfileMethodsByProfile($id);
     //$method_ids = '0';
     if ($profile_methods) {
         foreach ($profile_methods as $key => $value) {
             $method_id_array[] = $value['method_id'];
         }
         $method_ids = implode(',', $method_id_array);
     }
     $methods = Method::model()->cache()->findAllInArray();
     $gateways = Gateway::model()->getGateways();
     if (!$id) {
         throw new AFHttpException(0, 'no_id');
     }
     if (!$model->findByPk($id)) {
         throw new AFHttpException(0, 'incorrect_id');
     }
     //for create profile method
     $modelProfileMethod = new ProfileMethod();
     $modelProfileMethod->profile_id = $model->profile_id;
     Assets::js('jquery.form');
     $this->addToPageTitle('Edit Profile');
     $this->render('update', array('model' => $model, 'gateways' => $gateways, 'models' => $models, 'methods' => $methods, 'profile_methods' => $profile_methods, 'modelProfileMethod' => $modelProfileMethod));
 }
Exemple #2
0
 /**
  * @return PaymentAPIResponse
  */
 public function payOrder($order, $price)
 {
     $this->_paymetnResponse->clear();
     if (!$this->initOrder($order)) {
         return $this->_paymetnResponse;
     }
     $this->attemptModel = new Attempt();
     $this->attemptModel->getLastOrderAttempt($this->orderModel->order_id, Attempt::DEBIT_TYPE);
     // if in inprogress status, update status
     if (in_array($this->attemptModel->status, array(Attempt::SUBMITED_STATUS, Attempt::INPROGRESS_STATUS))) {
         $this->updateStatusAttempt();
     }
     //Set response params
     $this->_paymetnResponse->attemptModel = $this->attemptModel;
     $this->_paymetnResponse->paymentModel = $this->paymentModel;
     if (!$this->attemptModel->attempt_id || in_array($this->attemptModel->status, array(Attempt::NEW_STATUS, Attempt::DECLINED_STATUS, Attempt::UNKNOWN_STATUS))) {
         $payAttempt = 1;
         $gatewayAttemptArray = array();
         $currentGatewayID = $this->gatewayModel->gateway_id;
         // Trying to pay via several gateways
         do {
             if ($payAttempt > 1) {
                 $gatewayModel = Gateway::model()->findByPk($this->gatewayModel->next_id);
                 // if empty or we have tried this gateway yet, then return response
                 if (!$gatewayModel || in_array($gatewayModel->gateway_id, $gatewayAttemptArray)) {
                     break;
                 }
                 $this->gatewayModel = $gatewayModel;
                 $this->_ps->setModel($this->gatewayModel);
             }
             $this->createAttempt(Attempt::DEBIT_TYPE, $price);
             $this->payAttempt();
             $gatewayAttemptArray[] = $currentGatewayID = $this->gatewayModel->gateway_id;
             $payAttempt++;
         } while ($this->_paymetnResponse->attemptStatus == Attempt::DECLINED_STATUS && $this->gatewayModel->next_id);
         // rewrite gateway_id by order if changed
         if ($this->orderModel->gateway_id != $currentGatewayID) {
             $this->orderModel->gateway_id = $currentGatewayID;
             $this->orderModel->save();
         }
     } elseif (in_array($this->attemptModel->status, array(Attempt::SUCCESS_STATUS, Attempt::CHARGEBACK_STATUS))) {
         //return success
         $this->_paymetnResponse->status = PaymentAPIResponse::SUCCESS_STATUS;
     } elseif (in_array($this->attemptModel->status, array(Attempt::SUBMITED_STATUS, Attempt::INPROGRESS_STATUS))) {
         //return status
         $this->_paymetnResponse->status = PaymentAPIResponse::SUCCESS_STATUS;
     } else {
         //unknown error
         $this->_paymetnResponse->status = PaymentAPIResponse::ERROR_STATUS;
         $this->_paymetnResponse->addError('unknown_error');
     }
     return $this->_paymetnResponse;
 }
Exemple #3
0
 @include_once '../../ws/class/payment.class.php';
 @include_once '../../ws/class/payment_'.$orderModel->payment_type.'.class.php';
 $paymentSystem = Payment::getPaymentSystem($orderModel);
 */
 $paymentModelName = 'Order' . ucfirst($orderModel->payment_type);
 $paymentModel = new $paymentModelName();
 $paymentModel->fillFromDbPk($orderModel->order_id);
 $newPaymentModel = new $paymentModelName();
 $newPaymentModel->setIsNewRecord(false);
 $newPaymentModel->order_id = $orderModel->order_id;
 $newPaymentModel->request_id = base_convert($orderModel->order_id . time(), 10, 36);
 $newPaymentModel->save(false);
 //if Pacnet
 @(include_once '../../ws/class/raven_config_demo.class.php');
 @(include_once '../../ws/class/ravenrequest.class.php');
 $gateway = Gateway::model()->findByPk($orderModel->gateway_id)->getAttributes();
 $arrayNote1 = unserialize(NoteBase64::decode($paymentModel->note1));
 //if test credit card
 if ($arrayNote1['ccn'] == Config::TESTCREDITCARDNUMBER || $paymentModel->pn_status == 'test') {
     $newPaymentModel->pn_status = 'test';
     $newPaymentModel->save(false);
     $orderModel->status = 'ok';
     //$orderModel->recurring_next = 'NULL:sql';
     $orderModel->payment_total = $orderModel->amount_product + $orderModel->amount_shipping;
     $orderModel->save(false);
     continue;
 }
 if (!$arrayNote1['ccn'] || !$arrayNote1['ccc'] || !$paymentModel->currency || !$paymentModel->pn_payment_type || !$paymentModel->expiry_date || !$orderModel->fullAmountCent) {
     $newPaymentModel->pn_status = 'error';
     $newPaymentModel->save(false);
     $orderModel->status = 'error';
Exemple #4
0
 public function updateAction()
 {
     $model = new Gateway();
     $this->performAjaxValidation($model);
     // Uncomment the following line if AJAX validation is needed
     if (isset($_POST['model']) && $_POST['model'] == 'Gateway') {
         if (isset($_POST['ajax'])) {
             $model->fillFromArray($_POST, FALSE);
             $model->user_id_updated = $this->user->user_id;
             $model->updated = 'NOW():sql';
             $model->model_uset_id = $this->user->user_id;
             if ($model->save()) {
                 Message::echoJsonSuccess(__('gateway_updated'));
             } else {
                 Message::echoJsonError(__('gateway_no_updated'));
             }
             die;
         }
         $model->save();
         $this->redirect();
         die;
     }
     $id = AF::get($this->params, 'id', FALSE);
     if (!$id) {
         throw new AFHttpException(0, 'no_id');
     }
     if (!$model->cache()->findByPk($id)) {
         throw new AFHttpException(0, 'incorrect_id');
     }
     $currencies = Currency::model()->cache()->findAllInArray();
     $methods = Method::model()->cache()->findAllInArray();
     $systems = PSystem::model()->cache()->findAllInArray();
     $gateways = Gateway::model()->cache()->findAllInArray();
     $pagination = new Pagination(array('action' => $this->action, 'controller' => $this->controller, 'params' => $this->params));
     $models = AFActiveDataProvider::models('GatewayLimit', $this->params, $pagination);
     $limits = $models->getLimitsByGatewayId($id);
     Assets::js('jquery.form');
     $this->addToPageTitle('Update Gateway');
     $this->render('update', array('model' => $model, 'currencies' => $currencies, 'limits' => $limits, 'methods' => $methods, 'systems' => $systems, 'gateways' => $gateways));
 }
Exemple #5
0
 public function crmInit($post)
 {
     $this->wsType = 'x1';
     $this->intervalCheck = false;
     $this->campaign = new Campaign();
     // is this a valid campaign?
     if (!$this->campaign->fillfromDbPk($post['campaign_id'])) {
         // if(!$campaign->getPkValue())
         $this->apiError('This is not a valid request');
     }
     $this->post = $post;
     $this->post['user_ip'] = '127.0.0.1';
     if (!isset($this->post['is_payment']) || !$this->post['is_payment']) {
         $this->isPayment = false;
     }
     if ($this->isPayment) {
         // determine ps
         $gateway = Gateway::model()->fillFromDbPk($this->post['gateway_id']);
         if ($gateway->gateway_id) {
             $this->post['ps'] = $gateway->system_code;
         }
     }
     if (isset($this->post['customer_id']) && $this->post['customer_id']) {
         $this->newCustomer = false;
     }
 }