Plugin Directory

Changeset 2917055


Ignore:
Timestamp:
05/25/2023 04:02:31 AM (3 years ago)
Author:
9pay
Message:

Refactor code

Location:
9pay-gateway/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • 9pay-gateway/trunk/includes/gateways/ninepay-gateway.php

    r2903756 r2917055  
    287287        if($order->get_payment_method() != $this->id) return;
    288288
     289        $result = sanitize_text_field($_GET['result']);
     290        $request_checksum = sanitize_text_field($_GET['checksum']);
    289291        /*Check isset params*/
    290         if(empty($_GET['result']) || empty($_GET['checksum'])) {
     292        if(empty($result) || empty($request_checksum)) {
    291293            $mess = $this->genMess(null, $configFile, $lang);
    292294            $this->paymentFail($lang, $mess);
     
    295297
    296298        $secretKeyCheckSum = $this->get_option('checksum_secret_key');
    297         if (is_null($_GET['result'])) {
    298             return;
    299         }
    300         $result = sanitize_text_field($_GET['result']);
     299        if (is_null($result)) {
     300            return;
     301        }
    301302
    302303        $hashChecksum = strtoupper(hash('sha256', $result . $secretKeyCheckSum));
    303304
    304         if ($hashChecksum !== $_GET['checksum']) {
     305        if ($hashChecksum !== $request_checksum) {
    305306            return;
    306307        }
  • 9pay-gateway/trunk/includes/gateways/ninepay.php

    r2903653 r2917055  
    2323    public function show_notify(){
    2424        $screen = get_current_screen();
    25         $valid = $screen->id == 'woocommerce_page_wc-settings' && isset($_GET['section']) && $_GET['section'] ==$this->id;
     25        $section = sanitize_text_field($_GET['section']);
     26        $valid = $screen->id == 'woocommerce_page_wc-settings' && !empty($section) && $section ==$this->id;
    2627        if(!$valid) return;
    2728        ?>
     
    6566    function process_payment( $order_id ) {
    6667        $order = new WC_Order( $order_id );
    67         if (is_null($_POST['ninepay_payment_method'])) {
     68        $ninePayPaymentMethod = sanitize_text_field($_POST['ninepay_payment_method']);
     69        if (is_null($ninePayPaymentMethod)) {
    6870            return;
    6971        }
    70         $ninePayPaymentMethod = sanitize_text_field($_POST['ninepay_payment_method']);
    7172        $paymentMethod = $ninePayPaymentMethod;
    7273        $configFile = include('core/config.php');
  • 9pay-gateway/trunk/mc-quetma.php

    r2903756 r2917055  
    105105add_action('rest_api_init', function(){
    106106
    107     if (!is_string($_REQUEST['result'])) {
     107    $result = sanitize_text_field($_REQUEST['result']);
     108   
     109    if (!is_string($result)) {
    108110        return;
    109111    }
    110     $result = ($_REQUEST['result']);
    111 
    112     if (!is_string($_REQUEST['checksum'])) {
     112
     113    $checksum = sanitize_text_field($_REQUEST['checksum']);
     114    if (!is_string($checksum)) {
    113115        return;
    114116    }
    115     $checksum = ($_REQUEST['checksum']);
    116117
    117118    register_rest_route('nine-pay/v1', '/result-ipn', array(
     
    269270
    270271        $excRateUrl = $host . '?' . http_build_query($httpData);
    271         $ch = curl_init();
    272         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    273         curl_setopt($ch, CURLOPT_URL, $excRateUrl);
    274         $result=curl_exec($ch);
    275         curl_close($ch);
     272
     273        $result = wp_remote_retrieve_body(wp_remote_get($execRateUrl));
    276274
    277275        $allCurrencies = json_decode($result, true);
     
    689687            $lang = $config['ninepay_lang'];
    690688
    691             if (is_null($_POST['post_data'])) {
     689            $postData = sanitize_text_field($_POST['post_data']);
     690            if (is_null($postData)) {
    692691                return;
    693692            }
    694             $postData = ($_POST['post_data']);
    695693
    696694            parse_str($postData, $result);
Note: See TracChangeset for help on using the changeset viewer.