Differences Between: [Versions 310 and 402] [Versions 311 and 402] [Versions 39 and 402] [Versions 400 and 402] [Versions 401 and 402]
1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 /** 18 * PayPal enrolment plugin utility class. 19 * 20 * @package enrol_paypal 21 * @copyright 2016 Cameron Ball <cameron@cameron1729.xyz> 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 25 namespace enrol_paypal; 26 27 defined('MOODLE_INTERNAL') || die(); 28 29 /** 30 * PayPal enrolment plugin utility class. 31 * 32 * @package enrol_paypal 33 * @copyright 2016 Cameron Ball <cameron@cameron1729.xyz> 34 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 35 */ 36 final class util { 37 38 /** 39 * Alerts site admin of potential problems. 40 * 41 * @param string $subject email subject 42 * @param \stdClass $data PayPal IPN data 43 */ 44 public static function message_paypal_error_to_admin($subject, $data) { 45 $admin = get_admin(); 46 $site = get_site(); 47 48 $message = "$site->fullname: Transaction failed.\n\n$subject\n\n"; 49 50 foreach ($data as $key => $value) { 51 $message .= "$key => $value\n"; 52 } 53 54 $eventdata = new \core\message\message(); 55 $eventdata->courseid = empty($data->courseid) ? SITEID : $data->courseid; 56 $eventdata->modulename = 'moodle'; 57 $eventdata->component = 'enrol_paypal'; 58 $eventdata->name = 'paypal_enrolment'; 59 $eventdata->userfrom = $admin; 60 $eventdata->userto = $admin; 61 $eventdata->subject = "PAYPAL ERROR: ".$subject; 62 $eventdata->fullmessage = $message; 63 $eventdata->fullmessageformat = FORMAT_PLAIN; 64 $eventdata->fullmessagehtml = ''; 65 $eventdata->smallmessage = ''; 66 message_send($eventdata); 67 } 68 69 /** 70 * Silent exception handler. 71 * 72 * @return callable exception handler 73 */ 74 public static function get_exception_handler() { 75 return function($ex) { 76 $info = get_exception_info($ex); 77 78 $logerrmsg = "enrol_paypal IPN exception handler: ".$info->message; 79 if (debugging('', DEBUG_NORMAL)) { 80 $logerrmsg .= ' Debug: '.$info->debuginfo."\n".format_backtrace($info->backtrace, true); 81 } 82 error_log($logerrmsg); 83 84 if (http_response_code() == 200) { 85 http_response_code(500); 86 } 87 88 exit(0); 89 }; 90 } 91 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body