wpsc_payment_incomplete

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 something has gone wrong with the payment processing and the sales log status has been updated to 2 (incomplete payment), the hook is triggered after the customer returns from the gateway.

Note: There are quite a few cases that will set purchase log status to 2(order received) these include but are not limited to:

  • A problem connecting to the gateway
  • A customer has filled out the checkout form, been taken to an external gateway for payment (eg PayPal) but then decide to cancel purchase.
  • A problem with the gateway processing payment

Because the payment incomplete hook can be triggered by many different reasons be careful when performing tasks through this hook

Similar Hooks: wpsc_payment_failed – triggered on failed transactions, wpsc_payment_successful – triggered on successful transactions

Code in context:
[php firstline=”272″ highlight=”291″]
/**
* 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]