Plugin Directory

Changeset 3130950


Ignore:
Timestamp:
08/05/2024 10:30:00 AM (20 months ago)
Author:
SplitIt
Message:

release version 4.1.9

Location:
splitit-installment-payments
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • splitit-installment-payments/trunk/CHANGELOG.md

    r3114779 r3130950  
    33All notable changes to this project will be documented in this file
    44-
     5
     6### 4.1.9
     7* Improvements in the refund process
    58
    69### 4.1.8
  • splitit-installment-payments/trunk/assets/css/admin.css

    r2948745 r3130950  
    13411341    color: #00443c !important;
    13421342    font-family: Avenir, sans-serif !important;
     1343    display: flex;
     1344    justify-content: center;
     1345    align-items: center;
     1346    text-align: center;
    13431347}
    13441348.css-block-button:hover,
  • splitit-installment-payments/trunk/classes/class-splitit-flexfields-payment-plugin-settings.php

    r3110521 r3130950  
    9595                    'css'     => 'width: 420px; margin-bottom: 1px;',
    9696                    'default' => '',
     97                    'desc_tip' => false,
    9798                    'options' => self::refund_strategy_selection(),
    9899                ),
  • splitit-installment-payments/trunk/readme.txt

    r3114779 r3130950  
    66WC requires at least: 5.5
    77WC tested up to: 8.8.2
    8 Stable tag: 4.1.8
     8Stable tag: 4.1.9
    99License: GPLv3
    1010License URI: http://www.gnu.org/licenses/gpl-3.0.html
     
    6161
    6262== Changelog ==
     63
     64= 4.1.9 - 2024-08-05 =
     65Improvements in the refund process
    6366
    6467= 4.1.8 - 2024-07-09 =
  • splitit-installment-payments/trunk/splitIt-flexfields-payment-gateway.php

    r3114779 r3130950  
    1010 * Author: Splitit
    1111 * Author URI: https://www.splitit.com/
    12  * Version: 4.1.8
     12 * Version: 4.1.9
    1313 */
    1414
     
    2424
    2525global $plugin_version;
    26 $plugin_version = '4.1.8';
     26$plugin_version = '4.1.9';
    2727
    2828global $required_splitit_php_version;
     
    400400
    401401            add_action( 'parse_request', array( $this, 'splitit_custom_url_handler' ) );
     402
     403            add_action('woocommerce_create_refund', array( $this, 'handle_create_refund' ), 10, 2);
    402404        }
    403405
     
    574576            wc_add_notice( __( 'Something went wrong, please try to place an order again.', 'splitit_ff_payment' ), 'error' );
    575577            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));
    576614        }
    577615
     
    836874                echo curl_error( $curl );
    837875                echo 'Failed';
    838             } elseif ( json_decode( $response )->error ) {
     876            } elseif ( property_exists( json_decode( $response ), 'error' ) ) {
    839877                echo 'Error:<br />';
    840878                echo $response;
     
    15301568                        $terminal_id = $_POST['terminal_id'];
    15311569                        $merchant_id = $_POST['merchant_id'];
    1532                         $client_id   = $_POST['client_id'];
     1570                        $client_id   = $_POST['client_id'] ?? null;
    15331571
    15341572                        if ( !session_id() ) { session_start(); }
     
    45934631
    45944632                                                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
    45954661                                                    $refund = wc_create_refund(
    45964662                                                        array(
     
    45994665                                                            'order_id'       => $order_id,
    46004666                                                            'refund_payment' => true,
     4667                                                            'line_items'     => $line_items,
    46014668                                                        )
    46024669                                                    );
     
    46114678                                                        }
    46124679                                                    } else {
     4680                                                        delete_option($option_name);
    46134681                                                        $order->add_order_note( 'A refund for the amount = ' . $amount . ' has succeeded on the Splitit side.' );
    46144682                                                        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.