Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.10.x will end 8 November 2021 (12 months).
  • Bug fixes for security issues in 3.10.x will end 9 May 2022 (18 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.
   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   * Privacy Subsystem implementation for paygw_paypal.
  19   *
  20   * @package    paygw_paypal
  21   * @category   privacy
  22   * @copyright  2020 Shamim Rezaie <shamim@moodle.com>
  23   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  24   */
  25  
  26  namespace paygw_paypal\privacy;
  27  
  28  use core_payment\privacy\paygw_provider;
  29  use core_privacy\local\request\writer;
  30  
  31  /**
  32   * Privacy Subsystem implementation for paygw_paypal.
  33   *
  34   * @copyright  2020 Shamim Rezaie <shamim@moodle.com>
  35   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  36   */
  37  class provider implements \core_privacy\local\metadata\null_provider, paygw_provider {
  38  
  39      /**
  40       * Get the language string identifier with the component's language
  41       * file to explain why this plugin stores no data.
  42       *
  43       * @return  string
  44       */
  45      public static function get_reason() : string {
  46          return 'privacy:metadata';
  47      }
  48  
  49      /**
  50       * Export all user data for the specified payment record, and the given context.
  51       *
  52       * @param \context $context Context
  53       * @param array $subcontext The location within the current context that the payment data belongs
  54       * @param \stdClass $payment The payment record
  55       */
  56      public static function export_payment_data(\context $context, array $subcontext, \stdClass $payment) {
  57          global $DB;
  58  
  59          $subcontext[] = get_string('gatewayname', 'paygw_paypal');
  60          $record = $DB->get_record('paygw_paypal', ['paymentid' => $payment->id]);
  61  
  62          $data = (object) [
  63              'orderid' => $record->pp_orderid,
  64          ];
  65          writer::with_context($context)->export_data(
  66              $subcontext,
  67              $data
  68          );
  69      }
  70  
  71      /**
  72       * Delete all user data related to the given payments.
  73       *
  74       * @param string $paymentsql SQL query that selects payment.id field for the payments
  75       * @param array $paymentparams Array of parameters for $paymentsql
  76       */
  77      public static function delete_data_for_payment_sql(string $paymentsql, array $paymentparams) {
  78          global $DB;
  79  
  80          $DB->delete_records_select('paygw_paypal', "paymentid IN ({$paymentsql})", $paymentparams);
  81      }
  82  }