| @@ -1,8 +1,8 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | 3 | * Plugin Name: Cashfree |
| 4 | - * Version: 4.8.1 | |
| 4 | + * Version: 4.3.6 | |
| 5 | 5 | * Plugin URI: https://github.com/cashfree/cashfree-woocommerce |
| 6 | 6 | * Description: Payment gateway plugin by Cashfree Payments for Woocommerce sites. |
| 7 | 7 | * Author: devcashfree |
| 8 | 8 | * Author URI: https://cashfree.com |
| @@ -10,11 +10,11 @@ | ||
| 10 | 10 | * Developer URI: techsupport@gocashfree.com |
| 11 | 11 | * Text Domain: woocommerce-extension |
| 12 | 12 | * Domain Path: /languages |
| 13 | 13 | * Requires at least: 4.4 |
| 14 | - * Tested up to: 7.1 | |
| 14 | + * Tested up to: 6.0 | |
| 15 | 15 | * WC requires at least: 3.0 |
| 16 | - * WC tested up to: 11.0 | |
| 16 | + * WC tested up to: 6.3.1 | |
| 17 | 17 | * |
| 18 | 18 | * |
| 19 | 19 | * License: GPLv3 |
| 20 | 20 | * License URI: https://www.gnu.org/licenses/gpl-3.0.html |
| @@ -21,18 +21,8 @@ | ||
| 21 | 21 | */ |
| 22 | 22 | |
| 23 | 23 | defined( 'ABSPATH' ) || exit; |
| 24 | 24 | |
| 25 | -require_once ABSPATH . 'wp-admin/includes/plugin.php'; | |
| 26 | - | |
| 27 | -// Adding this for making compatible with HPOC | |
| 28 | -add_action('before_woocommerce_init', function() { | |
| 29 | - if (class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class)) | |
| 30 | - { | |
| 31 | - \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility('custom_order_tables', __FILE__, true); | |
| 32 | - } | |
| 33 | -}); | |
| 34 | - | |
| 35 | 25 | /** |
| 36 | 26 | * Cashfree main class. |
| 37 | 27 | */ |
| 38 | 28 | class WC_Cashfree { |
| @@ -50,10 +40,8 @@ | ||
| 50 | 40 | * @var array |
| 51 | 41 | */ |
| 52 | 42 | private $settings; |
| 53 | 43 | |
| 54 | - private $enabled; | |
| 55 | - | |
| 56 | 44 | /** |
| 57 | 45 | * A log object returned by wc_get_logger(). |
| 58 | 46 | * |
| 59 | 47 | * @var WC_Logger |
| @@ -71,11 +59,9 @@ | ||
| 71 | 59 | define( 'WC_CASHFREE_DIR_URL', plugin_dir_url( __FILE__ ) ); |
| 72 | 60 | define( 'WC_CASHFREE_VERSION', $plugin_data['Version'] ); |
| 73 | 61 | |
| 74 | 62 | $this->settings = get_option( 'woocommerce_' . self::PAYMENT_GATEWAY_ID . '_settings' ); |
| 75 | - if($this->settings) { | |
| 76 | - $this->enabled = 'yes' === $this->settings['enabled']; | |
| 77 | - } | |
| 63 | + $this->enabled = 'yes' === $this->settings['enabled'] && ! empty( $this->settings['merchant_id'] ); | |
| 78 | 64 | |
| 79 | 65 | require_once WC_CASHFREE_DIR_PATH . 'includes/wc-cashfree-functions.php'; |
| 80 | 66 | require_once WC_CASHFREE_DIR_PATH . 'includes/http/class-wc-cashfree-adapter.php'; |
| 81 | 67 | |
| @@ -80,33 +66,12 @@ | ||
| 80 | 66 | require_once WC_CASHFREE_DIR_PATH . 'includes/http/class-wc-cashfree-adapter.php'; |
| 81 | 67 | |
| 82 | 68 | add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( __CLASS__, 'plugin_action_links' ) ); |
| 83 | 69 | add_filter( 'woocommerce_payment_gateways', array( __CLASS__, 'load_gateways' ) ); |
| 84 | - add_filter( 'woocommerce_before_add_to_cart_form' , array( $this, 'wp_cashfree_offers' ) ); | |
| 85 | 70 | |
| 86 | 71 | add_action( 'wp_enqueue_scripts', array( $this, 'load_scripts' ) ); |
| 87 | - add_action( 'woocommerce_blocks_loaded', array( __CLASS__, 'woocommerce_gateway_cashfree_woocommerce_block_support' ) ); | |
| 88 | 72 | } |
| 89 | 73 | |
| 90 | - public function wp_cashfree_offers() { | |
| 91 | - if ( isset($this->settings['enabledOffers']) && | |
| 92 | - $this->settings['enabledOffers'] === 'yes' && | |
| 93 | - isset($this->settings['sandbox']) && | |
| 94 | - $this->settings['sandbox'] === 'no') { | |
| 95 | - // External Scripts | |
| 96 | - wp_register_script('cf-woocommerce-js', 'https://sdk.cashfree.com/js/widget/1.0.1/cashfree-widget.prod.js', null, null, true ); | |
| 97 | - wp_enqueue_script('cf-woocommerce-js'); | |
| 98 | - | |
| 99 | - add_filter( 'cf-woocommerce_enqueue_styles', '__return_false' ); | |
| 100 | - | |
| 101 | - global $product; | |
| 102 | - $price = $product->get_price(); | |
| 103 | - | |
| 104 | - echo'<div id="cashfree-widget" data-amount='.$price.' data-appId='.$this->settings['app_id'].' data-isOffers='.$this->settings['offers'].' data-isPayLater='.$this->settings['payLater'].' data-isEmi='.$this->settings['emi'].'></div>'; | |
| 105 | - | |
| 106 | - } | |
| 107 | - } | |
| 108 | - | |
| 109 | 74 | /** |
| 110 | 75 | * Add Cashfree payment gateway. |
| 111 | 76 | * |
| 112 | 77 | * @param array $methods List of payment methods. |
| @@ -163,30 +128,7 @@ | ||
| 163 | 128 | } |
| 164 | 129 | |
| 165 | 130 | self::$log->log( $level, $message, array( 'source' => self::PAYMENT_GATEWAY_ID ) ); |
| 166 | 131 | } |
| 167 | - | |
| 168 | - public static function woocommerce_gateway_cashfree_woocommerce_block_support() { | |
| 169 | - if ( class_exists( 'Automattic\WooCommerce\Blocks\Payments\Integrations\AbstractPaymentMethodType' ) ) { | |
| 170 | - require_once WC_CASHFREE_DIR_PATH . 'includes/gateways/class-wc-cashfree-block-support.php'; | |
| 171 | - add_action( | |
| 172 | - 'woocommerce_blocks_payment_method_type_registration', | |
| 173 | - function( Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry $payment_method_registry ) { | |
| 174 | - $container = Automattic\WooCommerce\Blocks\Package::container(); | |
| 175 | - // registers as shared instance. | |
| 176 | - $container->register( | |
| 177 | - WC_Cashfree_Blocks_Support::class, | |
| 178 | - function() { | |
| 179 | - return new WC_Cashfree_Blocks_Support(); | |
| 180 | - } | |
| 181 | - ); | |
| 182 | - $payment_method_registry->register( | |
| 183 | - $container->get( WC_Cashfree_Blocks_Support::class ) | |
| 184 | - ); | |
| 185 | - }, | |
| 186 | - 5 | |
| 187 | - ); | |
| 188 | - } | |
| 189 | - } | |
| 190 | 132 | } |
| 191 | 133 | |
| 192 | -new WC_Cashfree(); | |
| 134 | +new WC_Cashfree(); | |