Changeset 3186417
- Timestamp:
- 11/12/2024 10:46:02 AM (14 months ago)
- Location:
- payu-india
- Files:
-
- 6 edited
-
tags/3.8.3/includes/class-payu-payment-validation.php (modified) (1 diff)
-
tags/3.8.3/includes/class-payu-shipping-tax-api-calculation.php (modified) (3 diffs)
-
tags/3.8.3/includes/class-wc-gateway-payu.php (modified) (14 diffs)
-
trunk/includes/class-payu-payment-validation.php (modified) (1 diff)
-
trunk/includes/class-payu-shipping-tax-api-calculation.php (modified) (3 diffs)
-
trunk/includes/class-wc-gateway-payu.php (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
payu-india/tags/3.8.3/includes/class-payu-payment-validation.php
r3163861 r3186417 436 436 'city' => $order->get_shipping_city(), // (optional value) 437 437 ); 438 foreach($order->get_items('shipping') as $item_id => $item) { 439 $order->remove_item($item_id); 440 } 438 441 $added_shipping = array(); 439 442 foreach ($order->get_items('shipping') as $item) { -
payu-india/tags/3.8.3/includes/class-payu-shipping-tax-api-calculation.php
r3163861 r3186417 59 59 } 60 60 $response_code = $response['status'] == 'false' ? 400 : 200; 61 error_log('shipping api call response ' . wp_json_encode($response));61 error_log('shipping api call response ' . json_encode($response)); 62 62 return new WP_REST_Response($response, $response_code); 63 63 } … … 134 134 $order->set_address($new_address, 'shipping'); 135 135 $order->set_address($new_address, 'billing'); 136 error_log('set order address ' . wp_json_encode($new_address));136 error_log('set order address ' . json_encode($new_address)); 137 137 $order->set_billing_email($email); 138 138 $order->save(); … … 206 206 $shipping_data[$shipping_method_count]['amount'] = $shipping_rate->get_cost(); 207 207 $shipping_data[$shipping_method_count]['error_message'] = ""; 208 $shipping_data[$shipping_method_count]['tax_price'] = $tax_amount; 208 $plugin_data = get_option('woocommerce_payubiz_settings'); 209 $payu_dynamic_charges_flag = $plugin_data['dynamic_charges_flag']; 210 211 if($payu_dynamic_charges_flag=="yes" && wc_prices_include_tax()){ 212 if(WC()->cart->get_shipping_tax()){ 213 $shipping_data[$shipping_method_count]['tax_price'] = round(WC()->cart->get_shipping_tax(), 2); 214 $shipping_data[$shipping_method_count]['tax_price_inclusive'] = round($tax_amount, 2); 215 } 216 else{ 217 $shipping_data[$shipping_method_count]['tax_price'] = 0; 218 $shipping_data[$shipping_method_count]['tax_price_inclusive'] = round($tax_amount, 2); 219 } 220 221 } 222 else{ 223 $shipping_data[$shipping_method_count]['tax_price'] = round($tax_amount, 2); 224 } 225 209 226 $shipping_data[$shipping_method_count]['subtotal'] = WC()->cart->get_subtotal(); 210 $shipping_data[$shipping_method_count]['grand_total'] = WC()->cart->get_subtotal() + $shipping_rate->get_cost() + $tax_amount;227 $shipping_data[$shipping_method_count]['grand_total'] = round(WC()->cart->get_subtotal() + $shipping_rate->get_cost()+ $tax_amount, 2); 211 228 $shipping_method_count++; 212 229 } 213 230 } else if(WC()->cart->get_tax_totals()){ 214 231 foreach (WC()->cart->get_tax_totals() as $tax) { 215 $tax_amount = $tax->amount + $tax_amount; 232 $tax_amount = $tax->amount + $tax_amount; 216 233 } 217 234 $shipping_data[0]['carrier_code'] = ''; -
payu-india/tags/3.8.3/includes/class-wc-gateway-payu.php
r3171075 r3186417 29 29 protected $site_url; 30 30 protected $dynamic_charges_flag; 31 32 protected $_skuWiseTotal = 0; 31 33 32 34 … … 153 155 $this->manage_session(); //Update cookies with samesite 154 156 $thankyou_msg = 'Thank you for your order, please wait as you will be automatically redirected to PayUBiz.'; 155 echo '<p>' . esc_html ($thankyou_msg, 'payubiz') . '</p>';157 echo '<p>' . esc_html__($thankyou_msg, 'payubiz') . '</p>'; 156 158 echo $this->generatePayubizForm($order); 157 159 } … … 285 287 $redirect_url = add_query_arg('wc-api', get_class($this), $redirect_url); 286 288 WC()->session->set('orderid_awaiting_payubiz', $order_id); 287 //$txnid = $order_id . '_' . date("ymd") . ':' . random_int(1, 100); 288 $txnid = $order_id . '_' . gmdate("ymd") . '_' . random_int(1, 100); 289 $txnid = $order_id . '_' . date("ymd") . '_' . random_int(1, 100); 289 290 update_post_meta($order_id, 'order_txnid', $txnid); 290 291 … … 294 295 //get currency 295 296 $address = sanitize_text_field($order->billing_address_1); { 296 $address = $address . ' ' . sanitize_text_field($order->billing_address_2);297 $address = $address . ' ' . sanitize_text_field($order->billing_address_2); 297 298 } 298 299 … … 309 310 $action = esc_url(PAYU_HOSTED_PAYMENT_URL_UAT); 310 311 } 311 312 $order_subtotal = sanitize_text_field($order->get_subtotal()); 313 $amount = $this->checkout_express=='checkout_express'?$order_subtotal:sanitize_text_field($order->order_total); 312 /**Disable & enable shipping charges.**/ 313 $plugin_data = get_option('woocommerce_payubiz_settings'); 314 $payu_dynamic_charges_flag = $plugin_data['dynamic_charges_flag']; 315 $order_subtotal = sanitize_text_field($order->get_subtotal()); 316 $order_total_tax = sanitize_text_field($order->order_total); 317 if($payu_dynamic_charges_flag=="no"){ 318 $amount = $this->checkout_express=='checkout_express'?$order_total_tax:sanitize_text_field($order->order_total); 319 } 320 else{ 321 $amount = $this->checkout_express=='checkout_express'?$order_subtotal:sanitize_text_field($order->order_total); 322 } 314 323 $amount=number_format($amount,2); 315 324 $amount=str_replace(",", "", $amount); 325 //echo $amount; exit; 316 326 $firstname = sanitize_text_field($order->billing_first_name); 317 327 $lastname = sanitize_text_field($order->billing_last_name); … … 388 398 $ramdom_str = bin2hex($random_bytes); 389 399 $c_date = gmdate('D, d M Y H:i:s T'); 400 //$tax_info_data=$order->order_total-$order->get_subtotal(); 401 $tax_info_data=WC()->cart->get_total_tax(); 402 //$tax_info_data=round($tax_info_data, 2); 403 $taxinfo=array( 404 'breakup'=>array( 405 'Standard' => "$tax_info_data" 406 ), 407 'total'=> "$tax_info_data" 408 ); 409 410 $order_amount = 0; 411 if($payu_dynamic_charges_flag=="no"){ 412 if(wc_prices_include_tax()){ 413 $taxinfo=NULL; 414 $order_amount = $order->order_total; 415 416 }else{ 417 $taxinfo=$taxinfo; 418 $order_amount = $order->get_subtotal(); 419 } 420 421 } else { 422 $taxinfo=NULL; 423 $order_amount = $order->get_subtotal(); 424 } 390 425 426 427 if($payu_dynamic_charges_flag=="yes" && wc_prices_include_tax()){ 428 $order_amount = $order->order_total; 429 $amount = $order->order_total; 430 } 391 431 $amount=str_replace(",", "", $amount); 432 392 433 $data_array = array( 393 434 'key' => $payu_key, … … 421 462 'cod_fee' => 0, // cash on delivery fee. 422 463 'other_charges' => NULL, 423 'tax_info' => NULL, 464 'tax_info' => $taxinfo, 465 424 466 ), 425 467 'cart_details' => array( 426 'amount' => $order_ subtotal,468 'amount' => $order_amount, 427 469 'items' => (string)$item_count, 428 470 'sku_details' => $sku_details_array, … … 446 488 $productInfo = ''; 447 489 $logo = 'https://payu.in/demo/checkoutExpress/utils/images/MicrosoftTeams-image%20(31).png'; 490 448 491 foreach ($order->get_items() as $item) { 492 $variation_id = $item->get_variation_id(); 493 $_product = new WC_Product_Variation($variation_id); 494 $single_sku_price=$_product->get_price(); 495 $single_sku_name=$_product->get_name(); 496 $single_sku=$_product->get_sku(); 497 $single_sku=($single_sku!="") ? $single_sku : $variation_id; 498 $single_sku_price=str_replace(",", "", $single_sku_price); 449 499 $product = wc_get_product($item->get_product_id()); 450 500 $productInfo .= $product->get_sku() . ':'; 451 501 $amount_per_sku=(string)number_format($product->get_price(), 2); 452 502 $amount_per_sku=str_replace(",", "", $amount_per_sku); 453 $sku_details_array[] = array( 503 if($variation_id==0){ 504 $sku_id=($product->get_sku()!="") ? $product->get_sku():$product->get_id(); 505 $amount_per_sku=$amount_per_sku; 506 $product_name=$product->get_name(); 507 } 508 else{ 509 $sku_id=$single_sku; 510 $amount_per_sku=$single_sku_price; 511 $product_name=$single_sku_name; 512 } 513 $sku_details_array[] = array( 454 514 'offer_key' => array(), 455 515 'amount_per_sku' => $amount_per_sku, 456 516 'quantity' => (string)$item->get_quantity(), 457 //'sku_id' => $product->get_sku(), 458 'sku_id' => ($product->get_sku()!="") ? $product->get_sku():$product->get_id(), 459 'sku_name' => $product->get_name(), 517 'sku_id' => $sku_id, 518 'sku_name' => $product_name, 460 519 'logo' => $logo 461 ); 520 ); 462 521 } 463 522 … … 510 569 </form> 511 570 "; 512 $data = wp_json_encode($requestArr, JSON_UNESCAPED_SLASHES);571 $data = json_encode($requestArr, JSON_UNESCAPED_SLASHES); 513 572 $javascriptCode = <<<EOD 514 573 <script type='text/javascript'> … … 543 602 $payu_key = $this->currency1_payu_key; 544 603 $payu_salt = $this->currency1_payu_salt; 545 $data_array_json = wp_json_encode($data_array, JSON_UNESCAPED_SLASHES);604 $data_array_json = json_encode($data_array, JSON_UNESCAPED_SLASHES); 546 605 $v2hash = hash('sha512', $data_array_json . "|" . $c_date . "|" . $payu_salt); 547 606 $username = "hmac username=\"$payu_key\""; … … 567 626 $redirect_url = $args_express_checkout['redirect_url']; 568 627 $payu_payment_nonce = $args_express_checkout['payu_payment_nonce']; 569 $data_array_json = $args_express_checkout['data_array_json'];628 $data_array_json = json_encode($args_express_checkout['data_array_json']); 570 629 $c_date = $args_express_checkout['c_date']; 571 630 $auth_header_string = $args_express_checkout['auth_header_string']; … … 580 639 function handleSubmit() { 581 640 const expressRequestObj = { 582 data: '$data_array_json',641 data: $data_array_json, 583 642 date: '$c_date', 584 643 isCheckoutExpress: true, … … 587 646 var handlers = { 588 647 responseHandler: function (BOLT) { 589 console.log('response from payu'); 648 console.log('response from payu'); 649 console.log(BOLT.response.amount); 650 console.log(JSON.stringify(BOLT.response)); 651 590 652 if (BOLT.response.txnStatus == 'FAILED') { 591 653 alert('Payment failed. Please try again.'); … … 661 723 return false; 662 724 } 663 664 665 666 725 } -
payu-india/trunk/includes/class-payu-payment-validation.php
r3163861 r3186417 436 436 'city' => $order->get_shipping_city(), // (optional value) 437 437 ); 438 foreach($order->get_items('shipping') as $item_id => $item) { 439 $order->remove_item($item_id); 440 } 438 441 $added_shipping = array(); 439 442 foreach ($order->get_items('shipping') as $item) { -
payu-india/trunk/includes/class-payu-shipping-tax-api-calculation.php
r3163861 r3186417 59 59 } 60 60 $response_code = $response['status'] == 'false' ? 400 : 200; 61 error_log('shipping api call response ' . wp_json_encode($response));61 error_log('shipping api call response ' . json_encode($response)); 62 62 return new WP_REST_Response($response, $response_code); 63 63 } … … 134 134 $order->set_address($new_address, 'shipping'); 135 135 $order->set_address($new_address, 'billing'); 136 error_log('set order address ' . wp_json_encode($new_address));136 error_log('set order address ' . json_encode($new_address)); 137 137 $order->set_billing_email($email); 138 138 $order->save(); … … 206 206 $shipping_data[$shipping_method_count]['amount'] = $shipping_rate->get_cost(); 207 207 $shipping_data[$shipping_method_count]['error_message'] = ""; 208 $shipping_data[$shipping_method_count]['tax_price'] = $tax_amount; 208 $plugin_data = get_option('woocommerce_payubiz_settings'); 209 $payu_dynamic_charges_flag = $plugin_data['dynamic_charges_flag']; 210 211 if($payu_dynamic_charges_flag=="yes" && wc_prices_include_tax()){ 212 if(WC()->cart->get_shipping_tax()){ 213 $shipping_data[$shipping_method_count]['tax_price'] = round(WC()->cart->get_shipping_tax(), 2); 214 $shipping_data[$shipping_method_count]['tax_price_inclusive'] = round($tax_amount, 2); 215 } 216 else{ 217 $shipping_data[$shipping_method_count]['tax_price'] = 0; 218 $shipping_data[$shipping_method_count]['tax_price_inclusive'] = round($tax_amount, 2); 219 } 220 221 } 222 else{ 223 $shipping_data[$shipping_method_count]['tax_price'] = round($tax_amount, 2); 224 } 225 209 226 $shipping_data[$shipping_method_count]['subtotal'] = WC()->cart->get_subtotal(); 210 $shipping_data[$shipping_method_count]['grand_total'] = WC()->cart->get_subtotal() + $shipping_rate->get_cost() + $tax_amount;227 $shipping_data[$shipping_method_count]['grand_total'] = round(WC()->cart->get_subtotal() + $shipping_rate->get_cost()+ $tax_amount, 2); 211 228 $shipping_method_count++; 212 229 } 213 230 } else if(WC()->cart->get_tax_totals()){ 214 231 foreach (WC()->cart->get_tax_totals() as $tax) { 215 $tax_amount = $tax->amount + $tax_amount; 232 $tax_amount = $tax->amount + $tax_amount; 216 233 } 217 234 $shipping_data[0]['carrier_code'] = ''; -
payu-india/trunk/includes/class-wc-gateway-payu.php
r3171075 r3186417 29 29 protected $site_url; 30 30 protected $dynamic_charges_flag; 31 32 protected $_skuWiseTotal = 0; 31 33 32 34 … … 153 155 $this->manage_session(); //Update cookies with samesite 154 156 $thankyou_msg = 'Thank you for your order, please wait as you will be automatically redirected to PayUBiz.'; 155 echo '<p>' . esc_html ($thankyou_msg, 'payubiz') . '</p>';157 echo '<p>' . esc_html__($thankyou_msg, 'payubiz') . '</p>'; 156 158 echo $this->generatePayubizForm($order); 157 159 } … … 285 287 $redirect_url = add_query_arg('wc-api', get_class($this), $redirect_url); 286 288 WC()->session->set('orderid_awaiting_payubiz', $order_id); 287 //$txnid = $order_id . '_' . date("ymd") . ':' . random_int(1, 100); 288 $txnid = $order_id . '_' . gmdate("ymd") . '_' . random_int(1, 100); 289 $txnid = $order_id . '_' . date("ymd") . '_' . random_int(1, 100); 289 290 update_post_meta($order_id, 'order_txnid', $txnid); 290 291 … … 294 295 //get currency 295 296 $address = sanitize_text_field($order->billing_address_1); { 296 $address = $address . ' ' . sanitize_text_field($order->billing_address_2);297 $address = $address . ' ' . sanitize_text_field($order->billing_address_2); 297 298 } 298 299 … … 309 310 $action = esc_url(PAYU_HOSTED_PAYMENT_URL_UAT); 310 311 } 311 312 $order_subtotal = sanitize_text_field($order->get_subtotal()); 313 $amount = $this->checkout_express=='checkout_express'?$order_subtotal:sanitize_text_field($order->order_total); 312 /**Disable & enable shipping charges.**/ 313 $plugin_data = get_option('woocommerce_payubiz_settings'); 314 $payu_dynamic_charges_flag = $plugin_data['dynamic_charges_flag']; 315 $order_subtotal = sanitize_text_field($order->get_subtotal()); 316 $order_total_tax = sanitize_text_field($order->order_total); 317 if($payu_dynamic_charges_flag=="no"){ 318 $amount = $this->checkout_express=='checkout_express'?$order_total_tax:sanitize_text_field($order->order_total); 319 } 320 else{ 321 $amount = $this->checkout_express=='checkout_express'?$order_subtotal:sanitize_text_field($order->order_total); 322 } 314 323 $amount=number_format($amount,2); 315 324 $amount=str_replace(",", "", $amount); 325 //echo $amount; exit; 316 326 $firstname = sanitize_text_field($order->billing_first_name); 317 327 $lastname = sanitize_text_field($order->billing_last_name); … … 388 398 $ramdom_str = bin2hex($random_bytes); 389 399 $c_date = gmdate('D, d M Y H:i:s T'); 400 //$tax_info_data=$order->order_total-$order->get_subtotal(); 401 $tax_info_data=WC()->cart->get_total_tax(); 402 //$tax_info_data=round($tax_info_data, 2); 403 $taxinfo=array( 404 'breakup'=>array( 405 'Standard' => "$tax_info_data" 406 ), 407 'total'=> "$tax_info_data" 408 ); 409 410 $order_amount = 0; 411 if($payu_dynamic_charges_flag=="no"){ 412 if(wc_prices_include_tax()){ 413 $taxinfo=NULL; 414 $order_amount = $order->order_total; 415 416 }else{ 417 $taxinfo=$taxinfo; 418 $order_amount = $order->get_subtotal(); 419 } 420 421 } else { 422 $taxinfo=NULL; 423 $order_amount = $order->get_subtotal(); 424 } 390 425 426 427 if($payu_dynamic_charges_flag=="yes" && wc_prices_include_tax()){ 428 $order_amount = $order->order_total; 429 $amount = $order->order_total; 430 } 391 431 $amount=str_replace(",", "", $amount); 432 392 433 $data_array = array( 393 434 'key' => $payu_key, … … 421 462 'cod_fee' => 0, // cash on delivery fee. 422 463 'other_charges' => NULL, 423 'tax_info' => NULL, 464 'tax_info' => $taxinfo, 465 424 466 ), 425 467 'cart_details' => array( 426 'amount' => $order_ subtotal,468 'amount' => $order_amount, 427 469 'items' => (string)$item_count, 428 470 'sku_details' => $sku_details_array, … … 446 488 $productInfo = ''; 447 489 $logo = 'https://payu.in/demo/checkoutExpress/utils/images/MicrosoftTeams-image%20(31).png'; 490 448 491 foreach ($order->get_items() as $item) { 492 $variation_id = $item->get_variation_id(); 493 $_product = new WC_Product_Variation($variation_id); 494 $single_sku_price=$_product->get_price(); 495 $single_sku_name=$_product->get_name(); 496 $single_sku=$_product->get_sku(); 497 $single_sku=($single_sku!="") ? $single_sku : $variation_id; 498 $single_sku_price=str_replace(",", "", $single_sku_price); 449 499 $product = wc_get_product($item->get_product_id()); 450 500 $productInfo .= $product->get_sku() . ':'; 451 501 $amount_per_sku=(string)number_format($product->get_price(), 2); 452 502 $amount_per_sku=str_replace(",", "", $amount_per_sku); 453 $sku_details_array[] = array( 503 if($variation_id==0){ 504 $sku_id=($product->get_sku()!="") ? $product->get_sku():$product->get_id(); 505 $amount_per_sku=$amount_per_sku; 506 $product_name=$product->get_name(); 507 } 508 else{ 509 $sku_id=$single_sku; 510 $amount_per_sku=$single_sku_price; 511 $product_name=$single_sku_name; 512 } 513 $sku_details_array[] = array( 454 514 'offer_key' => array(), 455 515 'amount_per_sku' => $amount_per_sku, 456 516 'quantity' => (string)$item->get_quantity(), 457 //'sku_id' => $product->get_sku(), 458 'sku_id' => ($product->get_sku()!="") ? $product->get_sku():$product->get_id(), 459 'sku_name' => $product->get_name(), 517 'sku_id' => $sku_id, 518 'sku_name' => $product_name, 460 519 'logo' => $logo 461 ); 520 ); 462 521 } 463 522 … … 510 569 </form> 511 570 "; 512 $data = wp_json_encode($requestArr, JSON_UNESCAPED_SLASHES);571 $data = json_encode($requestArr, JSON_UNESCAPED_SLASHES); 513 572 $javascriptCode = <<<EOD 514 573 <script type='text/javascript'> … … 543 602 $payu_key = $this->currency1_payu_key; 544 603 $payu_salt = $this->currency1_payu_salt; 545 $data_array_json = wp_json_encode($data_array, JSON_UNESCAPED_SLASHES);604 $data_array_json = json_encode($data_array, JSON_UNESCAPED_SLASHES); 546 605 $v2hash = hash('sha512', $data_array_json . "|" . $c_date . "|" . $payu_salt); 547 606 $username = "hmac username=\"$payu_key\""; … … 567 626 $redirect_url = $args_express_checkout['redirect_url']; 568 627 $payu_payment_nonce = $args_express_checkout['payu_payment_nonce']; 569 $data_array_json = $args_express_checkout['data_array_json'];628 $data_array_json = json_encode($args_express_checkout['data_array_json']); 570 629 $c_date = $args_express_checkout['c_date']; 571 630 $auth_header_string = $args_express_checkout['auth_header_string']; … … 580 639 function handleSubmit() { 581 640 const expressRequestObj = { 582 data: '$data_array_json',641 data: $data_array_json, 583 642 date: '$c_date', 584 643 isCheckoutExpress: true, … … 587 646 var handlers = { 588 647 responseHandler: function (BOLT) { 589 console.log('response from payu'); 648 console.log('response from payu'); 649 console.log(BOLT.response.amount); 650 console.log(JSON.stringify(BOLT.response)); 651 590 652 if (BOLT.response.txnStatus == 'FAILED') { 591 653 alert('Payment failed. Please try again.'); … … 661 723 return false; 662 724 } 663 664 665 666 725 }
Note: See TracChangeset
for help on using the changeset viewer.