Changeset 3321888
- Timestamp:
- 07/03/2025 03:45:46 PM (6 months ago)
- Location:
- payu-india/trunk
- Files:
-
- 6 edited
-
includes/class-payu-payment-validation.php (modified) (1 diff)
-
includes/class-payu-shipping-tax-api-calculation.php (modified) (9 diffs)
-
includes/class-wc-gateway-payu.php (modified) (22 diffs)
-
includes/constant.php (modified) (1 diff)
-
index.php (modified) (2 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
payu-india/trunk/includes/class-payu-payment-validation.php
r3309781 r3321888 83 83 } 84 84 } 85 86 85 87 86 private function getRedirectUrl($order) -
payu-india/trunk/includes/class-payu-shipping-tax-api-calculation.php
r3313923 r3321888 15 15 16 16 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')); 18 18 } 19 19 … … 30 30 public function payuShippingCostCallback(WP_REST_Request $request) 31 31 { 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); 40 58 41 59 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)) { 43 61 $response = $this->handleValidToken($parameters, $email, $txnid); 44 62 } else { … … 77 95 $session_key = $parameters['udf4']; 78 96 $order_string = explode('_', $txnid); 79 $order_id = (int) $order_string[0];97 $order_id = (int) $order_string[0]; 80 98 $order = wc_get_order($order_id); 99 // error_log(var_dump($order , true )); 81 100 82 101 $shipping_address = $parameters['address']; … … 127 146 public function update_order_shipping_address($order, $new_address, $email) 128 147 { 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 134 158 $order->set_address($new_address, 'shipping'); 135 159 $order->set_address($new_address, 'billing'); 136 error_log('set order address ' . json_encode($new_address));137 160 $order->set_billing_email($email); 161 162 error_log('Updated order address: ' . json_encode($new_address)); 163 138 164 return $order; 139 165 } … … 184 210 WC()->customer->set_shipping_address_1($order->get_shipping_address_1()); 185 211 WC()->cart = new WC_Cart(); 186 212 187 213 // Authenticate user 188 214 if (is_user_logged_in()) { … … 190 216 $user_id = $current_user->ID; 191 217 wp_set_current_user($user_id); 192 // wp_set_auth_cookie($user_id);193 218 } elseif (!empty($user_id)) { 194 219 // Set session for already created/registered user 195 220 wp_set_current_user($user_id); 196 // wp_set_auth_cookie($user_id);197 221 } 198 222 … … 209 233 WC()->cart->calculate_totals(); 210 234 foreach (WC()->cart->get_tax_totals() as $tax) { 211 $tax_amount = $tax->amount + $tax_amount;235 $tax_amount = $tax->amount + $tax_amount; 212 236 } 213 237 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'] = ""; 219 243 $plugin_data = get_option('woocommerce_payubiz_settings'); 220 244 $payu_dynamic_charges_flag = $plugin_data['dynamic_charges_flag']; … … 222 246 if ($payu_dynamic_charges_flag == "yes" && wc_prices_include_tax()) { 223 247 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); 225 249 $shipping_data[$shipping_method_count]['tax_price_inclusive'] = round($tax_amount, 2); 226 250 } else { 227 $shipping_data[$shipping_method_count]['tax_price'] = 0;251 $shipping_data[$shipping_method_count]['tax_price'] = 0; 228 252 $shipping_data[$shipping_method_count]['tax_price_inclusive'] = round($tax_amount, 2); 229 253 } 230 254 } 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); 232 256 } 233 257 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); 236 260 $shipping_method_count++; 237 261 } 238 262 } else if (WC()->cart->get_tax_totals()) { 239 263 foreach (WC()->cart->get_tax_totals() as $tax) { 240 $tax_amount = $tax->amount + $tax_amount;264 $tax_amount = $tax->amount + $tax_amount; 241 265 } 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; 250 274 } 251 275 } … … 281 305 update_user_meta($user_id, '_woocommerce_persistent_cart_1', $cart_data); 282 306 } 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; 379 336 } 380 337 } -
payu-india/trunk/includes/class-wc-gateway-payu.php
r3301927 r3321888 1 1 <?php 2 ob_start(); 2 ob_start(); 3 3 if (!defined('ABSPATH')) { 4 4 exit; … … 11 11 protected $msg = array(); 12 12 13 protected $logger; 13 protected $logger; 14 14 15 15 protected $checkout_express; … … 28 28 29 29 protected $site_url; 30 protected $dynamic_charges_flag;31 32 protected $_skuWiseTotal = 0;30 protected $dynamic_charges_flag; 31 32 protected $_skuWiseTotal = 0; 33 33 34 34 … … 45 45 $this->init_settings(); 46 46 $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'); 49 49 $this->description = sanitize_text_field($this->settings['description']); 50 50 $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']); 52 52 $this->gateway_module = sanitize_text_field($this->settings['gateway_module']); 53 53 $this->redirect_page_id = sanitize_text_field($this->settings['redirect_page_id']); … … 97 97 if (PHP_VERSION_ID >= 70300) { 98 98 $options = session_get_cookie_params(); 99 $domain = $options['domain'] ??'';100 $path = $options['path'] ??'';99 $domain = $options['domain'] ?? ''; 100 $path = $options['path'] ?? ''; 101 101 $expire = 0; 102 102 $cookies = $_COOKIE; 103 103 foreach ($cookies as $key => $value) { 104 104 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); 106 106 } 107 107 } … … 129 129 { 130 130 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>'; 132 132 if (PHP_VERSION_ID < 70300) { 133 133 echo "<h1 style=\"color:red;\">" . esc_html__('**Notice: PayU payment plugin requires PHP v7.3 or higher.<br /> … … 220 220 return; 221 221 } 222 222 223 223 $postdata = $this->preparePostdata(); 224 224 $payuPaymentValidation = new PayuPaymentValidation(); … … 258 258 payu_insert_event_logs($args_log); 259 259 } 260 260 261 261 foreach ($_POST as $key => $val) { 262 262 $postdata[$key] = in_array( 263 263 $key, 264 ['transaction_offer', 'cart_details', 'shipping_address', 'extra_charges']264 ['transaction_offer', 'cart_details', 'shipping_address', 'extra_charges'] 265 265 ) ? 266 266 $val : sanitize_text_field($val); … … 288 288 $redirect_url = add_query_arg('wc-api', get_class($this), $redirect_url); 289 289 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); 291 291 update_post_meta($order_id, 'order_txnid', $txnid); 292 292 293 293 294 294 $order->calculate_totals(); … … 299 299 // } 300 300 $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()); 302 302 } 303 303 … … 314 314 $action = esc_url(PAYU_HOSTED_PAYMENT_URL_UAT); 315 315 } 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()); 320 320 $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; 330 329 $firstname = sanitize_text_field($order->billing_first_name); 331 330 $lastname = sanitize_text_field($order->billing_last_name); … … 356 355 $phone = isset($payu_phone) ? $payu_phone : sanitize_text_field($order->billing_phone); 357 356 //$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 } 361 360 // $get_state_list = get_state_list(); 362 361 // $state = $get_state_list[sanitize_text_field($order->billing_state)]; … … 371 370 $udf5 = 'WooCommerce'; 372 371 $hash = $this->generateHashToken($txnid, $amount, $productInfo, $firstname, $email, $udf4, $udf5); 373 372 374 373 $payu_payment_nonce = wp_nonce_field('payu_payment_nonce', 'payu_payment_nonce', true, false); 375 374 376 375 $requestArr = [ 377 376 'key' => $payu_key, … … 409 408 $ramdom_str = bin2hex($random_bytes); 410 409 $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 ); 420 419 421 420 $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 } 436 435 // echo "team working please wait"; 437 436 // echo wc_prices_include_tax(); … … 439 438 440 439 // 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 448 447 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 453 452 $data_array = array( 454 453 'key' => $payu_key, … … 465 464 'udf4' => $udf4, 466 465 'udf5' => $udf5, 466 'app_version' => COMMERCEPRO_APP_VERSION, 467 467 'drop_category' => '', 468 468 'enforce_paymethod' => '', … … 478 478 'orderid' => $ramdom_str, 479 479 'extra_charges' => array( 480 'totalAmount' => NULL, // this amount adding extra charges + cart Amount481 'shipping_charges' => NULL, // static shipping charges482 '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 ), 487 487 'cart_details' => array( 488 488 'amount' => $order_amount, 489 'items' => (string) $item_count,489 'items' => (string) $item_count, 490 490 'sku_details' => $sku_details_array, 491 491 ) … … 493 493 ); 494 494 $data_array = payuEndPointData($data_array); 495 496 495 496 497 497 $args_ec = $this->payuExpressCheckoutScriptGenerate($data_array, $c_date, $redirect_url, $payu_payment_nonce); 498 498 $html = $this->payuExpressCheckoutPayment($args_ec); … … 508 508 $productInfo = ''; 509 509 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 512 512 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); 520 520 $product = wc_get_product($item->get_product_id()); 521 521 $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); 526 526 527 527 $product_image = wp_get_attachment_url($_product->get_image_id()); 528 528 $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( 541 540 'offer_key' => array(), 542 541 'amount_per_sku' => $amount_per_sku, 543 'quantity' => (string) $item->get_quantity(),542 'quantity' => (string) $item->get_quantity(), 544 543 'sku_id' => $sku_id, 545 'sku_name' => $product_name, 544 'sku_name' => $product_name, 546 545 'logo' => $logo 547 ); 546 ); 548 547 } 549 548 … … 558 557 } 559 558 560 559 561 560 562 561 private function payuRedirectMethod($args_redirect) 563 562 { 564 563 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) . ' 566 565 <input type="hidden" name="key" value="' . esc_attr($args_redirect['key']) . '" /> 567 566 <input type="hidden" name="txnid" value="' . esc_attr($args_redirect['txnid']) . '" /> … … 655 654 $redirect_url = $args_express_checkout['redirect_url']; 656 655 $payu_payment_nonce = $args_express_checkout['payu_payment_nonce']; 656 // $args_express_checkout['data_array_json']['app_version'] = '3.8.7'; 657 657 $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); 658 662 $c_date = $args_express_checkout['c_date']; 659 663 $auth_header_string = $args_express_checkout['auth_header_string']; … … 722 726 'sha512', 723 727 $this->currency1_payu_key . '|' . 724 $txnid . '|' .725 $amount . '|' .726 $productInfo . '|' .727 $firstname . '|' .728 $email . '||||' .729 $udf4 . '|' .730 $udf5 . '||||||' .731 $payu_salt728 $txnid . '|' . 729 $amount . '|' . 730 $productInfo . '|' . 731 $firstname . '|' . 732 $email . '||||' . 733 $udf4 . '|' . 734 $udf5 . '||||||' . 735 $payu_salt 732 736 ); 733 737 } -
payu-india/trunk/includes/constant.php
r3156222 r3321888 23 23 $woocommerce_version = get_option('woocommerce_version'); 24 24 define('WOOCOMMERCE_CURRENT_VERSION',$woocommerce_version); 25 define('COMMERCEPRO_APP_VERSION' , '3.8'); -
payu-india/trunk/index.php
r3278834 r3321888 4 4 Plugin URI: https://payu.in/ 5 5 Description: Seamlessly integrate PayU with WooCommerce for secure and reliable payment processing. 6 Version: 3.8. 56 Version: 3.8.8 7 7 Author: Team PayU 8 8 Author URI: https://payu.in/ … … 10 10 Requires at least: 5.3 11 11 Tested up to: 6.8 12 Stable tag: 3.8. 512 Stable tag: 3.8.8 13 13 Requires PHP: 7.4 14 14 License: GPLv2 or later -
payu-india/trunk/readme.txt
r3278834 r3321888 5 5 Requires at least: 5.3 6 6 Tested up to: 6.8 7 Stable tag: 3.8. 57 Stable tag: 3.8.8 8 8 Requires PHP: 7.4 9 9 License: GPLv2 or later … … 45 45 46 46 == Changelog == 47 48 = 3.8.8 = 49 50 Remove user token api 51 52 Added hash validation for shipping cost api 53 54 = 3.8.7 = 55 56 Fixing user session 57 58 Skipping order update for shipping api 59 60 = 3.8.6 = 61 62 Fixed: 63 64 User session issue 65 47 66 = 3.8.5 = 48 67
Note: See TracChangeset
for help on using the changeset viewer.