Plugin Directory

Changeset 2851789


Ignore:
Timestamp:
01/20/2023 10:47:50 AM (3 years ago)
Author:
chaifinport
Message:

handling items with 0 price

Location:
chaiport-payment/trunk
Files:
2 edited

Legend:

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

    r2823329 r2851789  
    44 * Plugin URI:        https://www.docs.chaiport.io/plugins_and_sdks/woocommerce-plugin.html
    55 * Description:       Single Payment
    6  * Version:           1.0.6
     6 * Version:           1.0.7
    77 * Requires at least: 5.6
    88 * Author:            Chai Finance
     
    731731            }
    732732
     733            $isItemsAvailable = true;
     734            foreach ($itemsArray as $item) {
     735                if ($item["price"] == 0) {
     736                    $isItemsAvailable = false;
     737                    break;
     738                }
     739            }
     740
    733741            $custom_logo_id = get_theme_mod('custom_logo');
    734742            $image = wp_get_attachment_image_src($custom_logo_id, 'full');
     
    770778            $billingShippingArray = $this->getBillingShippingInfo($order);
    771779
    772             $reqObj = array(
    773                 "chaipay_key" => "$publicKey",
    774                 "merchant_details" => $merchantObj,
    775                 "merchant_order_id" => "$merchantOrder",
    776                 "signature_hash" => "$signature",
    777                 "amount" => (float)$amount,
    778                 "currency" => "$currencyCode",
    779                 "description" => "Your order-id is: $merchantOrder",
    780                 "order_details" => $itemsArray,
    781                 "billing_details" => $billingShippingArray[0],
    782                 "shipping_details" => $billingShippingArray[1],
    783                 "success_url" => "$red",
    784                 "failure_url" => "$red",
    785                 "country_code" => $countryCode,
    786                 "expiry_hours" => 96,
    787                 "is_checkout_embed" => false,
    788                 "show_shipping_details" => $this->getOptionBool('show_shipping_details'),
    789                 "show_back_button" => $this->getOptionBool('show_back_button'),
    790                 "default_guest_checkout" => $this->getOptionBool('default_guest_checkout'),
    791                 "environment" => $environment
    792             );
     780            if ($isItemsAvailable) {
     781                $reqObj = array(
     782                    "chaipay_key" => "$publicKey",
     783                    "merchant_details" => $merchantObj,
     784                    "merchant_order_id" => "$merchantOrder",
     785                    "signature_hash" => "$signature",
     786                    "amount" => (float)$amount,
     787                    "currency" => "$currencyCode",
     788                    "description" => "Your order-id is: $merchantOrder",
     789                    "order_details" => $itemsArray,
     790                    "billing_details" => $billingShippingArray[0],
     791                    "shipping_details" => $billingShippingArray[1],
     792                    "success_url" => "$red",
     793                    "failure_url" => "$red",
     794                    "country_code" => $countryCode,
     795                    "expiry_hours" => 96,
     796                    "is_checkout_embed" => false,
     797                    "show_shipping_details" => $this->getOptionBool('show_shipping_details'),
     798                    "show_back_button" => $this->getOptionBool('show_back_button'),
     799                    "default_guest_checkout" => $this->getOptionBool('default_guest_checkout'),
     800                    "environment" => $environment,
     801                    "source" => "woocommerce"
     802                );
     803            } else {
     804                $reqObj = array(
     805                    "chaipay_key" => "$publicKey",
     806                    "merchant_details" => $merchantObj,
     807                    "merchant_order_id" => "$merchantOrder",
     808                    "signature_hash" => "$signature",
     809                    "amount" => (float)$amount,
     810                    "currency" => "$currencyCode",
     811                    "description" => "Your order-id is: $merchantOrder",
     812                    "billing_details" => $billingShippingArray[0],
     813                    "shipping_details" => $billingShippingArray[1],
     814                    "success_url" => "$red",
     815                    "failure_url" => "$red",
     816                    "country_code" => $countryCode,
     817                    "expiry_hours" => 96,
     818                    "is_checkout_embed" => false,
     819                    "show_shipping_details" => $this->getOptionBool('show_shipping_details'),
     820                    "show_back_button" => $this->getOptionBool('show_back_button'),
     821                    "default_guest_checkout" => $this->getOptionBool('default_guest_checkout'),
     822                    "environment" => $environment,
     823                    "source" => "woocommerce"
     824                );
     825            }
    793826
    794827            $token = $this->ChaiportGenerateJwtToken($publicKey, $secretKey);
  • chaiport-payment/trunk/readme.txt

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