public function add($autodate = true, $null_values = false)
 {
     if (!parent::add($autodate)) {
         return false;
     }
     $order = new Order((int) $this->id_order);
     // Update id_order_state attribute in Order
     $order->current_state = $this->id_order_state;
     $order->update();
     // start of implementation of the module code - taxamo
     $operation = null;
     $list_orderstateoperation = Taxamoeuvat::getListValues();
     foreach ($list_orderstateoperation as $orderstateoperation) {
         if ($orderstateoperation['id_order_state'] == $order->current_state) {
             $operation = $orderstateoperation['operation'];
         }
     }
     if (!is_null($operation)) {
         if ($operation == 1 || $operation == 2) {
             $last_id_order_transaction = Taxamoeuvat::getLastIdByOrder($order->id);
             if (is_null($last_id_order_transaction)) {
                 $res_process_store_transaction = Tools::taxamoStoreTransaction($order->id_currency, $order->id_address_invoice, $order->id_customer, $order->getCartProducts());
                 if (is_null($res_process_store_transaction['key_transaction'])) {
                     $res_process_store_transaction['comment'] .= '* Transaccion NO Adicionada';
                 } else {
                     $res_process_store_transaction['comment'] .= '* Transaccion ADICIONADA';
                 }
                 Taxamoeuvat::addTransaction($order->id, $order->current_state, $res_process_store_transaction['key_transaction'], $res_process_store_transaction['comment']);
             } else {
                 $reg_taxamo_transaction = null;
                 $reg_taxamo_transaction = Taxamoeuvat::idExistsTransaction((int) $last_id_order_transaction);
                 $res_process_store_transaction['key_transaction'] = $reg_taxamo_transaction[0]['key_transaction'];
                 $res_process_store_transaction['comment'] = '';
             }
             if ($operation == 2) {
                 if (is_null($res_process_store_transaction['key_transaction'])) {
                     $res_process_store_transaction['comment'] .= '* Transaccion NO Confirmada';
                 } else {
                     $res_process_confirm_transaction = Tools::taxamoConfirmTransaction($res_process_store_transaction['key_transaction']);
                     if (!is_null($res_process_confirm_transaction['status']) && $res_process_confirm_transaction['status'] == 'C') {
                         $res_process_store_transaction['comment'] .= '* Transaccion CONFIRMADA';
                     } else {
                         if (!empty($res_process_confirm_transaction['error'])) {
                             $res_process_store_transaction['comment'] .= $res_process_confirm_transaction['error'];
                             $res_process_store_transaction['comment'] .= '* Transaccion NO Confirmada';
                         }
                     }
                 }
                 Taxamoeuvat::addTransaction($order->id, $order->current_state, $res_process_store_transaction['key_transaction'], $res_process_store_transaction['comment']);
             }
         }
     }
     // end of code implementation module - taxamo
     Hook::exec('actionOrderHistoryAddAfter', array('order_history' => $this), null, false, true, false, $order->id_shop);
     return true;
 }
Example #2
0
//获取支付返回信息
$transactionid = $_POST['transactionid'];
$orderid = $_POST['orderid'];
$status = $_POST['status'];
$currency = $_POST['currency'];
$amount = $_POST['amount'];
$originalcurrency = $_POST['originalcurrency'];
$originalamount = $_POST['originalamount'];
$signature = $_POST['signature'];
//检验签名
if (strtolower($signature) !== strtolower(md5($transactionid . $orderid . $status . $currency . $amount . $originalcurrency . $originalamount . Configuration::get('GOFPAY_SECRET_KEY')))) {
    add_log('signature validate error: transactionid=' . $transactionid . '&orderid=' . $orderid . '&status=' . $status . '&currency=' . $currency . '&amount=' . $amount . '&originalcurrency=' . $originalcurrency . '&originalamount=' . $originalamount . '&signature=' . $signature);
    echo 'failed';
} else {
    add_log('receive order notify: transactionid=' . $transactionid . '&orderid=' . $orderid . '&status=' . $status . '&currency=' . $currency . '&amount=' . $amount . '&originalcurrency=' . $originalcurrency . '&originalamount=' . $originalamount . '&signature=' . $signature . "\r\n");
    $history = new OrderHistoryCore();
    //获取最后一条的订单状态
    $order_Status = $history->getLastOrderState($orderid);
    if ($status == 'Pending') {
        //TODO:待支付
    } else {
        if ($status == 'Processing') {
            //TODO:处理中
        } else {
            if ($status == 'Success') {
                //支付成功
                //添加状态变更记录
                $flag = 2;
                Db::getInstance()->Execute('INSERT INTO ' . _DB_PREFIX_ . 'order_history (id_employee,id_order,id_order_state,date_add)
            VALUES (0,' . $orderid . ',' . '"' . $flag . '"' . ',sysdate())');
                //变更该订单状态