function espresso_process_firstdata_connect_2($payment_data)
{
    global $wpdb;
    $payment_data['txn_type'] = 'Firstdata Connect 2.0';
    $payment_data['txn_details'] = serialize($_REQUEST);
    $payment_data['payment_status'] = 'Incomplete';
    $payment_data['txn_id'] = $_REQUEST['oid'];
    if ($_REQUEST['status'] == 'APPROVED') {
        $payment_data['payment_status'] = 'Completed';
        $firstdata_connect_2_settings = get_option('event_espresso_firstdata_connect_2_settings');
        include "Fdggutil.php";
        $fdggutil = new Fdggutil($firstdata_connect_2_settings['storename'], $firstdata_connect_2_settings['sharedSecret']);
        $hash = $fdggutil->check_return_hash($payment_data['payment_date']);
    } else {
        ?>
			<h2 style="color:#F00;"><?php 
        _e('There was an error processing your transaction!', 'event_espresso');
        ?>
</h2>
			<p><strong>Error:</strong> (<?php 
        echo $_REQUEST['status'];
        ?>
 - <?php 
        echo $_REQUEST['fail_reason'];
        ?>
)</p>
			<?php 
    }
    add_action('action_hook_espresso_email_after_payment', 'espresso_email_after_payment');
    return $payment_data;
}
function espresso_display_firstdata_connect_2($payment_data)
{
    global $org_options;
    $firstdata_connect_2_settings = get_option('event_espresso_firstdata_connect_2_settings');
    $payment_data = apply_filters('filter_hook_espresso_prepare_payment_data_for_gateways', $payment_data);
    $payment_data = apply_filters('filter_hook_espresso_get_total_cost', $payment_data);
    require_once 'Fdggutil.php';
    $fdggutil = new Fdggutil($firstdata_connect_2_settings['storename'], $firstdata_connect_2_settings['sharedSecret']);
    $fdggutil->set_timezone($firstdata_connect_2_settings['timezone']);
    $fdggutil->set_chargetotal($payment_data['total_cost']);
    $fdggutil->set_sandbox($firstdata_connect_2_settings['sandbox']);
    $fdggutil->set_returnUrl($org_options['notify_url']);
    $fdggutil->set_cancelUrl($org_options['notify_url']);
    $fdggutil->set_attendee_id($payment_data['attendee_id']);
    $fdggutil->set_dateTime();
    $button_url = $firstdata_connect_2_settings['button_url'];
    if (!empty($firstdata_connect_2_settings['bypass_payment_page']) && $firstdata_connect_2_settings['bypass_payment_page'] == 'Y') {
        echo $fdggutil->submitPayment();
    } else {
        echo $fdggutil->submitButton($button_url);
    }
}