Changeset 3130950
- Timestamp:
- 08/05/2024 10:30:00 AM (20 months ago)
- Location:
- splitit-installment-payments
- Files:
-
- 1 added
- 5 edited
-
tags/4.1.9 (added)
-
trunk/CHANGELOG.md (modified) (1 diff)
-
trunk/assets/css/admin.css (modified) (1 diff)
-
trunk/classes/class-splitit-flexfields-payment-plugin-settings.php (modified) (1 diff)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/splitIt-flexfields-payment-gateway.php (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
splitit-installment-payments/trunk/CHANGELOG.md
r3114779 r3130950 3 3 All notable changes to this project will be documented in this file 4 4 - 5 6 ### 4.1.9 7 * Improvements in the refund process 5 8 6 9 ### 4.1.8 -
splitit-installment-payments/trunk/assets/css/admin.css
r2948745 r3130950 1341 1341 color: #00443c !important; 1342 1342 font-family: Avenir, sans-serif !important; 1343 display: flex; 1344 justify-content: center; 1345 align-items: center; 1346 text-align: center; 1343 1347 } 1344 1348 .css-block-button:hover, -
splitit-installment-payments/trunk/classes/class-splitit-flexfields-payment-plugin-settings.php
r3110521 r3130950 95 95 'css' => 'width: 420px; margin-bottom: 1px;', 96 96 'default' => '', 97 'desc_tip' => false, 97 98 'options' => self::refund_strategy_selection(), 98 99 ), -
splitit-installment-payments/trunk/readme.txt
r3114779 r3130950 6 6 WC requires at least: 5.5 7 7 WC tested up to: 8.8.2 8 Stable tag: 4.1. 88 Stable tag: 4.1.9 9 9 License: GPLv3 10 10 License URI: http://www.gnu.org/licenses/gpl-3.0.html … … 61 61 62 62 == Changelog == 63 64 = 4.1.9 - 2024-08-05 = 65 Improvements in the refund process 63 66 64 67 = 4.1.8 - 2024-07-09 = -
splitit-installment-payments/trunk/splitIt-flexfields-payment-gateway.php
r3114779 r3130950 10 10 * Author: Splitit 11 11 * Author URI: https://www.splitit.com/ 12 * Version: 4.1. 812 * Version: 4.1.9 13 13 */ 14 14 … … 24 24 25 25 global $plugin_version; 26 $plugin_version = '4.1. 8';26 $plugin_version = '4.1.9'; 27 27 28 28 global $required_splitit_php_version; … … 400 400 401 401 add_action( 'parse_request', array( $this, 'splitit_custom_url_handler' ) ); 402 403 add_action('woocommerce_create_refund', array( $this, 'handle_create_refund' ), 10, 2); 402 404 } 403 405 … … 574 576 wc_add_notice( __( 'Something went wrong, please try to place an order again.', 'splitit_ff_payment' ), 'error' ); 575 577 return; 578 } 579 580 public function handle_create_refund($refund, $order) { 581 global $wpdb; 582 583 SplitIt_FlexFields_Payment_Plugin_Log::log_to_file('$order: ' . json_encode($order)); 584 585 $refund_id = $refund->get_id(); 586 $order_id = $order['order_id']; 587 $refund_amount = $refund->get_amount(); 588 $items = $refund->get_items(); 589 590 $refund_data = array(); 591 592 foreach ($items as $item_id => $item) { 593 594 SplitIt_FlexFields_Payment_Plugin_Log::log_to_file('$item->get_name(): ' . $item->get_name()); 595 SplitIt_FlexFields_Payment_Plugin_Log::log_to_file('$item->get_meta_data(): ' . json_encode($item->get_meta_data())); 596 SplitIt_FlexFields_Payment_Plugin_Log::log_to_file('$item->get_meta(_refunded_item_id): ' . json_encode($item->get_meta('_refunded_item_id'))); 597 598 $name = $item->get_name(); 599 $refunded_item_id = $item->get_meta('_refunded_item_id'); 600 $qty = $item->get_quantity(); 601 $refund_total = $item->get_total(); 602 $refund_tax = array_map('wc_format_decimal', $item->get_taxes()['total']); 603 604 $refund_data[] = array( 605 'item_id' => $refunded_item_id, 606 'qty' => $qty, 607 'refund_total' => $refund_total, 608 'refund_tax' => $refund_tax, 609 ); 610 } 611 612 $option_name = 'splitit_refund_data_' . $order_id; 613 update_option($option_name, json_encode($refund_data)); 576 614 } 577 615 … … 836 874 echo curl_error( $curl ); 837 875 echo 'Failed'; 838 } elseif ( json_decode( $response )->error) {876 } elseif ( property_exists( json_decode( $response ), 'error' ) ) { 839 877 echo 'Error:<br />'; 840 878 echo $response; … … 1530 1568 $terminal_id = $_POST['terminal_id']; 1531 1569 $merchant_id = $_POST['merchant_id']; 1532 $client_id = $_POST['client_id'] ;1570 $client_id = $_POST['client_id'] ?? null; 1533 1571 1534 1572 if ( !session_id() ) { session_start(); } … … 4593 4631 4594 4632 if ( $order->get_remaining_refund_amount() >= $amount ) { 4633 4634 $option_name = 'splitit_refund_data_' . $order_id; 4635 $refund_data_json = get_option($option_name); 4636 4637 $line_items = array(); 4638 4639 if ($refund_data_json) { 4640 $refund_data = json_decode($refund_data_json, true); 4641 if ($refund_data) { 4642 foreach ($order->get_items() as $item_id => $item) { 4643 foreach ($refund_data as $refund_item) { 4644 SplitIt_FlexFields_Payment_Plugin_Log::log_to_file( '$item_id: ' . $item_id); 4645 SplitIt_FlexFields_Payment_Plugin_Log::log_to_file( '$refund_item: ' . json_encode($refund_item)); 4646 if ($refund_item['item_id'] == $item_id) { 4647 $line_items[$item_id] = array( 4648 'qty' => $refund_item['qty'], 4649 'refund_total' => $refund_item['refund_total'], 4650 'refund_tax' => $refund_item['refund_tax'], 4651 ); 4652 break; 4653 } 4654 } 4655 } 4656 } 4657 } 4658 4659 SplitIt_FlexFields_Payment_Plugin_Log::log_to_file( 'line_items_for_order_id_' . $order_id . '_refund_id_' . $refund_id . ': ' . json_encode( $line_items ) ); 4660 4595 4661 $refund = wc_create_refund( 4596 4662 array( … … 4599 4665 'order_id' => $order_id, 4600 4666 'refund_payment' => true, 4667 'line_items' => $line_items, 4601 4668 ) 4602 4669 ); … … 4611 4678 } 4612 4679 } else { 4680 delete_option($option_name); 4613 4681 $order->add_order_note( 'A refund for the amount = ' . $amount . ' has succeeded on the Splitit side.' ); 4614 4682 SplitIt_FlexFields_Payment_Plugin_Log::log_to_file( 'Refund success. Amount: ' . $amount . ', Order ID: ' . $order_id . ' Refund ID: ' . $order_refund_id . ', ipn = ' . $ipn );
Note: See TracChangeset
for help on using the changeset viewer.