public function validateOrder()
 {
     $id_cart = $this->createCart();
     $id_order = false;
     if (isset($this->datas->paymentResult) && $id_cart) {
         $order_state = (int) Configuration::get('PS_OS_PAYMENT');
         $this->datas->customer = $this->datas->customer;
         $payment = new PowaTagPayment($this->datas, $id_cart);
         $id_order = $payment->confirmPayment(true);
         if ($id_order) {
             $message = Configuration::get('POWATAG_SUCCESS_MSG', $this->context->language->id) != '' ? Configuration::get('POWATAG_SUCCESS_MSG', $this->context->language->id) : 'Success';
         } else {
             $message = 'Error on order creation';
         }
     }
     if ($id_cart) {
         $transaction = new PowaTagTransaction();
         $transaction->id_cart = (int) $this->cart->id;
         $transaction->id_order = (int) $id_order;
         $transaction->id_customer = (int) $this->customer->id;
         if (isset($this->datas->device)) {
             $transaction->id_device = isset($this->datas->device->deviceID) ? $this->datas->device->deviceID : '';
             $transaction->ip_address = isset($this->datas->device->ipAddress) ? $this->datas->device->ipAddress : '';
         }
         $transaction->order_state = isset($order_state) ? (int) $order_state : 0;
         $transaction->save();
         $message = Configuration::get('POWATAG_SUCCESS_MSG', $this->context->language->id) != '' ? Configuration::get('POWATAG_SUCCESS_MSG', $this->context->language->id) : 'Success';
     } else {
         $message = 'Cart has not been created';
     }
     return array($id_cart, $id_order, $message);
 }
예제 #2
0
 private function transactionExists()
 {
     $transactions = PowaTagTransaction::getTransactions((int) $this->idCart);
     if (!$transactions || !count($transactions)) {
         $this->addError(sprintf($this->module->l('No transaction found for, Cart ID : %s, Device ID : %s & IP : %s'), $this->idCart, $this->datas->device->deviceID, $this->datas->device->ipAddress), PowaTagErrorType::$INTERNAL_ERROR);
         return false;
     }
     if (count($transactions) > 1) {
         $this->addError(sprintf($this->module->l('Too many transaction for, Cart ID : %s, Device ID : %s & IP : %s'), $this->idCart, $this->datas->device->deviceID, $this->datas->device->ipAddress), PowaTagErrorType::$INTERNAL_ERROR);
         return false;
     }
     $transaction = current($transactions);
     return (int) $transaction['id_powatag_transaction'];
 }