/**
 * WP eCommerce transaction results class
 *
 * This class is responsible for theming the transaction results page.
 *
 * @package wp-e-commerce
 * @since 3.8
 */
function wpsc_transaction_theme()
{
    global $wpdb, $user_ID, $nzshpcrt_gateways, $sessionid, $cart_log_id, $errorcode;
    $errorcode = '';
    $transactid = '';
    $dont_show_transaction_results = false;
    if (isset($_GET['sessionid'])) {
        $sessionid = $_GET['sessionid'];
    }
    if (!isset($_GET['sessionid']) && isset($_GET['ms'])) {
        $sessionid = $_GET['ms'];
    }
    if (isset($_GET['gateway']) && 'google' == $_GET['gateway']) {
        wpsc_google_checkout_submit();
        unset($_SESSION['wpsc_sessionid']);
    }
    if ('paypal_certified' == $_SESSION['wpsc_previous_selected_gateway']) {
        $sessionid = $_SESSION['paypalexpresssessionid'];
    }
    if (isset($_REQUEST['eway']) && '1' == $_REQUEST['eway']) {
        $sessionid = $_GET['result'];
    } elseif (isset($_REQUEST['eway']) && '0' == $_REQUEST['eway']) {
        echo $_SESSION['eway_message'];
    } elseif (isset($_REQUEST['payflow']) && '1' == $_REQUEST['payflow']) {
        echo $_SESSION['payflow_message'];
        $_SESSION['payflow_message'] = '';
    }
    // Replaces the ugly if else for gateways
    switch ($_SESSION['wpsc_previous_selected_gateway']) {
        case 'paypal_certified':
        case 'wpsc_merchant_paypal_express':
            echo $_SESSION['paypalExpressMessage'];
            if (isset($_SESSION['reshash']['TRANSACTIONTYPE']) && 'expresscheckout' == $_SESSION['reshash']['TRANSACTIONTYPE']) {
                $dont_show_transaction_results = false;
            } else {
                $dont_show_transaction_results = true;
            }
            break;
        case 'dps':
            $sessionid = decrypt_dps_response();
            break;
    }
    if (!$dont_show_transaction_results) {
        if (!empty($sessionid)) {
            $cart_log_id = $wpdb->get_var("SELECT `id` FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `sessionid`= " . $sessionid . " LIMIT 1");
            return transaction_results($sessionid, true);
        } else {
            printf(__('Sorry your transaction was not accepted.<br /><a href="%1$s">Click here to go back to checkout page</a>.', 'wpsc'), get_option("shopping_cart_url"));
        }
    }
}
function wpsc_transaction_theme()
{
    global $wpdb, $user_ID, $nzshpcrt_gateways, $sessionid, $cart_log_id, $errorcode;
    $errorcode = '';
    $transactid = '';
    $dont_show_transaction_results = false;
    if (isset($_GET['sessionid'])) {
        $sessionid = $_GET['sessionid'];
    }
    if (!isset($_GET['sessionid']) && isset($_GET['ms'])) {
        $sessionid = $_GET['ms'];
    }
    $selected_gateway = wpsc_get_customer_meta('selected_gateway');
    if ($selected_gateway && in_array($selected_gateway, array('paypal_certified', 'wpsc_merchant_paypal_express'))) {
        $sessionid = wpsc_get_customer_meta('paypal_express_sessionid');
    }
    if (isset($_REQUEST['eway']) && '1' == $_REQUEST['eway']) {
        $sessionid = $_GET['result'];
    } elseif (isset($_REQUEST['eway']) && '0' == $_REQUEST['eway']) {
        echo wpsc_get_customer_meta('eway_message');
    } elseif (isset($_REQUEST['payflow']) && '1' == $_REQUEST['payflow']) {
        echo wpsc_get_customer_meta('payflow_message');
        wpsc_delete_customer_meta('payflow_message');
    }
    $dont_show_transaction_results = false;
    if ($selected_gateway) {
        // Replaces the ugly if else for gateways
        switch ($selected_gateway) {
            case 'paypal_certified':
            case 'wpsc_merchant_paypal_express':
                echo wpsc_get_customer_meta('paypal_express_message');
                $reshash = wpsc_get_customer_meta('paypal_express_reshash');
                if (isset($reshash['PAYMENTINFO_0_TRANSACTIONTYPE']) && in_array($reshash['PAYMENTINFO_0_TRANSACTIONTYPE'], array('expresscheckout', 'cart'))) {
                    $dont_show_transaction_results = false;
                } else {
                    $dont_show_transaction_results = true;
                }
                break;
            case 'dps':
                $sessionid = decrypt_dps_response();
                break;
                //paystation was not updating the purchase logs for successful payment - this is ugly as need to have the databse update done in one place by all gatways on a sucsessful transaction hook not some within the gateway and some within here and some not at all??? This is getting a major overhaul but for here and now it just needs to work for the gold cart people!
            //paystation was not updating the purchase logs for successful payment - this is ugly as need to have the databse update done in one place by all gatways on a sucsessful transaction hook not some within the gateway and some within here and some not at all??? This is getting a major overhaul but for here and now it just needs to work for the gold cart people!
            case 'paystation':
                $ec = $_GET['ec'];
                $result = $_GET['em'];
                if ($result == 'Transaction successful' && $ec == 0) {
                    $processed_id = '3';
                }
                if ($result == 'Insufficient Funds' && $ec == 5) {
                    $processed_id = '6';
                }
                if ($processed_id) {
                    wpsc_update_purchase_log_status($sessionid, $processed_id, 'sessionid');
                }
                break;
            case 'wpsc_merchant_paymentexpress':
                // Payment Express sends back there own session id, which is temporarily stored in the Auth field
                // so just swapping that over here
                $query = "SELECT `sessionid` FROM  `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE  `authcode` ='" . $sessionid . "'";
                $result = $wpdb->get_var($query);
                if ($result != null) {
                    // just in case they are using an older version old gold cart (pre 2.9.5)
                    $sessionid = $result;
                    $dont_show_transaction_results = true;
                }
                break;
            case 'eway_hosted':
                $sessionid = decrypt_eway_uk_response();
                break;
                //default filter for other payment gateways to use
            //default filter for other payment gateways to use
            default:
                $sessionid = apply_filters('wpsc_previous_selected_gateway_' . $selected_gateway, $sessionid);
                break;
        }
    }
    if (!$dont_show_transaction_results) {
        if (!empty($sessionid)) {
            $cart_log_id = $wpdb->get_var($wpdb->prepare("SELECT `id` FROM `" . WPSC_TABLE_PURCHASE_LOGS . "` WHERE `sessionid`= %s LIMIT 1", $sessionid));
            echo transaction_results($sessionid, true);
        } else {
            printf(__('Sorry your transaction was not accepted.<br /><a href="%1$s">Click here to go back to checkout page</a>.', 'wp-e-commerce'), wpsc_get_checkout_url());
        }
    }
}
Example #3
0
if ($_SESSION['wpsc_previous_selected_gateway'] == 'paypal_certified') {
    $sessionid = $_SESSION['paypalexpresssessionid'];
}
//exit("test!");
$errorcode = '';
$transactid = '';
if ($_REQUEST['eway'] == '1') {
    $sessionid = $_GET['result'];
} elseif ($_REQUEST['eway'] == '0') {
    echo $_SESSION['eway_message'];
} elseif ($_REQUEST['payflow'] == '1') {
    echo $_SESSION['payflow_message'];
    $_SESSION['payflow_message'] = '';
}
//exit('getting here?<pre>'.print_r($_SESSION[[wpsc_previous_selected_gateway], true).'</pre>'.get_option('payment_gateway'));
if ($_SESSION['wpsc_previous_selected_gateway'] == 'paypal_certified' && $_SESSION['paypalExpressMessage'] != '') {
    echo $_SESSION['paypalExpressMessage'];
} else {
    if ($_SESSION['wpsc_previous_selected_gateway'] == 'dps') {
        $sessionid = decrypt_dps_response();
        //exit($sessionid);
        if ($sessionid != '') {
            //exit('<pre>'.print_r($sessionid, true).'</pre>');
            transaction_results($sessionid, true);
        } else {
            _e('Sorry your transaction was not accepted.<br /><a href=' . get_option("shopping_cart_url") . '>Click here to go back to checkout page.</a>');
        }
    } else {
        echo transaction_results($sessionid, true);
    }
}