Plugin Directory

Changeset 2690001


Ignore:
Timestamp:
03/07/2022 01:39:17 PM (4 years ago)
Author:
bsecuretech
Message:

Released General Update, New Feature (PIM) and Bug Fixes

Location:
bsecure/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • bsecure/trunk/bsecure.php

    r2688113 r2690001  
    66 * Author: bSecure
    77 * Author URI:
    8  * Version: 1.6.4
     8 * Version: 1.6.5
    99 *
    1010 */
  • bsecure/trunk/includes/class-bsecure-checkout.php

    r2688113 r2690001  
    143143    add_action('woocommerce_add_to_cart', array($this, 'bsecure_custom_add_to_cart' ));
    144144   
    145     add_filter('woocommerce_rest_prepare_product_object', array($this,'custom_product_api_response'), 10, 3);   
     145    add_filter('woocommerce_rest_prepare_product_object', array($this,'custom_product_api_response'), 10, 3);
     146
     147    // trigger when wc order status changed
     148        add_action( 'woocommerce_order_status_changed', array($this,'bsecure_action_woocommerce_order_status_changed'), 10, 1 );
    146149
    147150    }   
     
    346349                    $bsecure_order_id = !empty($bsecure_order_id) ? $bsecure_order_id : $order->get_id();
    347350
     351                    $this->bsecure_action_woocommerce_order_status_changed($order->get_id());
     352
    348353                    $return_json = ['status' => true, 'msg' => __("Order status updated successfully.", 'wc-bsecure'),'bsecure_order_id' => $bsecure_order_id];                 
    349354
     
    383388                                }
    384389
     390                                $this->bsecure_action_woocommerce_order_status_changed($order->get_id());
     391                               
    385392                                $return_json = ['status' => true, 'msg' => $msg, 'bsecure_order_id' => $bsecure_order_id];
    386393
     
    28992906    }
    29002907
     2908    /**
     2909     * The function used when order status changes at woocommerce
     2910     * Send webhook response to bsecure server
     2911     */
     2912
     2913    public function bsecure_action_woocommerce_order_status_changed($order_id){
     2914       
     2915        $order = wc_get_order($order_id);
     2916        $store_id = get_option('wc_bsecure_store_id', '');
     2917        $base_url = get_option('wc_bsecure_base_url', '');
     2918        $request_data = ["order_id" => $order_id, 'store_slug' => $store_id];
     2919        $webhook_endpoint = '/webhook/pim/order-created';
     2920         
     2921        $webhook_url = $base_url.$webhook_endpoint;     
     2922
     2923        if(!empty($order->get_items())){
     2924            foreach ($order->get_items() as $order_item_id => $order_item) {
     2925
     2926                        $productInfo = ($order_item->get_data());
     2927
     2928                        $product_id = !empty($productInfo['variation_id']) ? $productInfo['variation_id'] : $productInfo['product_id'];
     2929
     2930                        $request_data["line_items"][] = [
     2931                                                                                            'product_id' => $productInfo['product_id'],
     2932                                                                                            'variant_id' => $productInfo['variation_id']
     2933                                                                                        ];
     2934
     2935            }
     2936        }
     2937
     2938
     2939        if($order->get_status() == Bsecure_Checkout::STATUS_PROCESSING && get_option('wc_bsecure_is_active', 'no') == 'yes'){
     2940
     2941            $response = $this->bsecureGetOauthToken();     
     2942
     2943            $validateResponse = $this->validateResponse($response,'token_request');     
     2944
     2945            if( $validateResponse['error'] ){           
     2946
     2947                status_header( 422 );
     2948
     2949                die('Response Error: '.$validateResponse['msg']);           
     2950
     2951            }else{                 
     2952
     2953                $headers =   $this->getApiHeaders($response->access_token);
     2954
     2955                $params =   [
     2956
     2957                            'method' => 'POST',
     2958                            'body' => $request_data,
     2959                            'headers' => $headers,                 
     2960
     2961                        ];
     2962                       
     2963                $this->bsecureSendCurlRequest($webhook_url,$params);
     2964            }           
     2965
     2966        }
     2967
     2968    }
    29012969
    29022970}
  • bsecure/trunk/includes/class-wc-bsecure.php

    r2688113 r2690001  
    3030
    3131    const PLUGIN_NAME = 'WooCommerce';
    32     const PLUGIN_VERSION = '1.6.4';
     32    const PLUGIN_VERSION = '1.6.5';
    3333    const QISSTPAY_PER_MONTH = 4;
    3434    const QISSTPAY_AMOUNT_MAX_LIMIT = 50000;
  • bsecure/trunk/readme.txt

    r2688113 r2690001  
    55Tested up to: 5.9
    66Requires PHP: 5.6.20 or above
    7 Stable tag: 1.6.4
     7Stable tag: 1.6.5
    88License: GNU General Public License v3.0
    99License URI: http://www.gnu.org/licenses/gpl-3.0.html
     
    8282* Tweak - Tested compatibility with WP 5.4.
    8383
     84== 1.6.1 February 11, 2022 ==
     85* 1.6.1 Released General Update, PIM api integration and Bug Fixes
     86
     87== 1.6.3 February 23, 2022 ==
     88* 1.6.3 Released General Update and Bug Fixes
     89
     90== 1.6.4 March 3, 2022 ==
     91* 1.6.4 Released General Update and Bug Fixes
     92
     93== 1.6.5 March 7, 2022 ==
     94* 1.6.5 Released General Update, New Feature (PIM) and Bug Fixes
     95
    8496== Upgrade Notice ==
    8597= 1.0 =
Note: See TracChangeset for help on using the changeset viewer.