Plugin Directory

Changeset 3200279


Ignore:
Timestamp:
12/01/2024 04:21:25 PM (16 months ago)
Author:
devcashfree
Message:

Update to version 4.7.6

Location:
cashfree
Files:
30 added
4 edited

Legend:

Unmodified
Added
Removed
  • cashfree/trunk/cashfree.php

    r3198819 r3200279  
    1212 * Domain Path: /languages
    1313 * Requires at least: 4.4
    14  * Tested up to: 6.7
     14 * Tested up to: 6.6
    1515 * WC requires at least: 3.0
    16  * WC tested up to: 9.4
     16 * WC tested up to: 9.2
    1717 *
    1818 *
  • cashfree/trunk/includes/http/class-wc-cashfree-adapter.php

    r3198819 r3200279  
    6969        if ( $http_code === 200 ) {
    7070            $cf_order = json_decode( wp_remote_retrieve_body( $response ) );
    71 
    72             // Check if the order has already been paid for.
    73             if ( $cf_order->order_status === 'PAID' ) {
     71            if ( $cf_order->order_status === 'PAID'  ||  $cf_order->order_status === 'EXPIRED' ) {
    7472                throw new Exception( 'Please reach out to the support team' );
    7573            }
  • cashfree/trunk/includes/request/class-wc-cashfree-request-checkout.php

    r3198819 r3200279  
    6464                'pincode'           => $postCode,
    6565                'cart_items'            => array_map(
    66                     function( $item ) use ( $order ) {
    67                         return WC_Cashfree_Request_Item::build( $order, $item );
     66                    function( $item ) {
     67                        return WC_Cashfree_Request_Item::build( $item );
    6868                    },
    6969                    array_values( $order->get_items() )
     
    7171            )
    7272        );
     73        return $data;
     74    }
    7375
    74         return $data;
     76    private static function get_valid_cart_items( $order ) {
     77        $filtered_items = array_filter(
     78            $order->get_items(),
     79            function( $item ) {
     80                return $item->get_product(); // Only include valid products
     81            }
     82        );
     83   
     84        return array_map(
     85            function( $item ) use ( $order ) {
     86                return WC_Cashfree_Request_Item::build( $order, $item );
     87            },
     88            $filtered_items
     89        );
    7590    }
    7691
  • cashfree/trunk/includes/request/class-wc-cashfree-request-items.php

    r3198819 r3200279  
    1919     * @return array
    2020     */
    21     public static function build( $order, $item ) {
    22         require_once WC_CASHFREE_DIR_PATH . 'includes/request/class-wc-cashfree-request-checkout.php';
    23         $product = $item->get_product();
     21    public static function build( $item ) {
    2422        return array(
    25             'item_id'                   => substr( $item->get_variation_id() ? $item->get_variation_id() : $item->get_product_id(), 0, 254 ),
    2623            'item_name'                 => mb_convert_encoding(substr( $item->get_name(), 0, 254 ), 'UTF-8', 'UTF-8'),
    27             'item_description'          => mb_convert_encoding(substr( $product->get_description(), 0, 499 ), 'UTF-8', 'UTF-8'),
    28             "tags"                      => [],
    29             'item_details_url'          => get_permalink( $item->get_product_id() ),
    30             'item_image_url'            => (string) wp_get_attachment_image_url( $product->get_image_id(), 'full' ),
    31             'item_original_unit_price'  => self::cfConvertToNumber($product->get_regular_price() ? $product->get_regular_price() : 0),
    32             'item_discounted_unit_price'=> self::cfConvertToNumber($product->get_price() ? $product->get_price() : 0),
     24            'item_original_unit_price'  => self::cfConvertToNumber($item->get_total() ? $item->get_total() : 0),
    3325            'item_quantity'             => $item->get_quantity(),
    34             'item_currency'             =>  $order->get_currency()
    3526        );
    3627    }
Note: See TracChangeset for help on using the changeset viewer.