Plugin Directory

Changeset 2879753


Ignore:
Timestamp:
03/14/2023 12:06:09 PM (3 years ago)
Author:
chaifinport
Message:

if amount total doesn't match then ignore items

Location:
chaiport-payment/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • chaiport-payment/trunk/chaiportGateway.php

    r2860347 r2879753  
    44 * Plugin URI:        https://www.docs.portone.cloud/plugins_and_sdks/woocommerce-plugin.html
    55 * Description:       Single Payment
    6  * Version:           2.0.2
     6 * Version:           2.0.3
    77 * Requires at least: 5.6
    88 * Author:            PortOne
     
    111111            "sub" => $publicKey,
    112112            "iat" => time(),
    113             "exp" => time() + 100
     113            "exp" => time() + 500
    114114        );
    115115        $payload = json_encode($encodeData);
     
    256256 */
    257257add_action('rest_api_init', function () {
    258     register_rest_route('chaiport/v1', 'redirect', array(
     258    register_rest_route('portone/', 'redirect', array(
    259259        'methods' => WP_REST_Server::READABLE,
    260260        'permission_callback' => '__return_true',
     
    292292        'callback' => 'chaiport_order_manage_webhook'
    293293    ));
     294    register_rest_route('portone/', 'webhook', array(
     295        'methods' => WP_REST_Server::CREATABLE,
     296        'permission_callback' => '__return_true',
     297        'callback' => 'chaiport_order_manage_webhook'
     298    ));
    294299});
    295300
     
    471476
    472477            $websiteUrl = get_bloginfo('url');
    473             $webhookUrl = $websiteUrl . "/wp-json/chaiport/v1/webhook";
     478            $webhookUrl = $websiteUrl . "/wp-json/portone/webhook";
    474479
    475480            $this->id = 'chaiport'; //payment gateway plugin ID
     
    540545
    541546            $websiteUrl = get_bloginfo('url');
    542             $webhookUrl = $websiteUrl . "/wp-json/chaiport/v1/webhook";
     547            $webhookUrl = $websiteUrl . "/wp-json/portone/webhook";
    543548
    544549            $this->form_fields = array(
     
    692697
    693698            $websiteUrl = get_bloginfo('url');
    694             $red = $websiteUrl . "/wp-json/chaiport/v1/redirect";
     699            $red = $websiteUrl . "/wp-json/portone/redirect";
    695700
    696701            $amount = $order->get_total();
     
    711716            // Get and Loop Over Order Items
    712717            $discount_total = 0;
     718            $item_total = 0;
    713719            foreach ($order->get_items() as $item_id => $item) {
    714720                $order_item_id = $item->get_id();
     
    728734                    $discount_total += $discount;
    729735                }
     736                $item_total += ((float)$product->get_regular_price()*$item->get_quantity());
    730737                array_push($itemsArray, $temp);
    731738            }
     
    749756                "promo_discount" => $discount_total
    750757            );
     758
     759            $this->console_log("Environment is: " . $environment, '');
     760            if ($amount != ((float)$order->get_shipping_total() + $item_total - $discount_total)) {
     761                $this->console_log("Not sending item details", '');
     762                $isItemsAvailable = false;
     763            } else {
     764                $this->console_log("Total amount is: " . $amount, '');
     765                $this->console_log("Items total is: " . $item_total, '');
     766                $this->console_log("Shipping amount is: " . (float)$order->get_shipping_total(), '');
     767                $this->console_log("Discount is: " . $discount_total, '');
     768            }
    751769
    752770            $countryCode = $order->get_billing_country();
  • chaiport-payment/trunk/readme.txt

    r2860347 r2879753  
    44Requires at least: 3.9.2
    55Tested up to: 6.1.1
    6 Stable tag: 2.0.2
     6Stable tag: 2.0.3
    77Requires PHP: 5.6
    88License: GPLv2 or later
Note: See TracChangeset for help on using the changeset viewer.