Plugin Directory

Changeset 3126058


Ignore:
Timestamp:
07/26/2024 03:28:39 PM (20 months ago)
Author:
ecommpay
Message:

new version 3.4.4

Location:
ecommpay-payments/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • ecommpay-payments/trunk/common/class-ecp-core.php

    r3090882 r3126058  
    4343     * @since 2.0.0
    4444     */
    45     const WC_ECP_VERSION = '3.4.3';
     45    const WC_ECP_VERSION = '3.4.4';
    4646    // endregion
    4747
  • ecommpay-payments/trunk/common/includes/class-ecp-gateway-callbacks.php

    r3054258 r3126058  
    249249    private function complete_order(Ecp_Gateway_Info_Callback $callback, Ecp_Gateway_Order $order)
    250250    {
    251         $is_amount_equal = (string) $callback['payment']['sum']['amount'] === (string) str_replace('.', '', $order->get_total());
    252         $is_currency_equal = $callback['payment']['sum']['currency'] === $order->get_currency();
    253 
    254         if ($is_amount_equal && $is_currency_equal) {
    255             ecp_get_log()->debug(__('Run success process.', 'woo-ecommpay'), $order->get_id());
    256             $order->payment_complete($callback->get_operation()->get_request_id());
    257             ecp_get_log()->debug(__('Success process completed.', 'woo-ecommpay'), $order->get_id());
    258         } else {
    259             $order->add_order_note(
    260                 __('The payment amount does not match the order amount. The order is on hold.', 'woo-ecommpay')
     251        $order_currency = $order->get_currency_uppercase();
     252        $payment_currency = $callback->get_payment_currency();
     253
     254        $is_amount_equal = $order->get_total_minor() === $callback->get_payment_amount_minor();
     255        $is_currency_equal = $order_currency === $payment_currency;
     256
     257        ecp_get_log()->debug(__('Run success process.', 'woo-ecommpay'), $order->get_id());
     258        $order->payment_complete($callback->get_operation()->get_request_id());
     259        ecp_get_log()->debug(__('Success process completed.', 'woo-ecommpay'), $order->get_id());
     260
     261        if (!$is_amount_equal || !$is_currency_equal) {
     262            $message = sprintf(
     263                'The payment amount does not match the order amount. The order has %s %s. The payment has %s %s',
     264                $order->get_total(), $order_currency, $callback->get_payment_amount(), $payment_currency
    261265            );
    262             $this->hold_order($callback, $order);
    263             return;
     266            $order->add_order_note(__($message, 'woo-ecommpay'));
    264267        }
    265268    }
  • ecommpay-payments/trunk/common/includes/trait-ecp-gateway-order-extension.php

    r3054258 r3126058  
    199199        return $meta;
    200200    }
     201
     202    public function get_currency_uppercase(): string
     203    {
     204        return strtoupper($this->get_currency());
     205    }
     206
     207    public function get_total_minor(): int
     208    {
     209        return ecp_price_multiply($this->get_total(), $this->get_currency());
     210    }
    201211}
  • ecommpay-payments/trunk/common/models/class-ecp-gateway-info-callback.php

    r2888278 r3126058  
    256256    }
    257257
     258    public function get_payment_sum(): ?Ecp_Gateway_Json
     259    {
     260        $payment = $this->get_payment();
     261        return $payment ? $payment->get_sum() : null;
     262    }
     263
     264    public function get_payment_amount_minor(): ?int
     265    {
     266        $payment_sum = $this->get_payment_sum();
     267        return $payment_sum ? $payment_sum->get_amount() : null;
     268    }
     269
     270    public function get_payment_amount(): ?float
     271    {
     272        $payment_amount_minor = $this->get_payment_amount_minor();
     273        $currency = $this->get_payment_currency();
     274        if (!$payment_amount_minor || !$currency) {
     275            return null;
     276        }
     277        return ecp_price_multiplied_to_float($payment_amount_minor, $currency);
     278    }
     279
     280    public function get_payment_currency(): ?string
     281    {
     282        if (!$payment_sum = $this->get_payment_sum()) {
     283            return null;
     284        }
     285        $currency = $payment_sum->get_currency();
     286        return $currency ? strtoupper($currency) : null;
     287    }
     288
    258289    /**
    259290     * @inheritDoc
  • ecommpay-payments/trunk/gateway-ecommpay.php

    r3090882 r3126058  
    55 * GitHub Plugin URI:
    66 * Description:       Easy payment from WooCommerce by different methods in single Payment Page.
    7  * Version:           3.4.3
     7 * Version:           3.4.4
    88 * License:           GPL2
    99 * License URI:       https://www.gnu.org/licenses/gpl-2.0.html
  • ecommpay-payments/trunk/readme.txt

    r3090882 r3126058  
    44Requires at least: 4.0.0
    55Tested up to: 6.4
    6 Stable tag: 3.4.3
     6Stable tag: 3.4.4
    77License: GPLv2
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
Note: See TracChangeset for help on using the changeset viewer.