ec_step1(); } else { // This will push on the second step of the paypalwpp payment // module, as we already have a PayPal express checkout token // at this point. $$paypalwpp_module->ec_step2(); } } ?> Processing... process(); if (valid_payment($order->info['total'], $_SESSION['currency']) === false) { die(); } if ($ipnFoundSession === false) { ipn_debug_email('IPN NOTICE :: Unique but no session - Assumed to be a personal payment, rather than an IPN transaction. Ignoring.'); die(); } $insert_id = $order->create($order_totals); if ($extraDebug) ipn_debug_email('Breakpoint: 5a - built order -- OID:' . $insert_id); $sql_data_array = ipn_create_order_array($insert_id, $txn_type); if ($extraDebug) ipn_debug_email('Breakpoint: 5b - PP table OID:' . print_r($sql_data_array, true)); zen_db_perform(TABLE_PAYPAL, $sql_data_array); if ($extraDebug) ipn_debug_email('Breakpoint: 5c - PP table OID saved'); $pp_hist_id = $db->Insert_ID(); if ($extraDebug) ipn_debug_email('Breakpoint: 5d - PP hist ID:' . $pp_hist_id); $sql_data_array = ipn_create_order_history_array($pp_hist_id); if ($extraDebug) ipn_debug_email('Breakpoint: 5e - PP hist_data:' . print_r($sql_data_array, true)); zen_db_perform(TABLE_PAYPAL_PAYMENT_STATUS_HISTORY, $sql_data_array); if ($extraDebug) ipn_debug_email('Breakpoint: 5f - PP hist saved'); $new_status = MODULE_PAYMENT_PAYPAL_ORDER_STATUS_ID; if ($extraDebug) ipn_debug_email('Breakpoint: 5g - new status code' . $new_status); if ($_POST['payment_status'] =='Pending') { $new_status = MODULE_PAYMENT_PAYPAL_PROCESSING_STATUS_ID; if ($extraDebug) ipn_debug_email('Breakpoint: 5h - newer status code' . $new_status); $sql = "UPDATE " . TABLE_ORDERS . " SET orders_status = " . MODULE_PAYMENT_PAYPAL_PROCESSING_STATUS_ID . " WHERE orders_id = '" . $insert_id . "'"; $db->Execute($sql); if ($extraDebug) ipn_debug_email('Breakpoint: 5i - order table updated'); } $sql_data_array = array('orders_id' => $insert_id, 'orders_status_id' => $new_status, 'date_added' => 'now()', 'comments' => 'PayPal status: ' . $_POST['payment_status'] . ' ' . $_POST['pending_reason']. ' @ '.$_POST['payment_date'] . (($_POST['parent_txn_id'] !='') ? "\n" . ' Parent Trans ID:' . $_POST['parent_txn_id'] : '') . "\n" . ' Trans ID:' . $_POST['txn_id'] . "\n" . ' Amount: ' . $_POST['mc_gross'] . ' ' . $_POST['mc_currency'], 'customer_notified' => false ); if ($extraDebug) ipn_debug_email('Breakpoint: 5j - order stat hist update:' . print_r($sql_data_array, true)); zen_db_perform(TABLE_ORDERS_STATUS_HISTORY, $sql_data_array); if ($extraDebug) ipn_debug_email('Breakpoint: 5k - OSH update done'); $order->create_add_products($insert_id, 2); if ($extraDebug) ipn_debug_email('Breakpoint: 5L - adding products'); $order->send_order_email($insert_id, 2); if ($extraDebug) ipn_debug_email('Breakpoint: 5m - emailing customer'); $_SESSION['cart']->reset(true); if ($extraDebug) ipn_debug_email('Breakpoint: 5n - emptying cart'); $ordersID = $insert_id; $paypalipnID = $pp_hist_id; ipn_debug_email('Breakpoint: 6 - Completed IPN order add.' . ' ordersID = '. $ordersID . ' IPN_id =' . $paypalipnID); if (!($new_record_needed && $txn_type == 'echeck-cleared')) break; case 'parent': case 'cleared-address': case 'cleared-multicurrency': case 'cleared-echeck': case 'cleared-authorization': case 'cleared-verify': case 'cleared-intl': case 'echeck-denied': case 'echeck-cleared': case 'denied-address': case 'denied-multicurrency': case 'denied-echeck': case 'failed-echeck': case 'denied-intl': case 'denied': case 'voided': case 'express-checkout-cleared': if ($txn_type == 'parent') { $sql_data_array = ipn_create_order_array($ordersID, $txn_type); zen_db_perform(TABLE_PAYPAL, $sql_data_array); } else { $sql_data_array = ipn_create_order_update_array($txn_type); zen_db_perform(TABLE_PAYPAL, $sql_data_array, 'update', "txn_id='" . $_POST['txn_id'] . "'"); } $sql_data_array = ipn_create_order_history_array($paypalipnID); zen_db_perform(TABLE_PAYPAL_PAYMENT_STATUS_HISTORY, $sql_data_array); ipn_debug_email('IPN NOTICE :: Updating PP table record status for order #' . $ordersID . ' txn_id: ' . $_POST['txn_id'] . ' PP IPN ID: ' . $paypalipnID); switch ($txn_type) { case 'voided': case ($_POST['payment_status'] == 'Refunded' || $_POST['payment_status'] == 'Reversed' || $_POST['payment_status'] == 'Voided'): //payment_status=Refunded or payment_status=Voided $new_status = MODULE_PAYMENT_PAYPALWPP_REFUNDED_STATUS_ID; if (defined('MODULE_PAYMENT_PAYPAL_REFUND_ORDER_STATUS_ID') && (int)MODULE_PAYMENT_PAYPAL_REFUND_ORDER_STATUS_ID > 0 && !$isECtransaction) $new_status = MODULE_PAYMENT_PAYPAL_REFUND_ORDER_STATUS_ID; break; case 'echeck-denied': case 'denied-echeck': case 'failed-echeck': //payment_status=Denied or failed $new_status = ($isECtransaction ? MODULE_PAYMENT_PAYPALWPP_REFUNDED_STATUS_ID : MODULE_PAYMENT_PAYPAL_REFUND_ORDER_STATUS_ID); break; case 'echeck-cleared': //echeck-cleared $new_status = MODULE_PAYMENT_PAYPAL_ORDER_STATUS_ID; break; case ($txn_type=='express-checkout-cleared' || substr($txn_type,0,8) == 'cleared-'): //express-checkout-cleared $new_status = ($isECtransaction && defined('MODULE_PAYMENT_PAYPALWPP_ORDER_STATUS_ID') ? MODULE_PAYMENT_PAYPALWPP_ORDER_STATUS_ID : MODULE_PAYMENT_PAYPAL_ORDER_STATUS_ID); if ((int)$new_status == 0) $new_status = 2; break; case 'pending-auth': // pending authorization $new_status = ($isECtransaction ? MODULE_PAYMENT_PAYPALWPP_REFUNDED_STATUS_ID : MODULE_PAYMENT_PAYPAL_REFUND_ORDER_STATUS_ID); break; case (substr($txn_type,0,7) == 'denied-'): // denied for any other reason - treat as pending for now case (substr($txn_type,0,8) == 'pending-'): // pending anything $new_status = ($isECtransaction ? MODULE_PAYMENT_PAYPALWPP_ORDER_PENDING_STATUS_ID : MODULE_PAYMENT_PAYPAL_PROCESSING_STATUS_ID); break; } // update order status history with new information ipn_debug_email('IPN NOTICE :: Set new status ' . $new_status . " for order ID = " . $ordersID . ($_POST['pending_reason'] != '' ? '. Reason_code = ' . $_POST['pending_reason'] : '') ); if ((int)$new_status == 0) $new_status = 1; if (in_array($_POST['payment_status'], array('Refunded', 'Reversed', 'Denied', 'Failed')) || substr($txn_type,0,8) == 'cleared-' || $txn_type=='echeck-cleared' || $txn_type == 'express-checkout-cleared') { ipn_update_orders_status_and_history($ordersID, $new_status, $txn_type); } break; case ($txn_type == 'pending-echeck' && (int)$ordersID > 0): ipn_debug_email('IPN NOTICE :: Pending echeck transaction for existing order. No action required. Waiting for echeck to clear.'); break; case ($txn_type == 'pending-multicurrency' && (int)$ordersID > 0): ipn_debug_email('IPN NOTICE :: Pending multicurrency transaction for existing order. No action required. Waiting for merchant to "accept" the order via PayPal account console.'); break; case ($txn_type == 'pending-address' && (int)$ordersID > 0): ipn_debug_email('IPN NOTICE :: "Pending address" transaction for existing order. No action required. Waiting for address approval by store owner via PayPal account console.'); break; default: // can't understand result found. Thus, logging and aborting. ipn_debug_email('IPN WARNING :: Could not process for txn type: ' . $txn_type . "\n" . ' postdata=' . str_replace('&', " \n&", urldecode($postdata))); } } ?>