コード例 #1
0
ファイル: paypal.php プロジェクト: h07r0d/leaguerunner
 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;
 }