wpsc_pre_submit_gateway

Located in: ajax.functions.php

Functions that call this hook: wpsc_submit_checkout()
Arguments Accepted: array( &$merchant_instance )
Version Introduced: 3.8

Description: This hook is triggered just before the data is submitted to the gateway for processing.

Code in context:
[php firstline=”649″ highlight=”656″]
$purchase_log_id = $wpdb->insert_id;
$wpsc_checkout->save_forms_to_db( $purchase_log_id );
$wpsc_cart->save_to_db( $purchase_log_id );
$wpsc_cart->submit_stock_claims( $purchase_log_id );
if( !isset( $our_user_id ) && isset( $user_ID ))
$our_user_id = $user_ID;
$wpsc_cart->log_id = $purchase_log_id;
do_action( ‘wpsc_submit_checkout’, array( "purchase_log_id" => $purchase_log_id, "our_user_id" => $our_user_id ) );
if ( get_option( ‘permalink_structure’ ) != ” )
$separator = "?";
else
$separator = "&";

// submit to gateway
if ( wpsc_is_payment_gateway_registered( $submitted_gateway ) ) {
$gateway = wpsc_get_payment_gateway( $submitted_gateway );
$gateway->set_purchase_log( new WPSC_Purchase_Log( $purchase_log_id ) );
$gateway->process();
} else {
$current_gateway_data = &$wpsc_gateways[$submitted_gateway];

if ( isset( $current_gateway_data[‘api_version’] ) && $current_gateway_data[‘api_version’] >= 2.0 ) {
$merchant_instance = new $current_gateway_data[‘class_name’]( $purchase_log_id );
$merchant_instance->construct_value_array();
do_action_ref_array( ‘wpsc_pre_submit_gateway’, array( &$merchant_instance ) );
$merchant_instance->submit();
} elseif ( ($current_gateway_data[‘internalname’] == $submitted_gateway) && ($current_gateway_data[‘internalname’] != ‘google’) ) {
$gateway_used = $current_gateway_data[‘internalname’];
$wpdb->update( WPSC_TABLE_PURCHASE_LOGS, array(
‘gateway’ => $gateway_used
), array( ‘id’ => $purchase_log_id ) );
$current_gateway_data[‘function’]( $separator, $sessionid );
} elseif ( ($current_gateway_data[‘internalname’] == ‘google’) && ($current_gateway_data[‘internalname’] == $submitted_gateway) ) {
$gateway_used = $current_gateway_data[‘internalname’];
$wpdb->update( WPSC_TABLE_PURCHASE_LOGS, array(
‘gateway’ => $gateway_used
), array( ‘id’ => $purchase_log_id ) );
$_SESSION[‘gateway’] = ‘google’;
wp_redirect(get_option( ‘shopping_cart_url’ ));
}
}
}
}

[/php]