Plugin Directory

Changeset 3321888


Ignore:
Timestamp:
07/03/2025 03:45:46 PM (6 months ago)
Author:
payuplugin
Message:

fixed shipping cost api vulnerability and added hash validation

Location:
payu-india/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • payu-india/trunk/includes/class-payu-payment-validation.php

    r3309781 r3321888  
    8383        }
    8484    }
    85 
    8685
    8786    private function getRedirectUrl($order)
  • payu-india/trunk/includes/class-payu-shipping-tax-api-calculation.php

    r3313923 r3321888  
    1515
    1616        add_action('rest_api_init', array(&$this, 'getPaymentFailedUpdate'));
    17         add_action('rest_api_init', array($this, 'payu_generate_get_user_token'));
     17        // add_action('rest_api_init', array($this, 'payu_generate_get_user_token'));
    1818    }
    1919
     
    3030    public function payuShippingCostCallback(WP_REST_Request $request)
    3131    {
    32         $parameters = json_decode($request->get_body(), true);
    33         error_log('shipping api call request ' . $request->get_body());
    34 
    35         $email = sanitize_email($parameters['email']);
    36         $txnid = sanitize_text_field($parameters['txnid']);
    37 
    38         $auth = apache_request_headers();
    39         $token = $auth['Auth-Token'];
     32
     33        // Get the raw JSON request body
     34        $raw_json_body = $request->get_body();
     35        error_log('Raw Json Body: ' . $raw_json_body);
     36
     37        // Decode body
     38        $parameters = json_decode($raw_json_body, true);
     39
     40        // error_log('json Decode Body ' . $parameters);
     41        // Basic validation
     42        if (!is_array($parameters)) {
     43            return new WP_REST_Response([
     44                'status' => false,
     45                'message' => 'Invalid JSON body.',
     46            ], 400);
     47        }
     48
     49        // Sanitize inputs
     50        $email = sanitize_email($parameters['email'] ?? '');
     51        $txnid = sanitize_text_field($parameters['txnid'] ?? '');
     52
     53        // Get headers
     54        $headers = apache_request_headers();
     55        $token = $headers['Auth-Token'] ?? '';
     56
     57        error_log('First token : ' . $token);
    4058
    4159        try {
    42             if ($token && $this->payu_validate_authentication_token(PAYU_USER_TOKEN_EMAIL, $token)) {
     60            if ($token && $this->payu_validate_authentication_token($raw_json_body, $token)) {
    4361                $response = $this->handleValidToken($parameters, $email, $txnid);
    4462            } else {
     
    7795        $session_key = $parameters['udf4'];
    7896        $order_string = explode('_', $txnid);
    79         $order_id = (int)$order_string[0];
     97        $order_id = (int) $order_string[0];
    8098        $order = wc_get_order($order_id);
     99        // error_log(var_dump($order , true ));
    81100
    82101        $shipping_address = $parameters['address'];
     
    127146    public function update_order_shipping_address($order, $new_address, $email)
    128147    {
    129         // Implement your logic to update the shipping address
    130         // You might use the wc_update_order function or any other method
    131 
    132         // Example using wc_update_order:
    133         $order->set_shipping_address($new_address);
     148        // Print new_address before anything else
     149        error_log('Received new_address: ' . json_encode($new_address));
     150
     151        // Validate order object
     152        if (!$order || !is_a($order, 'WC_Order')) {
     153            error_log('Invalid order object');
     154            return false;
     155        }
     156
     157        // Update addresses properly
    134158        $order->set_address($new_address, 'shipping');
    135159        $order->set_address($new_address, 'billing');
    136         error_log('set order address ' . json_encode($new_address));
    137160        $order->set_billing_email($email);
     161
     162        error_log('Updated order address: ' . json_encode($new_address));
     163
    138164        return $order;
    139165    }
     
    184210            WC()->customer->set_shipping_address_1($order->get_shipping_address_1());
    185211            WC()->cart = new WC_Cart();
    186    
     212
    187213            // Authenticate user
    188214            if (is_user_logged_in()) {
     
    190216                $user_id = $current_user->ID;
    191217                wp_set_current_user($user_id);
    192                 // wp_set_auth_cookie($user_id);
    193218            } elseif (!empty($user_id)) {
    194219                // Set session for already created/registered user
    195220                wp_set_current_user($user_id);
    196                 // wp_set_auth_cookie($user_id);
    197221            }
    198222
     
    209233                        WC()->cart->calculate_totals();
    210234                        foreach (WC()->cart->get_tax_totals() as $tax) {
    211                             $tax_amount   = $tax->amount + $tax_amount;
     235                            $tax_amount = $tax->amount + $tax_amount;
    212236                        }
    213237
    214                         $shipping_data[$shipping_method_count]['carrier_code']   = $shipping_rate->id;
    215                         $shipping_data[$shipping_method_count]['method_code']   = $shipping_rate->get_method_id();
    216                         $shipping_data[$shipping_method_count]['carrier_title']  = $shipping_rate->get_label();
    217                         $shipping_data[$shipping_method_count]['amount']        = $shipping_rate->get_cost();
    218                         $shipping_data[$shipping_method_count]['error_message']        = "";
     238                        $shipping_data[$shipping_method_count]['carrier_code'] = $shipping_rate->id;
     239                        $shipping_data[$shipping_method_count]['method_code'] = $shipping_rate->get_method_id();
     240                        $shipping_data[$shipping_method_count]['carrier_title'] = $shipping_rate->get_label();
     241                        $shipping_data[$shipping_method_count]['amount'] = $shipping_rate->get_cost();
     242                        $shipping_data[$shipping_method_count]['error_message'] = "";
    219243                        $plugin_data = get_option('woocommerce_payubiz_settings');
    220244                        $payu_dynamic_charges_flag = $plugin_data['dynamic_charges_flag'];
     
    222246                        if ($payu_dynamic_charges_flag == "yes" && wc_prices_include_tax()) {
    223247                            if (WC()->cart->get_shipping_tax()) {
    224                                 $shipping_data[$shipping_method_count]['tax_price']    = round(WC()->cart->get_shipping_tax(), 2);
     248                                $shipping_data[$shipping_method_count]['tax_price'] = round(WC()->cart->get_shipping_tax(), 2);
    225249                                $shipping_data[$shipping_method_count]['tax_price_inclusive'] = round($tax_amount, 2);
    226250                            } else {
    227                                 $shipping_data[$shipping_method_count]['tax_price']    = 0;
     251                                $shipping_data[$shipping_method_count]['tax_price'] = 0;
    228252                                $shipping_data[$shipping_method_count]['tax_price_inclusive'] = round($tax_amount, 2);
    229253                            }
    230254                        } else {
    231                             $shipping_data[$shipping_method_count]['tax_price']    = round($tax_amount, 2);
     255                            $shipping_data[$shipping_method_count]['tax_price'] = round($tax_amount, 2);
    232256                        }
    233257
    234                         $shipping_data[$shipping_method_count]['subtotal']   = WC()->cart->get_subtotal();
    235                         $shipping_data[$shipping_method_count]['grand_total']   = round(WC()->cart->get_subtotal() + $shipping_rate->get_cost() + $tax_amount, 2);
     258                        $shipping_data[$shipping_method_count]['subtotal'] = WC()->cart->get_subtotal();
     259                        $shipping_data[$shipping_method_count]['grand_total'] = round(WC()->cart->get_subtotal() + $shipping_rate->get_cost() + $tax_amount, 2);
    236260                        $shipping_method_count++;
    237261                    }
    238262                } else if (WC()->cart->get_tax_totals()) {
    239263                    foreach (WC()->cart->get_tax_totals() as $tax) {
    240                         $tax_amount   = $tax->amount + $tax_amount;
     264                        $tax_amount = $tax->amount + $tax_amount;
    241265                    }
    242                     $shipping_data[0]['carrier_code']   = '';
    243                     $shipping_data[0]['method_code']   = '';
    244                     $shipping_data[0]['carrier_title']  = '';
    245                     $shipping_data[0]['amount']        = '';
    246                     $shipping_data[0]['error_message']        = "";
    247                     $shipping_data[0]['tax_price']    = $tax_amount;
    248                     $shipping_data[0]['subtotal']   = WC()->cart->get_subtotal();
    249                     $shipping_data[0]['grand_total']   = WC()->cart->get_subtotal() + $tax_amount;
     266                    $shipping_data[0]['carrier_code'] = '';
     267                    $shipping_data[0]['method_code'] = '';
     268                    $shipping_data[0]['carrier_title'] = '';
     269                    $shipping_data[0]['amount'] = '';
     270                    $shipping_data[0]['error_message'] = "";
     271                    $shipping_data[0]['tax_price'] = $tax_amount;
     272                    $shipping_data[0]['subtotal'] = WC()->cart->get_subtotal();
     273                    $shipping_data[0]['grand_total'] = WC()->cart->get_subtotal() + $tax_amount;
    250274                }
    251275            }
     
    281305        update_user_meta($user_id, '_woocommerce_persistent_cart_1', $cart_data);
    282306    }
    283 
    284 
    285     public function payu_generate_get_user_token()
    286     {
    287         register_rest_route('payu/v1', '/generate-user-token', array(
    288             'methods' => ['POST'],
    289             'callback' => array($this, 'payu_generate_user_token_callback'),
    290             'permission_callback' => '__return_true'
    291         ));
    292         // register_rest_route('payu/v1', '/generate-user-token', array(
    293         //     'methods' => ['POST'],
    294         //     'callback' => array($this, 'payu_generate_user_token_callback'),
    295         //     'permission_callback' => function () {
    296         //         return is_user_logged_in();
    297         //     }
    298         // ));
    299     }
    300 
    301     public function payu_generate_user_token_callback(WP_REST_Request $request)
    302     {
    303         // Get and sanitize the email from request
    304         $email = sanitize_email($request->get_param('email'));
    305 
    306         if (!$email || !is_email($email)) {
    307             return new WP_REST_Response([
    308                 'status' => false,
    309                 'data' => [],
    310                 'message' => 'Invalid email address provided.',
    311             ], 400); // 400 Bad Request
    312         }
    313 
    314         // Fetch plugin settings
    315         $plugin_data = get_option('woocommerce_payubiz_settings');
    316         $this->payu_salt = isset($plugin_data['currency1_payu_salt']) ? sanitize_text_field($plugin_data['currency1_payu_salt']) : null;
    317 
    318         if (!$this->payu_salt) {
    319             return new WP_REST_Response([
    320                 'status' => false,
    321                 'data' => [],
    322                 'message' => 'Plugin configuration is missing.',
    323             ], 500); // 500 Internal Server Error
    324         }
    325 
    326         // Check if the user exists
    327         if (email_exists($email)) {
    328             $user = get_user_by('email', $email);
    329             $user_id = $user->ID;
    330 
    331             // Generate authentication token
    332             $token = $this->payu_generate_authentication_token($user_id);
    333 
    334             return new WP_REST_Response([
    335                 'status' => true,
    336                 'data' => ['token' => $token],
    337                 'message' => 'Token Generated',
    338             ]);
    339         } else {
    340             return new WP_REST_Response([
    341                 'status' => false,
    342                 'data' => [],
    343                 'message' => "Account does not exist for this email: $email",
    344             ], 404); // 404 Not Found
    345         }
    346     }
    347 
    348 
    349     private function payu_generate_authentication_token($user_id)
    350     {
    351 
    352         $expiration = get_user_meta($user_id, 'payu_auth_token_expiration', true);
    353         $stored_token = get_user_meta($user_id, 'payu_auth_token', true);
    354 
    355         if ($expiration >= time() && $stored_token) {
    356             return $stored_token;
    357         }
    358 
    359         $random_bytes = random_bytes(50);
    360         $hashed_token = bin2hex($random_bytes);
    361 
    362         // Set the expiration time to 24 hours from now
    363         $expiration = time() + 24 * 60 * 60;
    364         // Save the token and expiration time in user meta
    365         update_user_meta($user_id, 'payu_auth_token', $hashed_token);
    366         update_user_meta($user_id, 'payu_auth_token_expiration', $expiration);
    367 
    368         return $hashed_token;
    369     }
    370 
    371     private function payu_validate_authentication_token($email, $token)
    372     {
    373         $user_id = get_user_by('email', $email)->ID;
    374         // Get the stored token and expiration time from user meta
    375         $stored_token = get_user_meta($user_id, 'payu_auth_token', true);
    376         $expiration = get_user_meta($user_id, 'payu_auth_token_expiration', true);
    377         // Check if the stored token matches the provided token and is not expired
    378         return ($stored_token === $token && $expiration >= time()) ? true : false;
     307    private function payu_validate_authentication_token($request_body, $token)
     308    {
     309
     310        // Get saved plugin settings
     311        $plugin_settings = get_option('woocommerce_payubiz_settings');
     312        // Get Key and Salt
     313        $api_key = $plugin_settings['currency1_payu_key'] ?? '';
     314        $salt = $plugin_settings['currency1_payu_salt'] ?? '';
     315
     316        // Ensure required values exist
     317        if (empty($api_key) || empty($salt)) {
     318            error_log("key and salt are empty");
     319            return false;
     320        }
     321
     322        // Build string to hash
     323        $data_string = $request_body . '|' . $api_key . '|' . $salt;
     324
     325        // Generate hash
     326        $generated_hash = hash('sha512', $data_string);
     327        $generated_hash = trim($generated_hash);
     328        $token = trim($token);
     329        // Compare hashes
     330        if ($generated_hash === $token) {
     331            return true;
     332        }
     333
     334        error_log('Hash mismatch');
     335        return false;
    379336    }
    380337}
  • payu-india/trunk/includes/class-wc-gateway-payu.php

    r3301927 r3321888  
    11<?php
    2 ob_start(); 
     2ob_start();
    33if (!defined('ABSPATH')) {
    44    exit;
     
    1111    protected $msg = array();
    1212
    13     protected $logger;                                                                                     
     13    protected $logger;
    1414
    1515    protected $checkout_express;
     
    2828
    2929    protected $site_url;
    30     protected $dynamic_charges_flag;
    31    
    32     protected $_skuWiseTotal = 0;
     30    protected $dynamic_charges_flag;
     31
     32    protected $_skuWiseTotal = 0;
    3333
    3434
     
    4545        $this->init_settings();
    4646        $this->title = __('Credit/Debit Card & NetBanking Payment', 'payubiz');
    47         $this->method_description = __('Enable secure payments through PayU using (Credit/Debit Cards, NetBanking, UPI, and Wallets).', 'payubiz');     
    48         $this->supports  = array('products', 'refunds');
     47        $this->method_description = __('Enable secure payments through PayU using (Credit/Debit Cards, NetBanking, UPI, and Wallets).', 'payubiz');
     48        $this->supports = array('products', 'refunds');
    4949        $this->description = sanitize_text_field($this->settings['description']);
    5050        $this->checkout_express = sanitize_text_field($this->settings['checkout_express']);
    51         //$this->dynamic_charges_flag = sanitize_text_field($this->settings['dynamic_charges_flag']);
     51        //$this->dynamic_charges_flag = sanitize_text_field($this->settings['dynamic_charges_flag']);
    5252        $this->gateway_module = sanitize_text_field($this->settings['gateway_module']);
    5353        $this->redirect_page_id = sanitize_text_field($this->settings['redirect_page_id']);
     
    9797            if (PHP_VERSION_ID >= 70300) {
    9898                $options = session_get_cookie_params();
    99                 $domain = $options['domain']??'';
    100                 $path = $options['path']??'';
     99                $domain = $options['domain'] ?? '';
     100                $path = $options['path'] ?? '';
    101101                $expire = 0;
    102102                $cookies = $_COOKIE;
    103103                foreach ($cookies as $key => $value) {
    104104                    if (!preg_match('/cart/', sanitize_key($key))) {
    105                         setcookie(sanitize_key($key), sanitize_text_field($value), $expire,$path,$domain,true,true);
     105                        setcookie(sanitize_key($key), sanitize_text_field($value), $expire, $path, $domain, true, true);
    106106                    }
    107107                }
     
    129129    {
    130130        echo '<h3>' . esc_html__('PayU India', 'payubiz') . '</h3>';
    131         echo '<p>' . sprintf( __( '<a target="_blank" href="https://onboarding.payu.in/app/account/signup?partner_name=WooCommerce&partner_source=Affiliate+Links&partner_uuid=11eb-3a29-70592552-8c2b-0a696b110fde&source=Partner">Sign up</a> for a PayU merchant account to get started or <a target="_blank" href="https://onboarding.payu.in/app/account/login?partner_name=WooCommerce&partner_source=Affiliate+Links&partner_uuid=11eb-3a29-70592552-8c2b-0a696b110fde&source=Partner">login</a> to your existing account.', 'payubiz' ) ) . '</p>';
     131        echo '<p>' . sprintf(__('<a target="_blank" href="https://onboarding.payu.in/app/account/signup?partner_name=WooCommerce&partner_source=Affiliate+Links&partner_uuid=11eb-3a29-70592552-8c2b-0a696b110fde&source=Partner">Sign up</a> for a PayU merchant account to get started or <a target="_blank" href="https://onboarding.payu.in/app/account/login?partner_name=WooCommerce&partner_source=Affiliate+Links&partner_uuid=11eb-3a29-70592552-8c2b-0a696b110fde&source=Partner">login</a> to your existing account.', 'payubiz')) . '</p>';
    132132        if (PHP_VERSION_ID < 70300) {
    133133            echo "<h1 style=\"color:red;\">" . esc_html__('**Notice: PayU payment plugin requires PHP v7.3 or higher.<br />
     
    220220            return;
    221221        }
    222        
     222
    223223        $postdata = $this->preparePostdata();
    224224        $payuPaymentValidation = new PayuPaymentValidation();
     
    258258            payu_insert_event_logs($args_log);
    259259        }
    260        
     260
    261261        foreach ($_POST as $key => $val) {
    262262            $postdata[$key] = in_array(
    263263                $key,
    264                 ['transaction_offer', 'cart_details', 'shipping_address','extra_charges']
     264                ['transaction_offer', 'cart_details', 'shipping_address', 'extra_charges']
    265265            ) ?
    266266                $val : sanitize_text_field($val);
     
    288288        $redirect_url = add_query_arg('wc-api', get_class($this), $redirect_url);
    289289        WC()->session->set('orderid_awaiting_payubiz', $order_id);
    290         $txnid = $order_id . '_' . date("ymd") . '_' . random_int(1, 100);
     290        $txnid = $order_id . '_' . date("ymd") . '_' . random_int(1, 100);
    291291        update_post_meta($order_id, 'order_txnid', $txnid);
    292        
     292
    293293
    294294        $order->calculate_totals();
     
    299299        // }
    300300        $address = sanitize_text_field($order->get_billing_address_1()); {
    301         $address = $address . ' ' . sanitize_text_field($order->get_billing_address_2());
     301            $address = $address . ' ' . sanitize_text_field($order->get_billing_address_2());
    302302        }
    303303
     
    314314            $action = esc_url(PAYU_HOSTED_PAYMENT_URL_UAT);
    315315        }
    316         /**Disable & enable shipping charges.**/
    317         $plugin_data = get_option('woocommerce_payubiz_settings');
    318         $payu_dynamic_charges_flag = $plugin_data['dynamic_charges_flag'];
    319         $order_subtotal = sanitize_text_field($order->get_subtotal());   
     316        /**Disable & enable shipping charges.**/
     317        $plugin_data = get_option('woocommerce_payubiz_settings');
     318        $payu_dynamic_charges_flag = $plugin_data['dynamic_charges_flag'];
     319        $order_subtotal = sanitize_text_field($order->get_subtotal());
    320320        $order_total_tax = sanitize_text_field($order->order_total);
    321         if($payu_dynamic_charges_flag=="no"){
    322         $amount = $this->checkout_express=='checkout_express'?$order_total_tax:sanitize_text_field($order->order_total);
    323         }
    324         else{
    325         $amount = $this->checkout_express=='checkout_express'?$order_subtotal:sanitize_text_field($order->order_total);   
    326         }
    327         $amount=number_format($amount,2);
    328         $amount=str_replace(",", "", $amount);
    329         //echo $amount; exit;
     321        if ($payu_dynamic_charges_flag == "no") {
     322            $amount = $this->checkout_express == 'checkout_express' ? $order_total_tax : sanitize_text_field($order->order_total);
     323        } else {
     324            $amount = $this->checkout_express == 'checkout_express' ? $order_subtotal : sanitize_text_field($order->order_total);
     325        }
     326        $amount = number_format($amount, 2);
     327        $amount = str_replace(",", "", $amount);
     328        //echo $amount; exit;
    330329        $firstname = sanitize_text_field($order->billing_first_name);
    331330        $lastname = sanitize_text_field($order->billing_last_name);
     
    356355        $phone = isset($payu_phone) ? $payu_phone : sanitize_text_field($order->billing_phone);
    357356        //$phone = $payu_phone ? $payu_phone : sanitize_text_field($order->billing_phone);
    358         if(strlen($phone)>10){
    359         $phone = substr($phone, -10);   
    360         }
     357        if (strlen($phone) > 10) {
     358            $phone = substr($phone, -10);
     359        }
    361360        // $get_state_list = get_state_list();
    362361        // $state = $get_state_list[sanitize_text_field($order->billing_state)];
     
    371370        $udf5 = 'WooCommerce';
    372371        $hash = $this->generateHashToken($txnid, $amount, $productInfo, $firstname, $email, $udf4, $udf5);
    373        
     372
    374373        $payu_payment_nonce = wp_nonce_field('payu_payment_nonce', 'payu_payment_nonce', true, false);
    375        
     374
    376375        $requestArr = [
    377376            'key' => $payu_key,
     
    409408            $ramdom_str = bin2hex($random_bytes);
    410409            $c_date = gmdate('D, d M Y H:i:s T');
    411             //$tax_info_data=$order->order_total-$order->get_subtotal();
    412             $tax_info_data=WC()->cart->get_total_tax();
    413             //$tax_info_data=round($tax_info_data, 2);           
    414             $taxinfo= array(
    415                 'breakup'=>array(
    416                     'Standard' => "$tax_info_data"
    417                 ),
    418                 'total'=> "$tax_info_data"
    419             ); 
     410            //$tax_info_data=$order->order_total-$order->get_subtotal();
     411            $tax_info_data = WC()->cart->get_total_tax();
     412            //$tax_info_data=round($tax_info_data, 2);           
     413            $taxinfo = array(
     414                'breakup' => array(
     415                    'Standard' => "$tax_info_data"
     416                ),
     417                'total' => "$tax_info_data"
     418            );
    420419
    421420            $order_amount = 0;
    422             if($payu_dynamic_charges_flag=="no"){
    423                 if(wc_prices_include_tax()){
    424                     $taxinfo=NULL;
    425                     $order_amount = $order->order_total;
    426                    
    427                 }else{
    428                     $taxinfo=$taxinfo;
    429                     $order_amount = $order->get_subtotal();
    430                 }
    431                
    432             } else {
    433                 $taxinfo=NULL;
    434                 $order_amount  = $order->get_subtotal();               
    435             }
     421            if ($payu_dynamic_charges_flag == "no") {
     422                if (wc_prices_include_tax()) {
     423                    $taxinfo = NULL;
     424                    $order_amount = $order->order_total;
     425
     426                } else {
     427                    $taxinfo = $taxinfo;
     428                    $order_amount = $order->get_subtotal();
     429                }
     430
     431            } else {
     432                $taxinfo = NULL;
     433                $order_amount = $order->get_subtotal();
     434            }
    436435            // echo "team working please wait";
    437436            // echo wc_prices_include_tax();
     
    439438
    440439            // exit;
    441            
    442             if($payu_dynamic_charges_flag=="yes" && wc_prices_include_tax()){
    443                 $order_amount = $order->order_total;
    444                 $amount = $order->order_total;
    445             }           
    446             $amount=str_replace(",", "", $amount);
    447            
     440
     441            if ($payu_dynamic_charges_flag == "yes" && wc_prices_include_tax()) {
     442                $order_amount = $order->order_total;
     443                $amount = $order->order_total;
     444            }
     445            $amount = str_replace(",", "", $amount);
     446
    448447            if (empty($email)) {
    449                 $email = 'guest_' . uniqid() . '@payu.in';
    450                 error_log('Email not found, setting default email: ' . $email);
    451             }
    452        
     448                $email = 'guest_' . uniqid() . '@payu.in';
     449                error_log('Email not found, setting default email: ' . $email);
     450            }
     451
    453452            $data_array = array(
    454453                'key' => $payu_key,
     
    465464                'udf4' => $udf4,
    466465                'udf5' => $udf5,
     466                'app_version' => COMMERCEPRO_APP_VERSION,
    467467                'drop_category' => '',
    468468                'enforce_paymethod' => '',
     
    478478                'orderid' => $ramdom_str,
    479479                'extra_charges' => array(
    480                     'totalAmount' => NULL, // this amount adding extra charges + cart Amount
    481                     'shipping_charges' => NULL, // static shipping charges
    482                     'cod_fee' => 0, // cash on delivery fee.
    483                     'other_charges' => NULL,
    484                     'tax_info' => $taxinfo,
    485                    
    486                 ),
     480                        'totalAmount' => NULL, // this amount adding extra charges + cart Amount
     481                        'shipping_charges' => NULL, // static shipping charges
     482                        'cod_fee' => 0, // cash on delivery fee.
     483                        'other_charges' => NULL,
     484                        'tax_info' => $taxinfo,
     485
     486                    ),
    487487                'cart_details' => array(
    488488                    'amount' => $order_amount,
    489                     'items' => (string)$item_count,
     489                    'items' => (string) $item_count,
    490490                    'sku_details' => $sku_details_array,
    491491                )
     
    493493            );
    494494            $data_array = payuEndPointData($data_array);
    495            
    496            
     495
     496
    497497            $args_ec = $this->payuExpressCheckoutScriptGenerate($data_array, $c_date, $redirect_url, $payu_payment_nonce);
    498498            $html = $this->payuExpressCheckoutPayment($args_ec);
     
    508508        $productInfo = '';
    509509
    510         $default_Payu_logo = 'https://devguide.payu.in/website-assets/uploads/2021/12/new-payu-logo.svg'; 
    511        
     510        $default_Payu_logo = 'https://devguide.payu.in/website-assets/uploads/2021/12/new-payu-logo.svg';
     511
    512512        foreach ($order->get_items() as $item) {
    513             $variation_id = $item->get_variation_id();
    514             $_product = new WC_Product_Variation($variation_id);
    515             $single_sku_price= (float) $_product->get_price();
    516             $single_sku_name=$_product->get_name();
    517             $single_sku=$_product->get_sku();
    518             $single_sku=($single_sku!="") ? $single_sku : $variation_id;
    519             $single_sku_price=str_replace(",", "", $single_sku_price);
     513            $variation_id = $item->get_variation_id();
     514            $_product = new WC_Product_Variation($variation_id);
     515            $single_sku_price = (float) $_product->get_price();
     516            $single_sku_name = $_product->get_name();
     517            $single_sku = $_product->get_sku();
     518            $single_sku = ($single_sku != "") ? $single_sku : $variation_id;
     519            $single_sku_price = str_replace(",", "", $single_sku_price);
    520520            $product = wc_get_product($item->get_product_id());
    521521            $productInfo .= $product->get_sku() . ':';
    522             // $amount_per_sku= number_format($product->get_price(), 2);
    523             $amount_per_sku= (float)$product->get_price();
    524 
    525             $amount_per_sku=str_replace(",", "", $amount_per_sku);
     522            // $amount_per_sku= number_format($product->get_price(), 2);
     523            $amount_per_sku = (float) $product->get_price();
     524
     525            $amount_per_sku = str_replace(",", "", $amount_per_sku);
    526526
    527527            $product_image = wp_get_attachment_url($_product->get_image_id());
    528528            $logo = $product_image ? $product_image : $default_Payu_logo;
    529             if($variation_id==0){
    530                 $sku_id=($product->get_sku()!="") ? $product->get_sku():$product->get_id();
    531                 $amount_per_sku=$amount_per_sku;
    532                 $product_name=$product->get_name();
    533             }
    534             else{
    535              $sku_id=$single_sku;
    536              $amount_per_sku=$single_sku_price;
    537              $product_name=$single_sku_name;                 
    538             }
    539 
    540             $sku_details_array[] = array(
     529            if ($variation_id == 0) {
     530                $sku_id = ($product->get_sku() != "") ? $product->get_sku() : $product->get_id();
     531                $amount_per_sku = $amount_per_sku;
     532                $product_name = $product->get_name();
     533            } else {
     534                $sku_id = $single_sku;
     535                $amount_per_sku = $single_sku_price;
     536                $product_name = $single_sku_name;
     537            }
     538
     539            $sku_details_array[] = array(
    541540                'offer_key' => array(),
    542541                'amount_per_sku' => $amount_per_sku,
    543                 'quantity' => (string)$item->get_quantity(),
     542                'quantity' => (string) $item->get_quantity(),
    544543                'sku_id' => $sku_id,
    545                 'sku_name' => $product_name, 
     544                'sku_name' => $product_name,
    546545                'logo' => $logo
    547             );           
     546            );
    548547        }
    549548
     
    558557    }
    559558
    560    
     559
    561560
    562561    private function payuRedirectMethod($args_redirect)
    563562    {
    564563        return '<form action="' . esc_url($args_redirect['action']) . '" method="post" id="payu_form" name="payu_form">
    565                 ' .  wp_nonce_field('payu_payment_nonce', 'payu_payment_nonce', true, false) . '
     564                ' . wp_nonce_field('payu_payment_nonce', 'payu_payment_nonce', true, false) . '
    566565                <input type="hidden" name="key" value="' . esc_attr($args_redirect['key']) . '" />
    567566                <input type="hidden" name="txnid" value="' . esc_attr($args_redirect['txnid']) . '" />
     
    655654        $redirect_url = $args_express_checkout['redirect_url'];
    656655        $payu_payment_nonce = $args_express_checkout['payu_payment_nonce'];
     656        // $args_express_checkout['data_array_json']['app_version'] = '3.8.7';
    657657        $data_array_json = json_encode($args_express_checkout['data_array_json']);
     658        // $data_array = $args_express_checkout['data_array_json'];
     659        // // $data_array['app_version'] = '3.8.7';
     660        // $data_array['app_version'] = COMMERCEPRO_APP_VERSION;
     661        // $data_array_json = json_encode($data_array);
    658662        $c_date = $args_express_checkout['c_date'];
    659663        $auth_header_string = $args_express_checkout['auth_header_string'];
     
    722726            'sha512',
    723727            $this->currency1_payu_key . '|' .
    724                 $txnid . '|' .
    725                 $amount . '|' .
    726                 $productInfo . '|' .
    727                 $firstname . '|' .
    728                 $email . '||||' .
    729                 $udf4 . '|' .
    730                 $udf5 . '||||||' .
    731                 $payu_salt
     728            $txnid . '|' .
     729            $amount . '|' .
     730            $productInfo . '|' .
     731            $firstname . '|' .
     732            $email . '||||' .
     733            $udf4 . '|' .
     734            $udf5 . '||||||' .
     735            $payu_salt
    732736        );
    733737    }
  • payu-india/trunk/includes/constant.php

    r3156222 r3321888  
    2323$woocommerce_version = get_option('woocommerce_version');
    2424define('WOOCOMMERCE_CURRENT_VERSION',$woocommerce_version);
     25define('COMMERCEPRO_APP_VERSION' , '3.8');
  • payu-india/trunk/index.php

    r3278834 r3321888  
    44Plugin URI: https://payu.in/
    55Description: Seamlessly integrate PayU with WooCommerce for secure and reliable payment processing.
    6 Version: 3.8.5
     6Version: 3.8.8
    77Author: Team PayU
    88Author URI: https://payu.in/
     
    1010Requires at least: 5.3
    1111Tested up to: 6.8
    12 Stable tag: 3.8.5
     12Stable tag: 3.8.8
    1313Requires PHP: 7.4
    1414License: GPLv2 or later
  • payu-india/trunk/readme.txt

    r3278834 r3321888  
    55Requires at least: 5.3
    66Tested up to: 6.8
    7 Stable tag: 3.8.5
     7Stable tag: 3.8.8
    88Requires PHP: 7.4
    99License: GPLv2 or later
     
    4545
    4646== Changelog ==
     47
     48= 3.8.8 =
     49
     50Remove user token api
     51
     52Added hash validation for shipping cost api
     53
     54= 3.8.7 =
     55
     56Fixing user session
     57
     58Skipping order update for shipping api
     59
     60= 3.8.6 =
     61
     62Fixed:
     63
     64User session issue
     65
    4766= 3.8.5 =
    4867
Note: See TracChangeset for help on using the changeset viewer.