Example #1
0
function fn_exim_orders_get_data($order_id, $type)
{
    $data = db_get_field("SELECT data FROM ?:order_data WHERE order_id = ?i AND type = ?s", $order_id, $type);
    if (!empty($data)) {
        // Payment information
        if ($type == 'P') {
            $data = @unserialize(fn_decrypt_text($data));
            // Coupons, Taxes and Shipping information
        } elseif (strpos('CTL', $type) !== false) {
            $data = @unserialize($data);
        }
        return YAML_Parser::serialize($data);
    }
}
Example #2
0
 /**
  * Return order/orders info after the order placing
  * @param int   $order_id
  * @param array $response
  */
 public static function returnPlacedOrders($order_id, &$response, $items_per_page, $lang_code)
 {
     $order = self::getOrderInfo($order_id);
     $_error = false;
     $status = db_get_field('SELECT status FROM ?:orders WHERE order_id=?i', $order_id);
     if ($status == STATUS_PARENT_ORDER) {
         $child_orders = db_get_hash_single_array("SELECT order_id, status FROM ?:orders WHERE parent_order_id = ?i", array('order_id', 'status'), $order_id);
         $status = reset($child_orders);
         $order['child_orders'] = array_keys($child_orders);
     }
     if (!in_array($status, fn_get_order_paid_statuses())) {
         $_error = true;
         if ($status != 'B') {
             if (!empty($child_orders)) {
                 array_unshift($child_orders, $order_id);
             } else {
                 $child_orders = array();
                 $child_orders[] = $order_id;
             }
             $order_id_field = $status == 'N' ? 'processed_order_id' : 'failed_order_id';
             $_SESSION['cart'][$order_id_field] = $child_orders;
             $cart =& $_SESSION['cart'];
             if (!empty($cart['failed_order_id'])) {
                 $_ids = !empty($cart['failed_order_id']) ? $cart['failed_order_id'] : $cart['processed_order_id'];
                 $_order_id = reset($_ids);
                 $_payment_info = db_get_field("SELECT data\n                         FROM ?:order_data\n                         WHERE order_id = ?i AND type = 'P'", $_order_id);
                 if (!empty($_payment_info)) {
                     $_payment_info = unserialize(fn_decrypt_text($_payment_info));
                 }
                 $_msg = !empty($_payment_info['reason_text']) ? $_payment_info['reason_text'] : '';
                 $_msg .= empty($_msg) ? __('text_order_placed_error') : '';
                 $response->addError('ERROR_FAIL_POST_ORDER', $_msg);
                 $cart['processed_order_id'] = $cart['failed_order_id'];
                 unset($cart['failed_order_id']);
             } elseif (!fn_twg_set_internal_errors($response, 'ERROR_FAIL_POST_ORDER')) {
                 $response->addError('ERROR_FAIL_POST_ORDER', __('fail_post_order', $lang_code));
             }
         } else {
             if (!fn_twg_set_internal_errors($response, 'ERROR_ORDER_BACKORDERED')) {
                 $response->addError('ERROR_ORDER_BACKORDERED', __('text_order_backordered', $lang_code));
             }
         }
         $response->returnResponse();
     }
     $auth =& $_SESSION['auth'];
     $user = fn_get_user_info($auth['user_id']);
     $profile_points = !empty($user['points']) ? $user['points'] : 0;
     if (empty($order['child_orders'])) {
         $response->setData(array('order' => $order, 'profile_points' => $profile_points));
     } else {
         $params = array();
         if (empty($auth['user_id'])) {
             $params['order_id'] = $auth['order_ids'];
         } else {
             $params['user_id'] = $auth['user_id'];
         }
         list($orders, , $totals) = fn_get_orders($params, $items_per_page, true);
         $response->setMeta(!empty($totals['gross_total']) ? $totals['gross_total'] : 0, 'gross_total');
         $response->setMeta(!empty($totals['totally_paid']) ? $totals['totally_paid'] : 0, 'totally_paid');
         $response->setMeta($order, 'order');
         $response->setResponseList(TwigmoOrder::getOrdersAsApiList($orders, $lang_code));
         $response->setData($profile_points, 'profile_points');
         $pagination_params = array('items_per_page' => !empty($items_per_page) ? $items_per_page : TWG_RESPONSE_ITEMS_LIMIT, 'page' => !empty($_REQUEST['page']) ? $_REQUEST['page'] : 1);
         fn_twg_set_response_pagination($response, $pagination_params);
     }
 }
