function process() { global $lr_session; $payments = array(); $paypal = new PaypalHandler(); $talkback_results = $paypal->talkback('pdt'); if (!$talkback_results || $talkback_results['status'] == false) { return false; } // confirm that data from PayPal matches registrations $item_numbers = preg_grep_keys('/item_number[0-9]*/', $talkback_results['message']); foreach ($item_numbers as $key => $value) { // get current Item # from PayPal, which is the last character in $key $item = substr($key, -1); $status = $paypal->validatePayment($value, $talkback_results['message']['mc_gross_' . $item], $lr_session->user->user_id); if ($status['status'] == false) { error_exit($status['message']); } else { // PaymentRegistration object passed back in message on success array_push($payments, $status['message']); } } // output confirmation view $this->smarty->assign('payments', $payments); $this->smarty->assign('order_id_format', variable_get('order_id_format', '%d')); $this->title = 'Registration ' . $this->registration->formatted_order_id() . '- Payment Received'; $this->template_name = 'pages/registration/paypal.tpl'; return true; }
$log = new KLogger($_SERVER['DOCUMENT_ROOT'] . $CONFIG['paths']['base_url'] . '/logs', variable_get('log_threshold', Klogger::DEBUG)); } } /* * PayPal IPN transactions are purely B2B, so most of the leaguerunner codebase isn't needed. * The main functions are: * - Update registration payments * - ensure registrations/payments are matched up for players */ // Check Request for IPN if ($_GET['q'] == 'ipn') { require_once "Handler/PaypalHandler.php"; // PayPal has its own logger $paypal_log = new KLogger($_SERVER['DOCUMENT_ROOT'] . '/' . $CONFIG['paths']['base_url'] . '/logs/paypal', Klogger::DEBUG); $paypal_log->logInfo('Received IPN Request'); $handler = new PaypalHandler(); $status = $handler->process(); // success could have multiple payments to log if ($status['status'] == true) { foreach ($status['message'] as $payment) { $paypal_log->logInfo('Registration #' . $payment->order_id . ' - ' . $payment->payment_amount . ' paid in full'); } } else { $paypal_log->logError($status['message']); $paypal_log->logDebug(print_r(debug_backtrace(), true)); } // no more IPN processing required exit; } // Set some template defaults global $smarty;