wpsc_payment_failed

Located in: merchant.class.php, payment-gateway.class.php

Functions that call this hook: go_to_transaction_results()
Arguments Accepted: none
Version Introduced: 3.8

Description: This hook is triggered if the customer has had their payment declined and returned from the gateway.

You would use this hook to preform extra tasks relating to declined payments that WP-e-Commerce doesn’t handle for you.

Similar Hooks: wpsc_payment_incomplete – triggered on incomplete transactions, wpsc_payment_successful – triggered on successful transactions

Code in context:
[php firstline=”272″ highlight=”287″]
/**
* go_to_transaction_results, please don’t extend this without very good reason
* go to transaction results, if this changes and you extend this, your merchant module may go to the wrong place
*/
function go_to_transaction_results( $session_id ) {
global $wpdb, $purchase_log;

//Now to do actions once the payment has been attempted
switch ($purchase_log[‘processed’]) {
case 3:
// payment worked
do_action(‘wpsc_payment_successful’);
break;
case 1:
// payment declined
do_action(‘wpsc_payment_failed’);
break;
case 2:
// something happened with the payment
do_action(‘wpsc_payment_incomplete’);
break;
}

$transaction_url_with_sessionid = add_query_arg( ‘sessionid’, $session_id, get_option( ‘transact_url’ ) );
wp_redirect( $transaction_url_with_sessionid );

exit(); // follow the redirect with an exit, just to be sure.
}

[/php]