Example #3
0
    if (Registry::get('settings.General.user_multiple_profiles') == 'Y') {
        $user_profiles = fn_get_user_profiles($auth['user_id']);
        Tygh::$app['view']->assign('user_profiles', $user_profiles);
    }
    fn_checkout_summary($cart);
    Tygh::$app['view']->assign('use_ajax', 'true');
    Tygh::$app['view']->assign('completed_steps', $completed_steps);
    Tygh::$app['view']->assign('location', 'checkout');
    Tygh::$app['view']->assign('cart', $cart);
    Tygh::$app['view']->assign('cart_products', array_reverse($cart_products, true));
    Tygh::$app['view']->assign('product_groups', $cart['product_groups']);
    if (!empty($cart['failed_order_id']) || !empty($cart['processed_order_id'])) {
        $_ids = !empty($cart['failed_order_id']) ? $cart['failed_order_id'] : $cart['processed_order_id'];
        $_order_id = reset($_ids);
        $_payment_info = db_get_field("SELECT data FROM ?:order_data WHERE order_id = ?i AND type = 'P'", $_order_id);
        $_payment_info = !empty($_payment_info) ? unserialize(fn_decrypt_text($_payment_info)) : array();
        if (!empty($cart['failed_order_id'])) {
            $_msg = !empty($_payment_info['reason_text']) ? $_payment_info['reason_text'] : '';
            $_msg .= empty($_msg) ? __('text_order_placed_error') : '';
            fn_set_notification('O', '', $_msg);
            $cart['processed_order_id'] = $cart['failed_order_id'];
            unset($cart['failed_order_id']);
        }
        unset($_payment_info['card_number'], $_payment_info['cvv2']);
        $cart['payment_info'] = $_payment_info;
        if (!empty($cart['extra_payment_info'])) {
            $cart['payment_info'] = array_merge($cart['payment_info'], $cart['extra_payment_info']);
        }
    }
    // Delete product from the cart
} elseif ($mode == 'delete' && isset($_REQUEST['cart_id'])) {
Example #4
0
 public function addPaymentNotifications()
 {
     if (empty($_REQUEST['action']) or empty($_REQUEST['object']) or $_REQUEST['action'] != 'get' or $_REQUEST['object'] != 'errors') {
         return;
     }
     $cart =& $_SESSION['cart'];
     if (!empty($cart['failed_order_id']) || !empty($cart['processed_order_id'])) {
         $_ids = !empty($cart['failed_order_id']) ? $cart['failed_order_id'] : $cart['processed_order_id'];
         $_order_id = reset($_ids);
         $_payment_info = db_get_field("SELECT data FROM ?:order_data WHERE order_id = ?i AND type = 'P'", $_order_id);
         if (!empty($_payment_info)) {
             $_payment_info = unserialize(fn_decrypt_text($_payment_info));
         }
         if (!empty($cart['failed_order_id'])) {
             $_msg = !empty($_payment_info['reason_text']) ? $_payment_info['reason_text'] : '';
             $_msg .= empty($_msg) ? __('text_order_placed_error') : '';
             fn_set_notification('O', '', $_msg);
             $cart['processed_order_id'] = $cart['failed_order_id'];
             unset($cart['failed_order_id']);
         }
     }
 }
Example #5
0
function fn_get_default_credit_card(&$cart, $user_data)
{
    if (!empty($user_data['credit_cards'])) {
        $cards = unserialize(fn_decrypt_text($user_data['credit_cards']));
        foreach ((array) $cards as $cc) {
            if ($cc['default']) {
                $cart['payment_info'] = $cc;
                break;
            }
        }
    } elseif (isset($cart['payment_info'])) {
        unset($cart['payment_info']);
    }
}
Example #6
0
function fn_pp_get_mode($order_id)
{
    $result = 'test';
    $payment_info = db_get_field("SELECT data FROM ?:order_data WHERE order_id = ?i AND type = 'P'", $order_id);
    if (!empty($payment_info)) {
        $payment_info = unserialize(fn_decrypt_text($payment_info));
        if (!empty($payment_info['pp_mode'])) {
            $result = $payment_info['pp_mode'];
        }
    }
    return $result;
}
Example #7
0
function fn_cleanup_payment_info($order_id, $payment_info, $silent = false)
{
    if ($silent == false) {
        $processing_msg = fn_get_lang_var('processing_order');
        $done_msg = fn_get_lang_var('uc_ok');
        echo $processing_msg . '&nbsp;<b>#' . $order_id . '</b>...';
        fn_flush();
    }
    if (!is_array($payment_info)) {
        $info = @unserialize(fn_decrypt_text($payment_info));
    } else {
        $info = $payment_info;
    }
    if (!empty($info['cvv2'])) {
        $info['cvv2'] = 'XXX';
    }
    if (!empty($info['card_number'])) {
        $info['card_number'] = substr_replace($info['card_number'], str_repeat('X', strlen($info['card_number']) - 4), 0, strlen($info['card_number']) - 4);
    }
    foreach (array('start_month', 'start_year', 'expiry_month', 'expiry_year') as $v) {
        if (!empty($info[$v])) {
            $info[$v] = 'XX';
        }
    }
    $_data = fn_encrypt_text(serialize($info));
    db_query("UPDATE ?:order_data SET data = ?s WHERE order_id = ?i AND type = 'P'", $_data, $order_id);
    if ($silent == false) {
        echo $done_msg . '<br />';
    }
}
Example #8
0
    } else {
        $uid = $auth['user_id'];
    }
    $can_delete = db_get_field("SELECT profile_id FROM ?:user_profiles WHERE user_id = ?i AND profile_id = ?i AND profile_type = 'S'", $uid, $_REQUEST['profile_id']);
    if (!empty($can_delete)) {
        db_query("DELETE FROM ?:user_profiles WHERE profile_id = ?i", $_REQUEST['profile_id']);
    }
    return array(CONTROLLER_STATUS_OK, "profiles.update?user_id=" . $uid);
} elseif ($mode == 'delete_card') {
    if (AREA == 'A' && fn_is_restricted_admin($_REQUEST) == true) {
        return array(CONTROLLER_STATUS_DENIED);
    }
    if (!empty($_REQUEST['card_id']) && !empty($_REQUEST['profile_id'])) {
        $cards_data = db_get_field("SELECT credit_cards FROM ?:user_profiles WHERE profile_id = ?i", $_REQUEST['profile_id']);
        if (!empty($cards_data)) {
            $cards = unserialize(fn_decrypt_text($cards_data));
            $is_default = $cards[$_REQUEST['card_id']]['default'];
            unset($cards[$_REQUEST['card_id']]);
            if ($is_default && !empty($cards)) {
                reset($cards);
                $cards[key($cards)]['default'] = true;
            }
            $cards_data = array('credit_cards' => empty($cards) ? '' : fn_encrypt_text(serialize($cards)));
            db_query('UPDATE ?:user_profiles SET ?u WHERE profile_id = ?i', $cards_data, $_REQUEST['profile_id']);
            if (AREA == 'A') {
                $uid = empty($_REQUEST['user_id']) ? $auth['user_id'] : $_REQUEST['user_id'];
            } else {
                $uid = $auth['user_id'];
            }
            return array(CONTROLLER_STATUS_OK, "profiles.update?user_id={$uid}&profile_id={$_REQUEST['profile_id']}");
        }
Example #9
0
 public static function apiOrdersGetData($order_id, $type, $object_type, $data = array(), $single = true)
 {
     if (empty($data)) {
         $data = db_get_field("SELECT data FROM ?:order_data WHERE order_id = ?i AND type = ?s", $order_id, $type);
         // Payment information
         if ($type == 'P') {
             $data = @unserialize(fn_decrypt_text($data));
             // Coupons, Taxes and Shipping information
         } elseif (strpos('CTL', $type) !== false) {
             $data = @unserialize($data);
         }
         if (empty($data)) {
             return array();
         }
     }
     if ($single) {
         return self::getAsApiObject($object_type, $data);
     }
     return self::getAsList($object_type, ApiData::getObjects($data));
 }