/** * Handle IPN. */ private function handleIPN() { if (!PayPal_Helper::validate_notification()) { trigger_error('PayPal: Invalid notification received. ' . json_encode($_POST), E_USER_WARNING); return; } // get objects $transaction_manager = ShopTransactionsManager::getInstance(); // get data $handled = false; $type = escape_chars($_POST['txn_type']); $amount = escape_chars($_POST['amount']); // handle different notification types switch ($type) { case 'recurring_payment': case 'recurring_payment_expired': case 'recurring_payment_failed': case 'recurring_payment_profile_created': case 'recurring_payment_profile_cancel': case 'recurring_payment_skipped': case 'recurring_payment_suspended': case 'recurring_payment_suspended_due_to_max_failed_payment': $profile_id = escape_chars($_REQUEST['recurring_payment_id']); $transaction = $transaction_manager->getSingleItem($transaction_manager->getFieldNames(), array('token' => $profile_id)); if (is_object($transaction)) { $handled = $this->handleRecurringIPN($transaction, $type, $amount); } else { trigger_error("PayPal: Unable to handle IPN, unknown transaction {$profile_id}.", E_USER_WARNING); } break; } // record unhandled notifications if (!$handled) { trigger_error("PayPal: Unhandled notification '{$type}'.", E_USER_NOTICE); } }