Changeset 3054427
- Timestamp:
- 03/19/2024 12:24:00 PM (2 years ago)
- Location:
- cardgate
- Files:
-
- 154 added
- 8 edited
- 1 copied
-
tags/3.1.28 (copied) (copied from cardgate/trunk)
-
tags/3.1.28/cardgate.php (modified) (11 diffs)
-
tags/3.1.28/classes/CGP_Common_Gateway.php (modified) (10 diffs)
-
tags/3.1.28/classes/WC_CardgateIdealqr.php (modified) (1 diff)
-
tags/3.1.28/classes/woocommerce-blocks (added)
-
tags/3.1.28/classes/woocommerce-blocks/afterpay (added)
-
tags/3.1.28/classes/woocommerce-blocks/afterpay/AfterpayCardgate.php (added)
-
tags/3.1.28/classes/woocommerce-blocks/afterpay/build (added)
-
tags/3.1.28/classes/woocommerce-blocks/afterpay/build/index.js (added)
-
tags/3.1.28/classes/woocommerce-blocks/bancontact (added)
-
tags/3.1.28/classes/woocommerce-blocks/bancontact/BancontactCardgate.php (added)
-
tags/3.1.28/classes/woocommerce-blocks/bancontact/build (added)
-
tags/3.1.28/classes/woocommerce-blocks/bancontact/build/index.js (added)
-
tags/3.1.28/classes/woocommerce-blocks/banktransfer (added)
-
tags/3.1.28/classes/woocommerce-blocks/banktransfer/BanktransferCardgate.php (added)
-
tags/3.1.28/classes/woocommerce-blocks/banktransfer/build (added)
-
tags/3.1.28/classes/woocommerce-blocks/banktransfer/build/index.js (added)
-
tags/3.1.28/classes/woocommerce-blocks/billink (added)
-
tags/3.1.28/classes/woocommerce-blocks/billink/BillinkCardgate.php (added)
-
tags/3.1.28/classes/woocommerce-blocks/billink/build (added)
-
tags/3.1.28/classes/woocommerce-blocks/billink/build/index.js (added)
-
tags/3.1.28/classes/woocommerce-blocks/bitcoin (added)
-
tags/3.1.28/classes/woocommerce-blocks/bitcoin/BitcoinCardgate.php (added)
-
tags/3.1.28/classes/woocommerce-blocks/bitcoin/build (added)
-
tags/3.1.28/classes/woocommerce-blocks/bitcoin/build/index.js (added)
-
tags/3.1.28/classes/woocommerce-blocks/creditcard (added)
-
tags/3.1.28/classes/woocommerce-blocks/creditcard/CreditcardCardgate.php (added)
-
tags/3.1.28/classes/woocommerce-blocks/creditcard/build (added)
-
tags/3.1.28/classes/woocommerce-blocks/creditcard/build/index.js (added)
-
tags/3.1.28/classes/woocommerce-blocks/directdebit (added)
-
tags/3.1.28/classes/woocommerce-blocks/directdebit/DirectDebitCardgate.php (added)
-
tags/3.1.28/classes/woocommerce-blocks/directdebit/build (added)
-
tags/3.1.28/classes/woocommerce-blocks/directdebit/build/index.js (added)
-
tags/3.1.28/classes/woocommerce-blocks/giftcard (added)
-
tags/3.1.28/classes/woocommerce-blocks/giftcard/GiftcardCardgate.php (added)
-
tags/3.1.28/classes/woocommerce-blocks/giftcard/build (added)
-
tags/3.1.28/classes/woocommerce-blocks/giftcard/build/index.js (added)
-
tags/3.1.28/classes/woocommerce-blocks/giropay (added)
-
tags/3.1.28/classes/woocommerce-blocks/giropay/GiropayCardgate.php (added)
-
tags/3.1.28/classes/woocommerce-blocks/giropay/build (added)
-
tags/3.1.28/classes/woocommerce-blocks/giropay/build/index.js (added)
-
tags/3.1.28/classes/woocommerce-blocks/ideal (added)
-
tags/3.1.28/classes/woocommerce-blocks/ideal/IdealCardgate.php (added)
-
tags/3.1.28/classes/woocommerce-blocks/ideal/build (added)
-
tags/3.1.28/classes/woocommerce-blocks/ideal/build/index.js (added)
-
tags/3.1.28/classes/woocommerce-blocks/idealqr (added)
-
tags/3.1.28/classes/woocommerce-blocks/idealqr/IdealqrCardgate.php (added)
-
tags/3.1.28/classes/woocommerce-blocks/idealqr/build (added)
-
tags/3.1.28/classes/woocommerce-blocks/idealqr/build/index.js (added)
-
tags/3.1.28/classes/woocommerce-blocks/klarna (added)
-
tags/3.1.28/classes/woocommerce-blocks/klarna/KlarnaCardgate.php (added)
-
tags/3.1.28/classes/woocommerce-blocks/klarna/build (added)
-
tags/3.1.28/classes/woocommerce-blocks/klarna/build/index.js (added)
-
tags/3.1.28/classes/woocommerce-blocks/onlineueberweisen (added)
-
tags/3.1.28/classes/woocommerce-blocks/onlineueberweisen/OnlineueberweisenCardgate.php (added)
-
tags/3.1.28/classes/woocommerce-blocks/onlineueberweisen/build (added)
-
tags/3.1.28/classes/woocommerce-blocks/onlineueberweisen/build/index.js (added)
-
tags/3.1.28/classes/woocommerce-blocks/paypal (added)
-
tags/3.1.28/classes/woocommerce-blocks/paypal/PaypalCardgate.php (added)
-
tags/3.1.28/classes/woocommerce-blocks/paypal/build (added)
-
tags/3.1.28/classes/woocommerce-blocks/paypal/build/index.js (added)
-
tags/3.1.28/classes/woocommerce-blocks/paysafecard (added)
-
tags/3.1.28/classes/woocommerce-blocks/paysafecard/PaysafecardCardgate.php (added)
-
tags/3.1.28/classes/woocommerce-blocks/paysafecard/build (added)
-
tags/3.1.28/classes/woocommerce-blocks/paysafecard/build/index.js (added)
-
tags/3.1.28/classes/woocommerce-blocks/paysafecash (added)
-
tags/3.1.28/classes/woocommerce-blocks/paysafecash/PaysafecashCardgate.php (added)
-
tags/3.1.28/classes/woocommerce-blocks/paysafecash/build (added)
-
tags/3.1.28/classes/woocommerce-blocks/paysafecash/build/index.js (added)
-
tags/3.1.28/classes/woocommerce-blocks/przelewy24 (added)
-
tags/3.1.28/classes/woocommerce-blocks/przelewy24/Przelewy24Cardgate.php (added)
-
tags/3.1.28/classes/woocommerce-blocks/przelewy24/build (added)
-
tags/3.1.28/classes/woocommerce-blocks/przelewy24/build/index.js (added)
-
tags/3.1.28/classes/woocommerce-blocks/sofortbanking (added)
-
tags/3.1.28/classes/woocommerce-blocks/sofortbanking/SofortbankingCardgate.php (added)
-
tags/3.1.28/classes/woocommerce-blocks/sofortbanking/build (added)
-
tags/3.1.28/classes/woocommerce-blocks/sofortbanking/build/index.js (added)
-
tags/3.1.28/classes/woocommerce-blocks/spraypay (added)
-
tags/3.1.28/classes/woocommerce-blocks/spraypay/SpraypayCardgate.php (added)
-
tags/3.1.28/classes/woocommerce-blocks/spraypay/build (added)
-
tags/3.1.28/classes/woocommerce-blocks/spraypay/build/index.js (added)
-
tags/3.1.28/readme.txt (modified) (2 diffs)
-
trunk/cardgate.php (modified) (11 diffs)
-
trunk/classes/CGP_Common_Gateway.php (modified) (10 diffs)
-
trunk/classes/WC_CardgateIdealqr.php (modified) (1 diff)
-
trunk/classes/woocommerce-blocks (added)
-
trunk/classes/woocommerce-blocks/afterpay (added)
-
trunk/classes/woocommerce-blocks/afterpay/AfterpayCardgate.php (added)
-
trunk/classes/woocommerce-blocks/afterpay/build (added)
-
trunk/classes/woocommerce-blocks/afterpay/build/index.js (added)
-
trunk/classes/woocommerce-blocks/bancontact (added)
-
trunk/classes/woocommerce-blocks/bancontact/BancontactCardgate.php (added)
-
trunk/classes/woocommerce-blocks/bancontact/build (added)
-
trunk/classes/woocommerce-blocks/bancontact/build/index.js (added)
-
trunk/classes/woocommerce-blocks/banktransfer (added)
-
trunk/classes/woocommerce-blocks/banktransfer/BanktransferCardgate.php (added)
-
trunk/classes/woocommerce-blocks/banktransfer/build (added)
-
trunk/classes/woocommerce-blocks/banktransfer/build/index.js (added)
-
trunk/classes/woocommerce-blocks/billink (added)
-
trunk/classes/woocommerce-blocks/billink/BillinkCardgate.php (added)
-
trunk/classes/woocommerce-blocks/billink/build (added)
-
trunk/classes/woocommerce-blocks/billink/build/index.js (added)
-
trunk/classes/woocommerce-blocks/bitcoin (added)
-
trunk/classes/woocommerce-blocks/bitcoin/BitcoinCardgate.php (added)
-
trunk/classes/woocommerce-blocks/bitcoin/build (added)
-
trunk/classes/woocommerce-blocks/bitcoin/build/index.js (added)
-
trunk/classes/woocommerce-blocks/creditcard (added)
-
trunk/classes/woocommerce-blocks/creditcard/CreditcardCardgate.php (added)
-
trunk/classes/woocommerce-blocks/creditcard/build (added)
-
trunk/classes/woocommerce-blocks/creditcard/build/index.js (added)
-
trunk/classes/woocommerce-blocks/directdebit (added)
-
trunk/classes/woocommerce-blocks/directdebit/DirectDebitCardgate.php (added)
-
trunk/classes/woocommerce-blocks/directdebit/build (added)
-
trunk/classes/woocommerce-blocks/directdebit/build/index.js (added)
-
trunk/classes/woocommerce-blocks/giftcard (added)
-
trunk/classes/woocommerce-blocks/giftcard/GiftcardCardgate.php (added)
-
trunk/classes/woocommerce-blocks/giftcard/build (added)
-
trunk/classes/woocommerce-blocks/giftcard/build/index.js (added)
-
trunk/classes/woocommerce-blocks/giropay (added)
-
trunk/classes/woocommerce-blocks/giropay/GiropayCardgate.php (added)
-
trunk/classes/woocommerce-blocks/giropay/build (added)
-
trunk/classes/woocommerce-blocks/giropay/build/index.js (added)
-
trunk/classes/woocommerce-blocks/ideal (added)
-
trunk/classes/woocommerce-blocks/ideal/IdealCardgate.php (added)
-
trunk/classes/woocommerce-blocks/ideal/build (added)
-
trunk/classes/woocommerce-blocks/ideal/build/index.js (added)
-
trunk/classes/woocommerce-blocks/idealqr (added)
-
trunk/classes/woocommerce-blocks/idealqr/IdealqrCardgate.php (added)
-
trunk/classes/woocommerce-blocks/idealqr/build (added)
-
trunk/classes/woocommerce-blocks/idealqr/build/index.js (added)
-
trunk/classes/woocommerce-blocks/klarna (added)
-
trunk/classes/woocommerce-blocks/klarna/KlarnaCardgate.php (added)
-
trunk/classes/woocommerce-blocks/klarna/build (added)
-
trunk/classes/woocommerce-blocks/klarna/build/index.js (added)
-
trunk/classes/woocommerce-blocks/onlineueberweisen (added)
-
trunk/classes/woocommerce-blocks/onlineueberweisen/OnlineueberweisenCardgate.php (added)
-
trunk/classes/woocommerce-blocks/onlineueberweisen/build (added)
-
trunk/classes/woocommerce-blocks/onlineueberweisen/build/index.js (added)
-
trunk/classes/woocommerce-blocks/paypal (added)
-
trunk/classes/woocommerce-blocks/paypal/PaypalCardgate.php (added)
-
trunk/classes/woocommerce-blocks/paypal/build (added)
-
trunk/classes/woocommerce-blocks/paypal/build/index.js (added)
-
trunk/classes/woocommerce-blocks/paysafecard (added)
-
trunk/classes/woocommerce-blocks/paysafecard/PaysafecardCardgate.php (added)
-
trunk/classes/woocommerce-blocks/paysafecard/build (added)
-
trunk/classes/woocommerce-blocks/paysafecard/build/index.js (added)
-
trunk/classes/woocommerce-blocks/paysafecash (added)
-
trunk/classes/woocommerce-blocks/paysafecash/PaysafecashCardgate.php (added)
-
trunk/classes/woocommerce-blocks/paysafecash/build (added)
-
trunk/classes/woocommerce-blocks/paysafecash/build/index.js (added)
-
trunk/classes/woocommerce-blocks/przelewy24 (added)
-
trunk/classes/woocommerce-blocks/przelewy24/Przelewy24Cardgate.php (added)
-
trunk/classes/woocommerce-blocks/przelewy24/build (added)
-
trunk/classes/woocommerce-blocks/przelewy24/build/index.js (added)
-
trunk/classes/woocommerce-blocks/sofortbanking (added)
-
trunk/classes/woocommerce-blocks/sofortbanking/SofortbankingCardgate.php (added)
-
trunk/classes/woocommerce-blocks/sofortbanking/build (added)
-
trunk/classes/woocommerce-blocks/sofortbanking/build/index.js (added)
-
trunk/classes/woocommerce-blocks/spraypay (added)
-
trunk/classes/woocommerce-blocks/spraypay/SpraypayCardgate.php (added)
-
trunk/classes/woocommerce-blocks/spraypay/build (added)
-
trunk/classes/woocommerce-blocks/spraypay/build/index.js (added)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
cardgate/tags/3.1.28/cardgate.php
r3008166 r3054427 7 7 * Author: CardGate 8 8 * Author URI: https://www.cardgate.com 9 * Version: 3.1.2 79 * Version: 3.1.28 10 10 * Text Domain: cardgate 11 11 * Domain Path: /i18n/languages 12 12 * Requires at least: 4.4 13 13 * WC requires at least: 3.0.0 14 * WC tested up to: 8. 1.114 * WC tested up to: 8.6.1 15 15 * License: GPLv3 or later 16 16 */ … … 36 36 if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) { 37 37 \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true ); 38 \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'cart_checkout_blocks', __FILE__, true ); 38 39 } 39 40 } ); 40 add_action('admin_head', array($this,'add_cgform_fields')); 41 add_action('woocommerce_cart_calculate_fees', array($this,'calculate_totals'), 10, 1); 42 add_action('wp_enqueue_scripts', array($this,'load_cg_script')); 41 42 43 add_action('admin_head', array($this,'add_cgform_fields')); 44 add_action('woocommerce_cart_calculate_fees', array($this,'calculate_totals')); 45 add_action('wp_enqueue_scripts', array($this,'load_cg_script'),10, 1); 43 46 add_action('admin_menu', array(&$this,'CGPAdminMenu')); 44 47 add_action('init', array(&$this,'cardgate_callback'), 20); 45 48 add_action( 'woocommerce_blocks_loaded', array($this,'woocommerce_cardgate_blocks_support' )); 49 add_action('wp_loaded', array($this,'cardgate_checkout_fees')); 50 46 51 register_activation_hook(__FILE__, array(&$this,'cardgate_install')); // hook for install 47 52 register_deactivation_hook(__FILE__, array(&$this,'cardgate_uninstall')); // hook for uninstall … … 50 55 update_option('is_callback_status_change', false); 51 56 add_action('woocommerce_cancelled_order', array(&$this,'capture_payment_failed')); 57 52 58 if (! $this->cardgate_settings()) 53 59 add_action('admin_notices', array(&$this,'my_error_notice')); … … 468 474 // check that the callback came from CardGate 469 475 if (isset($_GET['cgp_notify']) && $_GET['cgp_notify'] == 'true' && empty($_REQUEST['cgp_sitesetup'])) { 470 471 476 // hash check 472 477 $bIsTest = (get_option('cgp_mode') == 1 ? true : false); … … 708 713 $methods[] = 'WC_CardgateSofortbanking'; 709 714 $methods[] = 'WC_CardgateSpraypay'; 710 711 715 return $methods; 712 716 } … … 772 776 } 773 777 } 774 775 778 public function calculate_totals($totals) { 776 779 global $woocommerce; 777 780 778 781 $woocommerce->session->extra_cart_fee = 0; 779 782 $available_gateways = $woocommerce->payment_gateways->get_available_payment_gateways(); … … 789 792 } 790 793 } 794 791 795 if ($current_gateway != '') { 792 796 $current_gateway_id = $current_gateway->id; … … 819 823 $t6 = $this->current_gateway_title . ' Extra Charges - '; 820 824 } 825 821 826 $woocommerce->cart->add_fee(__($t6 . $t5), $t1); 822 827 $woocommerce->session->extra_cart_fee = $t1; … … 824 829 } 825 830 return $totals; 831 } 832 public function is_ajax_block_update($post){ 833 return ( isset( $post['action'] ) && $post['action'] == 'wp_ajax_cardgate_checkout_fees' ) ? true : false; 826 834 } 827 835 … … 832 840 } 833 841 842 function woocommerce_cardgate_blocks_support(){ 843 // Check if the required class exists 844 if ( ! class_exists( 'Automattic\WooCommerce\Blocks\Payments\Integrations\AbstractPaymentMethodType' ) ) { 845 return; 846 } 847 848 // Include the custom Blocks Checkout class 849 require_once 'classes/woocommerce-blocks/giropay/GiropayCardgate.php'; 850 add_action( 851 'woocommerce_blocks_payment_method_type_registration', 852 function( Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry $payment_method_registry ) { 853 $payment_method_registry->register( new \Automattic\WooCommerce\Blocks\Payments\Integrations\GiropayCardgate() ); 854 } 855 ); 856 require_once 'classes/woocommerce-blocks/bancontact/BancontactCardgate.php'; 857 add_action( 858 'woocommerce_blocks_payment_method_type_registration', 859 function( Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry $payment_method_registry ) { 860 $payment_method_registry->register( new \Automattic\WooCommerce\Blocks\Payments\Integrations\BancontactCardgate() ); 861 } 862 ); 863 require_once 'classes/woocommerce-blocks/afterpay/AfterpayCardgate.php'; 864 add_action( 865 'woocommerce_blocks_payment_method_type_registration', 866 function( Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry $payment_method_registry ) { 867 $payment_method_registry->register( new \Automattic\WooCommerce\Blocks\Payments\Integrations\AfterpayCardgate() ); 868 } 869 ); 870 require_once 'classes/woocommerce-blocks/banktransfer/BanktransferCardgate.php'; 871 add_action( 872 'woocommerce_blocks_payment_method_type_registration', 873 function( Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry $payment_method_registry ) { 874 $payment_method_registry->register( new \Automattic\WooCommerce\Blocks\Payments\Integrations\BanktransferCardgate() ); 875 } 876 ); 877 require_once 'classes/woocommerce-blocks/billink/BillinkCardgate.php'; 878 add_action( 879 'woocommerce_blocks_payment_method_type_registration', 880 function( Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry $payment_method_registry ) { 881 $payment_method_registry->register( new \Automattic\WooCommerce\Blocks\Payments\Integrations\BillinkCardgate() ); 882 } 883 ); 884 require_once 'classes/woocommerce-blocks/bitcoin/BitcoinCardgate.php'; 885 add_action( 886 'woocommerce_blocks_payment_method_type_registration', 887 function( Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry $payment_method_registry ) { 888 $payment_method_registry->register( new \Automattic\WooCommerce\Blocks\Payments\Integrations\BitcoinCardgate() ); 889 } 890 ); 891 require_once 'classes/woocommerce-blocks/creditcard/CreditcardCardgate.php'; 892 add_action( 893 'woocommerce_blocks_payment_method_type_registration', 894 function( Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry $payment_method_registry ) { 895 $payment_method_registry->register( new \Automattic\WooCommerce\Blocks\Payments\Integrations\CreditcardCardgate() ); 896 } 897 ); 898 require_once 'classes/woocommerce-blocks/directdebit/DirectDebitCardgate.php'; 899 add_action( 900 'woocommerce_blocks_payment_method_type_registration', 901 function( Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry $payment_method_registry ) { 902 $payment_method_registry->register( new \Automattic\WooCommerce\Blocks\Payments\Integrations\DirectDebitCardgate() ); 903 } 904 ); 905 require_once 'classes/woocommerce-blocks/giftcard/GiftcardCardgate.php'; 906 add_action( 907 'woocommerce_blocks_payment_method_type_registration', 908 function( Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry $payment_method_registry ) { 909 $payment_method_registry->register( new \Automattic\WooCommerce\Blocks\Payments\Integrations\GiftcardCardgate() ); 910 } 911 ); 912 require_once 'classes/woocommerce-blocks/ideal/IdealCardgate.php'; 913 add_action( 914 'woocommerce_blocks_payment_method_type_registration', 915 function( Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry $payment_method_registry ) { 916 $payment_method_registry->register( new \Automattic\WooCommerce\Blocks\Payments\Integrations\IdealCardgate() ); 917 } 918 ); 919 require_once 'classes/woocommerce-blocks/idealqr/IdealqrCardgate.php'; 920 add_action( 921 'woocommerce_blocks_payment_method_type_registration', 922 function( Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry $payment_method_registry ) { 923 $payment_method_registry->register( new \Automattic\WooCommerce\Blocks\Payments\Integrations\IdealqrCardgate() ); 924 } 925 ); 926 require_once 'classes/woocommerce-blocks/klarna/KlarnaCardgate.php'; 927 add_action( 928 'woocommerce_blocks_payment_method_type_registration', 929 function( Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry $payment_method_registry ) { 930 $payment_method_registry->register( new \Automattic\WooCommerce\Blocks\Payments\Integrations\KlarnaCardgate() ); 931 } 932 ); 933 require_once 'classes/woocommerce-blocks/onlineueberweisen/OnlineueberweisenCardgate.php'; 934 add_action( 935 'woocommerce_blocks_payment_method_type_registration', 936 function( Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry $payment_method_registry ) { 937 $payment_method_registry->register( new \Automattic\WooCommerce\Blocks\Payments\Integrations\OnlineueberweisenCardgate() ); 938 } 939 ); 940 require_once 'classes/woocommerce-blocks/paypal/PaypalCardgate.php'; 941 add_action( 942 'woocommerce_blocks_payment_method_type_registration', 943 function( Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry $payment_method_registry ) { 944 $payment_method_registry->register( new \Automattic\WooCommerce\Blocks\Payments\Integrations\PaypalCardgate() ); 945 } 946 ); 947 require_once 'classes/woocommerce-blocks/paysafecard/PaysafecardCardgate.php'; 948 add_action( 949 'woocommerce_blocks_payment_method_type_registration', 950 function( Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry $payment_method_registry ) { 951 $payment_method_registry->register( new \Automattic\WooCommerce\Blocks\Payments\Integrations\PaysafecardCardgate() ); 952 } 953 ); 954 require_once 'classes/woocommerce-blocks/paysafecash/PaysafecashCardgate.php'; 955 add_action( 956 'woocommerce_blocks_payment_method_type_registration', 957 function( Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry $payment_method_registry ) { 958 $payment_method_registry->register( new \Automattic\WooCommerce\Blocks\Payments\Integrations\PaysafecashCardgate() ); 959 } 960 ); 961 require_once 'classes/woocommerce-blocks/przelewy24/Przelewy24Cardgate.php'; 962 add_action( 963 'woocommerce_blocks_payment_method_type_registration', 964 function( Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry $payment_method_registry ) { 965 $payment_method_registry->register( new \Automattic\WooCommerce\Blocks\Payments\Integrations\Przelewy24Cardgate() ); 966 } 967 ); 968 require_once 'classes/woocommerce-blocks/sofortbanking/SofortbankingCardgate.php'; 969 add_action( 970 'woocommerce_blocks_payment_method_type_registration', 971 function( Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry $payment_method_registry ) { 972 $payment_method_registry->register( new \Automattic\WooCommerce\Blocks\Payments\Integrations\SofortbankingCardgate() ); 973 } 974 ); 975 require_once 'classes/woocommerce-blocks/spraypay/SpraypayCardgate.php'; 976 add_action( 977 'woocommerce_blocks_payment_method_type_registration', 978 function( Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry $payment_method_registry ) { 979 $payment_method_registry->register( new \Automattic\WooCommerce\Blocks\Payments\Integrations\SpraypayCardgate() ); 980 } 981 ); 982 } 983 984 public function cardgate_checkout_fees() { 985 global $woocommerce; 986 if ( isset( $_POST ) && $this->is_ajax_block_update( $_POST ) ) { 987 $method = $_POST['method']; 988 $feeData = $this->getFeeData($method); 989 990 $this->cartRemoveFee( $feeData['label'] ); 991 $newTotal = (float) $woocommerce->cart->get_totals()['total']; 992 $totalTax = $woocommerce->cart->get_totals()['total_tax']; 993 $noSurchargeData = [ 994 995 'amount' => false, 996 'name' => '', 997 'currency' => get_woocommerce_currency_symbol(), 998 'newTotal' => $newTotal, 999 'totalTax' => $totalTax, 1000 ]; 1001 if (!$feeData['fee'] || $feeData['fee'] == 0) { 1002 wp_send_json_success($noSurchargeData); 1003 return; 1004 } 1005 1006 $feeAmount = $feeData['fee']; 1007 $label = $feeData['label']; 1008 add_action('woocommerce_cart_calculate_fees', static function () use ($label, $feeAmount) { 1009 global $woocommerce; 1010 $woocommerce->cart->add_fee($label, $feeAmount, true, 'standard'); 1011 }); 1012 1013 //add global woocommerce. 1014 1015 $woocommerce->cart->calculate_totals(); 1016 1017 $feeAmountTaxed = (float) $woocommerce->cart->get_totals()['fee_total']; 1018 $taxDisplayMode = get_option('woocommerce_tax_display_shop'); 1019 if ($taxDisplayMode === 'incl') { 1020 $feeAmountTaxed = $feeAmountTaxed + (float) $woocommerce->cart->get_totals()['fee_tax']; 1021 } 1022 $newTotal = (float) $woocommerce->cart->get_totals()['total']; 1023 $totalTax = $woocommerce->cart->get_totals()['total_tax']; 1024 $data = [ 1025 'amount' => $feeAmountTaxed, 1026 'name' => $feeData['label'], 1027 'currency' => get_woocommerce_currency_symbol(), 1028 'newTotal' => $newTotal, 1029 'totalTax' => $totalTax, 1030 'cart' => $woocommerce->cart->get_totals(), 1031 ]; 1032 1033 wp_send_json_success($data); 1034 } 1035 } 1036 protected function cartRemoveFee($label) 1037 { 1038 add_action('woocommerce_before_calculate_totals', static function () use ($label) { 1039 $fees = WC()->cart->get_fees(); 1040 foreach ($fees as $key => $fee) { 1041 if ($fees[$key]->name === $label) { 1042 unset($fees[$key]); 1043 } 1044 } 1045 WC()->cart->fees_api()->set_fees($fees); 1046 }); 1047 } 1048 protected function getFeeData($method) { 1049 global $woocommerce; 1050 $woocommerce->cart; 1051 $woocommerce->cart->calculate_totals(); 1052 $data = []; 1053 $fee = get_option('woocommerce_' . $method . '_extra_charges'); 1054 $fee = $fee == "" ? 0: $fee; 1055 $label = get_option( 'woocommerce_' . $method . '_extra_charges_label'); 1056 $type = get_option('woocommerce_' . $method . '_extra_charges_type'); 1057 if (isset($label) && strlen($label) > 2) { 1058 if ($type == 'percentage'){ 1059 $label .= ' '. $fee.'%'; 1060 } 1061 } else { 1062 $label= $this->current_gateway_title . ' Payment Charges '; 1063 } 1064 1065 if ($type == "percentage") { 1066 $cart_total = (float) $woocommerce->cart->get_subtotal('edit'); 1067 $payment_fee = ($cart_total * $fee) / 100; 1068 } else { 1069 $payment_fee = $fee; 1070 } 1071 $data['fee'] = $payment_fee; 1072 $data['type'] = ($type == "percentage" ? $fee . '%' : 'Fixed'); 1073 $data['label'] = $label; 1074 return $data; 1075 } 834 1076 public function set_plugin_url() { 835 1077 $this->plugin_url = untrailingslashit(plugins_url('/', __FILE__)); … … 890 1132 spl_autoload_register('cardgate_autoload'); 891 1133 endif; 892 893 1134 ?> -
cardgate/tags/3.1.28/classes/CGP_Common_Gateway.php
r2975181 r3054427 84 84 * Fetch bank options from Card Gate 85 85 */ 86 p rivatefunction getBankOptions() {86 public function getBankOptions() { 87 87 $this->checkBankOptions(); 88 88 $aIssuers = get_option( 'sIssuers' ); … … 200 200 global $woocommerce; 201 201 try { 202 202 $oOrder = new WC_Order( $iOrderId ); 203 $this->correct_payment_fee($oOrder); 204 $oOrder->save(); 203 205 $this->savePaymentData( $iOrderId ); 204 206 … … 207 209 $bIsTest = ( get_option( 'cgp_mode' ) == 1 ? true : false ); 208 210 $sLanguage = substr( get_locale(), 0, 2 ); 209 $oOrder = new WC_Order( $iOrderId );210 211 211 212 $sVersion = ( $this->get_woocommerce_version() == '' ? 'unkown' : $this->get_woocommerce_version() ); … … 369 370 return [ 370 371 'result' => 'success', 371 'redirect' => $woocommerce->cart->get_checkout_url()372 'redirect' => wc_get_checkout_url() 372 373 ]; 373 374 } … … 378 379 return [ 379 380 'result' => 'success', 380 'redirect' => $woocommerce->cart->get_checkout_url()381 'redirect' => wc_get_checkout_url() 381 382 ]; 382 383 } 383 384 } 385 386 protected function correct_payment_fee(&$oOrder) { 387 if ($this->has_block_checkout()){ 388 $fees = $oOrder->get_fees(); 389 $feeData = $this->getFeeData($oOrder->get_payment_method()); 390 $hasFee = array_key_exists('fee',$feeData) && $feeData['fee'] !== 0.0; 391 $correctedFee = false; 392 foreach ($fees as $fee) { 393 $feeName = $fee->get_name(); 394 $feeId = $fee->get_id(); 395 $hasCardgateFee = strpos($feeName, $feeData['label']) !== false; 396 if ($hasCardgateFee) { 397 if ($feeData['amount'] == (float)$fee->get_amount('edit')) { 398 $correctedFee = true; 399 continue; 400 } 401 if (!$correctedFee) { 402 $this->removeOrderFee($oOrder, $feeId); 403 $correctedFee = true; 404 continue; 405 } 406 $this->removeOrderFee($oOrder, $feeId); 407 $this->orderAddFee($oOrder, $feeData['fee'], $feeData['label']); 408 $correctedFee = true; 409 } 410 } 411 if (!$correctedFee) { 412 if ($hasFee) { 413 $this->orderAddFee($oOrder, $feeData['fee'], $feeData['label']); 414 } 415 } 416 } 417 if ($hasFee) { 418 $feeName = $feeData['label']; 419 $this->setSessionfee( $oOrder, $feeName ); 420 } 421 return $oOrder; 422 } 423 424 function setSessionFee($oOrder, $feeName){ 425 WC()->session->extra_cart_fee = WC()->session->extra_cart_fee_tax = 0; 426 $aFees = $oOrder->get_fees(); 427 foreach($aFees as $fee){ 428 if($fee['name'] == $feeName){ 429 WC()->session->extra_cart_fee = $fee->get_total(); 430 WC()->session->extra_cart_fee_tax = $fee->get_total_tax(); 431 } 432 } 433 } 434 435 protected function removeOrderFee(&$oOrder, int $feeId) { 436 $oOrder->remove_item($feeId); 437 wc_delete_order_item($feeId); 438 $oOrder->calculate_totals(); 439 } 440 441 protected function orderAddFee(&$oOrder, $amount, $feeName) { 442 $item_fee = new \WC_Order_Item_Fee(); 443 $item_fee->set_name($feeName); 444 $item_fee->set_amount($amount); 445 $item_fee->set_total($amount); 446 $item_fee->set_tax_status(true); 447 $oOrder->add_item($item_fee); 448 $oOrder->calculate_totals(); 449 } 450 451 protected function getFeeData($method) { 452 global $woocommerce; 453 $woocommerce->cart; 454 $woocommerce->cart->calculate_totals(); 455 $data = []; 456 $fee = get_option('woocommerce_' . $method . '_extra_charges'); 457 $fee = $fee == "" ? 0: $fee; 458 $label = get_option( 'woocommerce_' . $method . '_extra_charges_label'); 459 $type = get_option('woocommerce_' . $method . '_extra_charges_type'); 460 if (isset($label) && strlen($label) > 2) { 461 if ($type == 'percentage'){ 462 $label .= ' '. $fee.'%'; 463 } 464 } else { 465 $label= $this->current_gateway_title . ' Payment Charges '; 466 } 467 468 if ($type == "percentage") { 469 $cart_total = (float) $woocommerce->cart->get_subtotal('edit'); 470 $payment_fee = ($cart_total * $fee) / 100; 471 } else { 472 $payment_fee = $fee; 473 } 474 $data['fee'] = $payment_fee; 475 $data['type'] = ($type == "percentage" ? $fee . '%' : 'Fixed'); 476 $data['label'] = $label; 477 return $data; 478 } 479 480 public function has_block_checkout(){ 481 $uses_blocks = class_exists( 'Automattic\WooCommerce\Blocks\Payments\Integrations\AbstractPaymentMethodType'); 482 $isClassicCheckout = isset($_REQUEST["wc-ajax"]) && $_REQUEST["wc-ajax"] === "checkout"; 483 return ($uses_blocks && !$isClassicCheckout); 484 } 384 485 385 486 // //////////////////////////////////////////////// … … 479 580 } 480 581 } 481 if ( WC()->version < '3.0.0' ) { 482 $order_id = $order->id; 483 } else { 484 $order_id = $order->get_id(); 485 } 582 583 $order_id = $order->get_id(); 486 584 487 585 $data = [ … … 634 732 $fpExtraFee = ( empty( $woocommerce->session->extra_cart_fee ) ? 0 : $woocommerce->session->extra_cart_fee ); 635 733 $iExtraFee = round( $fpExtraFee * 100 ); 636 637 if ( $iExtraFee > 0 ) { 734 $fpExtraFeeTax = ( empty( $woocommerce->session->extra_cart_fee_tax ) ? 0 : $woocommerce->session->extra_cart_fee_tax ); 735 $iExtraFeeTax = round( $fpExtraFeeTax * 100 ); 736 737 if ($iExtraFeeTax > 0){ 738 $iTaxRate = round($iExtraFeeTax / $fpExtraFee,2); 739 $nr ++; 740 $items[ $nr ]['type'] = 'paymentfee'; 741 $items[ $nr ]['model'] = 'extra_costs'; 742 $items[ $nr ]['name'] = 'payment_fee'; 743 $items[ $nr ]['quantity'] = 1; 744 $items[ $nr ]['price_wt'] = $iExtraFee; 745 $items[ $nr ]['vat'] = $iTaxRate; 746 $items[ $nr ]['vat_amount'] = $iExtraFeeTax; 747 748 } elseif ( $iExtraFee > 0 ) { 638 749 639 750 $nr ++; … … 666 777 } 667 778 668 $iTaxDifference = round( $oOrder->get_total_tax() * 100 ) - $iCartItemTaxTotal - $ishippingTaxTotal - $i DiscountTaxTotal;779 $iTaxDifference = round( $oOrder->get_total_tax() * 100 ) - $iCartItemTaxTotal - $ishippingTaxTotal - $iExtraFeeTax - $iDiscountTaxTotal; 669 780 if ( $iTaxDifference != 0 ) { 670 781 $nr ++; … … 678 789 } 679 790 680 $iCorrection = round( $iOrderTotal - $iCartItemTotal - $iCartItemTaxTotal - $iShippingTotal - $ishippingTaxTotal - $iExtraFee - $i TaxDifference - $iDiscountTotal - $iDiscountTaxTotal);791 $iCorrection = round( $iOrderTotal - $iCartItemTotal - $iCartItemTaxTotal - $iShippingTotal - $ishippingTaxTotal - $iExtraFee - $iExtraFeeTax - $iTaxDifference - $iDiscountTotal - $iDiscountTaxTotal); 681 792 682 793 if ( $iCorrection != 0 ) { … … 706 817 public function validate_fields() { 707 818 global $woocommerce; 708 709 if ( $_POST['payment_method'] == 'cardgateideal' ) { 819 if (key_exists('wc-cardgateideal-new-payment-method',$_POST)) { 820 if ( empty( $_POST['cardgateideal_issuer'] ) || $_POST['cardgateideal_issuer'] == '0' ) { 821 wc_add_notice( __( ' Choose your bank first, please', 'cardgate' ), 'error' ); 822 return false; 823 } else { 824 $this->bankOption = $_POST['cardgateideal_issuer']; 825 } 826 } elseif (key_exists('payment_method', $_POST) && $_POST['payment_method'] == 'cardgateideal' ) { 710 827 if ( empty( $_POST['cgp_bank_options'] ) || $_POST['cgp_bank_options'] == '0' ) { 711 828 wc_add_notice( __( ' Choose your bank first, please', 'cardgate' ), 'error' ); 712 713 829 return false; 714 830 } else { -
cardgate/tags/3.1.28/classes/WC_CardgateIdealqr.php
r2491968 r3054427 11 11 class WC_CardgateIdealqr extends CGP_Common_Gateway { 12 12 13 var $id = 'cardgate aIdealqr';13 var $id = 'cardgateidealqr'; 14 14 var $title = ''; 15 15 var $method_title = 'Cardgate iDEAL QR'; -
cardgate/tags/3.1.28/readme.txt
r3008166 r3054427 5 5 Requires at least: 4.4 6 6 Tested up to: 6.4 7 Stable tag: 3.1.2 77 Stable tag: 3.1.28 8 8 License: GPLv3 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-3.0.html … … 75 75 76 76 == Changelog == 77 78 = 3.1.28 = 79 * Added: Woocommerce block compatibility 77 80 78 81 = 3.1.27 = -
cardgate/trunk/cardgate.php
r3008166 r3054427 7 7 * Author: CardGate 8 8 * Author URI: https://www.cardgate.com 9 * Version: 3.1.2 79 * Version: 3.1.28 10 10 * Text Domain: cardgate 11 11 * Domain Path: /i18n/languages 12 12 * Requires at least: 4.4 13 13 * WC requires at least: 3.0.0 14 * WC tested up to: 8. 1.114 * WC tested up to: 8.6.1 15 15 * License: GPLv3 or later 16 16 */ … … 36 36 if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) { 37 37 \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true ); 38 \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'cart_checkout_blocks', __FILE__, true ); 38 39 } 39 40 } ); 40 add_action('admin_head', array($this,'add_cgform_fields')); 41 add_action('woocommerce_cart_calculate_fees', array($this,'calculate_totals'), 10, 1); 42 add_action('wp_enqueue_scripts', array($this,'load_cg_script')); 41 42 43 add_action('admin_head', array($this,'add_cgform_fields')); 44 add_action('woocommerce_cart_calculate_fees', array($this,'calculate_totals')); 45 add_action('wp_enqueue_scripts', array($this,'load_cg_script'),10, 1); 43 46 add_action('admin_menu', array(&$this,'CGPAdminMenu')); 44 47 add_action('init', array(&$this,'cardgate_callback'), 20); 45 48 add_action( 'woocommerce_blocks_loaded', array($this,'woocommerce_cardgate_blocks_support' )); 49 add_action('wp_loaded', array($this,'cardgate_checkout_fees')); 50 46 51 register_activation_hook(__FILE__, array(&$this,'cardgate_install')); // hook for install 47 52 register_deactivation_hook(__FILE__, array(&$this,'cardgate_uninstall')); // hook for uninstall … … 50 55 update_option('is_callback_status_change', false); 51 56 add_action('woocommerce_cancelled_order', array(&$this,'capture_payment_failed')); 57 52 58 if (! $this->cardgate_settings()) 53 59 add_action('admin_notices', array(&$this,'my_error_notice')); … … 468 474 // check that the callback came from CardGate 469 475 if (isset($_GET['cgp_notify']) && $_GET['cgp_notify'] == 'true' && empty($_REQUEST['cgp_sitesetup'])) { 470 471 476 // hash check 472 477 $bIsTest = (get_option('cgp_mode') == 1 ? true : false); … … 708 713 $methods[] = 'WC_CardgateSofortbanking'; 709 714 $methods[] = 'WC_CardgateSpraypay'; 710 711 715 return $methods; 712 716 } … … 772 776 } 773 777 } 774 775 778 public function calculate_totals($totals) { 776 779 global $woocommerce; 777 780 778 781 $woocommerce->session->extra_cart_fee = 0; 779 782 $available_gateways = $woocommerce->payment_gateways->get_available_payment_gateways(); … … 789 792 } 790 793 } 794 791 795 if ($current_gateway != '') { 792 796 $current_gateway_id = $current_gateway->id; … … 819 823 $t6 = $this->current_gateway_title . ' Extra Charges - '; 820 824 } 825 821 826 $woocommerce->cart->add_fee(__($t6 . $t5), $t1); 822 827 $woocommerce->session->extra_cart_fee = $t1; … … 824 829 } 825 830 return $totals; 831 } 832 public function is_ajax_block_update($post){ 833 return ( isset( $post['action'] ) && $post['action'] == 'wp_ajax_cardgate_checkout_fees' ) ? true : false; 826 834 } 827 835 … … 832 840 } 833 841 842 function woocommerce_cardgate_blocks_support(){ 843 // Check if the required class exists 844 if ( ! class_exists( 'Automattic\WooCommerce\Blocks\Payments\Integrations\AbstractPaymentMethodType' ) ) { 845 return; 846 } 847 848 // Include the custom Blocks Checkout class 849 require_once 'classes/woocommerce-blocks/giropay/GiropayCardgate.php'; 850 add_action( 851 'woocommerce_blocks_payment_method_type_registration', 852 function( Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry $payment_method_registry ) { 853 $payment_method_registry->register( new \Automattic\WooCommerce\Blocks\Payments\Integrations\GiropayCardgate() ); 854 } 855 ); 856 require_once 'classes/woocommerce-blocks/bancontact/BancontactCardgate.php'; 857 add_action( 858 'woocommerce_blocks_payment_method_type_registration', 859 function( Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry $payment_method_registry ) { 860 $payment_method_registry->register( new \Automattic\WooCommerce\Blocks\Payments\Integrations\BancontactCardgate() ); 861 } 862 ); 863 require_once 'classes/woocommerce-blocks/afterpay/AfterpayCardgate.php'; 864 add_action( 865 'woocommerce_blocks_payment_method_type_registration', 866 function( Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry $payment_method_registry ) { 867 $payment_method_registry->register( new \Automattic\WooCommerce\Blocks\Payments\Integrations\AfterpayCardgate() ); 868 } 869 ); 870 require_once 'classes/woocommerce-blocks/banktransfer/BanktransferCardgate.php'; 871 add_action( 872 'woocommerce_blocks_payment_method_type_registration', 873 function( Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry $payment_method_registry ) { 874 $payment_method_registry->register( new \Automattic\WooCommerce\Blocks\Payments\Integrations\BanktransferCardgate() ); 875 } 876 ); 877 require_once 'classes/woocommerce-blocks/billink/BillinkCardgate.php'; 878 add_action( 879 'woocommerce_blocks_payment_method_type_registration', 880 function( Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry $payment_method_registry ) { 881 $payment_method_registry->register( new \Automattic\WooCommerce\Blocks\Payments\Integrations\BillinkCardgate() ); 882 } 883 ); 884 require_once 'classes/woocommerce-blocks/bitcoin/BitcoinCardgate.php'; 885 add_action( 886 'woocommerce_blocks_payment_method_type_registration', 887 function( Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry $payment_method_registry ) { 888 $payment_method_registry->register( new \Automattic\WooCommerce\Blocks\Payments\Integrations\BitcoinCardgate() ); 889 } 890 ); 891 require_once 'classes/woocommerce-blocks/creditcard/CreditcardCardgate.php'; 892 add_action( 893 'woocommerce_blocks_payment_method_type_registration', 894 function( Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry $payment_method_registry ) { 895 $payment_method_registry->register( new \Automattic\WooCommerce\Blocks\Payments\Integrations\CreditcardCardgate() ); 896 } 897 ); 898 require_once 'classes/woocommerce-blocks/directdebit/DirectDebitCardgate.php'; 899 add_action( 900 'woocommerce_blocks_payment_method_type_registration', 901 function( Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry $payment_method_registry ) { 902 $payment_method_registry->register( new \Automattic\WooCommerce\Blocks\Payments\Integrations\DirectDebitCardgate() ); 903 } 904 ); 905 require_once 'classes/woocommerce-blocks/giftcard/GiftcardCardgate.php'; 906 add_action( 907 'woocommerce_blocks_payment_method_type_registration', 908 function( Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry $payment_method_registry ) { 909 $payment_method_registry->register( new \Automattic\WooCommerce\Blocks\Payments\Integrations\GiftcardCardgate() ); 910 } 911 ); 912 require_once 'classes/woocommerce-blocks/ideal/IdealCardgate.php'; 913 add_action( 914 'woocommerce_blocks_payment_method_type_registration', 915 function( Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry $payment_method_registry ) { 916 $payment_method_registry->register( new \Automattic\WooCommerce\Blocks\Payments\Integrations\IdealCardgate() ); 917 } 918 ); 919 require_once 'classes/woocommerce-blocks/idealqr/IdealqrCardgate.php'; 920 add_action( 921 'woocommerce_blocks_payment_method_type_registration', 922 function( Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry $payment_method_registry ) { 923 $payment_method_registry->register( new \Automattic\WooCommerce\Blocks\Payments\Integrations\IdealqrCardgate() ); 924 } 925 ); 926 require_once 'classes/woocommerce-blocks/klarna/KlarnaCardgate.php'; 927 add_action( 928 'woocommerce_blocks_payment_method_type_registration', 929 function( Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry $payment_method_registry ) { 930 $payment_method_registry->register( new \Automattic\WooCommerce\Blocks\Payments\Integrations\KlarnaCardgate() ); 931 } 932 ); 933 require_once 'classes/woocommerce-blocks/onlineueberweisen/OnlineueberweisenCardgate.php'; 934 add_action( 935 'woocommerce_blocks_payment_method_type_registration', 936 function( Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry $payment_method_registry ) { 937 $payment_method_registry->register( new \Automattic\WooCommerce\Blocks\Payments\Integrations\OnlineueberweisenCardgate() ); 938 } 939 ); 940 require_once 'classes/woocommerce-blocks/paypal/PaypalCardgate.php'; 941 add_action( 942 'woocommerce_blocks_payment_method_type_registration', 943 function( Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry $payment_method_registry ) { 944 $payment_method_registry->register( new \Automattic\WooCommerce\Blocks\Payments\Integrations\PaypalCardgate() ); 945 } 946 ); 947 require_once 'classes/woocommerce-blocks/paysafecard/PaysafecardCardgate.php'; 948 add_action( 949 'woocommerce_blocks_payment_method_type_registration', 950 function( Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry $payment_method_registry ) { 951 $payment_method_registry->register( new \Automattic\WooCommerce\Blocks\Payments\Integrations\PaysafecardCardgate() ); 952 } 953 ); 954 require_once 'classes/woocommerce-blocks/paysafecash/PaysafecashCardgate.php'; 955 add_action( 956 'woocommerce_blocks_payment_method_type_registration', 957 function( Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry $payment_method_registry ) { 958 $payment_method_registry->register( new \Automattic\WooCommerce\Blocks\Payments\Integrations\PaysafecashCardgate() ); 959 } 960 ); 961 require_once 'classes/woocommerce-blocks/przelewy24/Przelewy24Cardgate.php'; 962 add_action( 963 'woocommerce_blocks_payment_method_type_registration', 964 function( Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry $payment_method_registry ) { 965 $payment_method_registry->register( new \Automattic\WooCommerce\Blocks\Payments\Integrations\Przelewy24Cardgate() ); 966 } 967 ); 968 require_once 'classes/woocommerce-blocks/sofortbanking/SofortbankingCardgate.php'; 969 add_action( 970 'woocommerce_blocks_payment_method_type_registration', 971 function( Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry $payment_method_registry ) { 972 $payment_method_registry->register( new \Automattic\WooCommerce\Blocks\Payments\Integrations\SofortbankingCardgate() ); 973 } 974 ); 975 require_once 'classes/woocommerce-blocks/spraypay/SpraypayCardgate.php'; 976 add_action( 977 'woocommerce_blocks_payment_method_type_registration', 978 function( Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry $payment_method_registry ) { 979 $payment_method_registry->register( new \Automattic\WooCommerce\Blocks\Payments\Integrations\SpraypayCardgate() ); 980 } 981 ); 982 } 983 984 public function cardgate_checkout_fees() { 985 global $woocommerce; 986 if ( isset( $_POST ) && $this->is_ajax_block_update( $_POST ) ) { 987 $method = $_POST['method']; 988 $feeData = $this->getFeeData($method); 989 990 $this->cartRemoveFee( $feeData['label'] ); 991 $newTotal = (float) $woocommerce->cart->get_totals()['total']; 992 $totalTax = $woocommerce->cart->get_totals()['total_tax']; 993 $noSurchargeData = [ 994 995 'amount' => false, 996 'name' => '', 997 'currency' => get_woocommerce_currency_symbol(), 998 'newTotal' => $newTotal, 999 'totalTax' => $totalTax, 1000 ]; 1001 if (!$feeData['fee'] || $feeData['fee'] == 0) { 1002 wp_send_json_success($noSurchargeData); 1003 return; 1004 } 1005 1006 $feeAmount = $feeData['fee']; 1007 $label = $feeData['label']; 1008 add_action('woocommerce_cart_calculate_fees', static function () use ($label, $feeAmount) { 1009 global $woocommerce; 1010 $woocommerce->cart->add_fee($label, $feeAmount, true, 'standard'); 1011 }); 1012 1013 //add global woocommerce. 1014 1015 $woocommerce->cart->calculate_totals(); 1016 1017 $feeAmountTaxed = (float) $woocommerce->cart->get_totals()['fee_total']; 1018 $taxDisplayMode = get_option('woocommerce_tax_display_shop'); 1019 if ($taxDisplayMode === 'incl') { 1020 $feeAmountTaxed = $feeAmountTaxed + (float) $woocommerce->cart->get_totals()['fee_tax']; 1021 } 1022 $newTotal = (float) $woocommerce->cart->get_totals()['total']; 1023 $totalTax = $woocommerce->cart->get_totals()['total_tax']; 1024 $data = [ 1025 'amount' => $feeAmountTaxed, 1026 'name' => $feeData['label'], 1027 'currency' => get_woocommerce_currency_symbol(), 1028 'newTotal' => $newTotal, 1029 'totalTax' => $totalTax, 1030 'cart' => $woocommerce->cart->get_totals(), 1031 ]; 1032 1033 wp_send_json_success($data); 1034 } 1035 } 1036 protected function cartRemoveFee($label) 1037 { 1038 add_action('woocommerce_before_calculate_totals', static function () use ($label) { 1039 $fees = WC()->cart->get_fees(); 1040 foreach ($fees as $key => $fee) { 1041 if ($fees[$key]->name === $label) { 1042 unset($fees[$key]); 1043 } 1044 } 1045 WC()->cart->fees_api()->set_fees($fees); 1046 }); 1047 } 1048 protected function getFeeData($method) { 1049 global $woocommerce; 1050 $woocommerce->cart; 1051 $woocommerce->cart->calculate_totals(); 1052 $data = []; 1053 $fee = get_option('woocommerce_' . $method . '_extra_charges'); 1054 $fee = $fee == "" ? 0: $fee; 1055 $label = get_option( 'woocommerce_' . $method . '_extra_charges_label'); 1056 $type = get_option('woocommerce_' . $method . '_extra_charges_type'); 1057 if (isset($label) && strlen($label) > 2) { 1058 if ($type == 'percentage'){ 1059 $label .= ' '. $fee.'%'; 1060 } 1061 } else { 1062 $label= $this->current_gateway_title . ' Payment Charges '; 1063 } 1064 1065 if ($type == "percentage") { 1066 $cart_total = (float) $woocommerce->cart->get_subtotal('edit'); 1067 $payment_fee = ($cart_total * $fee) / 100; 1068 } else { 1069 $payment_fee = $fee; 1070 } 1071 $data['fee'] = $payment_fee; 1072 $data['type'] = ($type == "percentage" ? $fee . '%' : 'Fixed'); 1073 $data['label'] = $label; 1074 return $data; 1075 } 834 1076 public function set_plugin_url() { 835 1077 $this->plugin_url = untrailingslashit(plugins_url('/', __FILE__)); … … 890 1132 spl_autoload_register('cardgate_autoload'); 891 1133 endif; 892 893 1134 ?> -
cardgate/trunk/classes/CGP_Common_Gateway.php
r2975181 r3054427 84 84 * Fetch bank options from Card Gate 85 85 */ 86 p rivatefunction getBankOptions() {86 public function getBankOptions() { 87 87 $this->checkBankOptions(); 88 88 $aIssuers = get_option( 'sIssuers' ); … … 200 200 global $woocommerce; 201 201 try { 202 202 $oOrder = new WC_Order( $iOrderId ); 203 $this->correct_payment_fee($oOrder); 204 $oOrder->save(); 203 205 $this->savePaymentData( $iOrderId ); 204 206 … … 207 209 $bIsTest = ( get_option( 'cgp_mode' ) == 1 ? true : false ); 208 210 $sLanguage = substr( get_locale(), 0, 2 ); 209 $oOrder = new WC_Order( $iOrderId );210 211 211 212 $sVersion = ( $this->get_woocommerce_version() == '' ? 'unkown' : $this->get_woocommerce_version() ); … … 369 370 return [ 370 371 'result' => 'success', 371 'redirect' => $woocommerce->cart->get_checkout_url()372 'redirect' => wc_get_checkout_url() 372 373 ]; 373 374 } … … 378 379 return [ 379 380 'result' => 'success', 380 'redirect' => $woocommerce->cart->get_checkout_url()381 'redirect' => wc_get_checkout_url() 381 382 ]; 382 383 } 383 384 } 385 386 protected function correct_payment_fee(&$oOrder) { 387 if ($this->has_block_checkout()){ 388 $fees = $oOrder->get_fees(); 389 $feeData = $this->getFeeData($oOrder->get_payment_method()); 390 $hasFee = array_key_exists('fee',$feeData) && $feeData['fee'] !== 0.0; 391 $correctedFee = false; 392 foreach ($fees as $fee) { 393 $feeName = $fee->get_name(); 394 $feeId = $fee->get_id(); 395 $hasCardgateFee = strpos($feeName, $feeData['label']) !== false; 396 if ($hasCardgateFee) { 397 if ($feeData['amount'] == (float)$fee->get_amount('edit')) { 398 $correctedFee = true; 399 continue; 400 } 401 if (!$correctedFee) { 402 $this->removeOrderFee($oOrder, $feeId); 403 $correctedFee = true; 404 continue; 405 } 406 $this->removeOrderFee($oOrder, $feeId); 407 $this->orderAddFee($oOrder, $feeData['fee'], $feeData['label']); 408 $correctedFee = true; 409 } 410 } 411 if (!$correctedFee) { 412 if ($hasFee) { 413 $this->orderAddFee($oOrder, $feeData['fee'], $feeData['label']); 414 } 415 } 416 } 417 if ($hasFee) { 418 $feeName = $feeData['label']; 419 $this->setSessionfee( $oOrder, $feeName ); 420 } 421 return $oOrder; 422 } 423 424 function setSessionFee($oOrder, $feeName){ 425 WC()->session->extra_cart_fee = WC()->session->extra_cart_fee_tax = 0; 426 $aFees = $oOrder->get_fees(); 427 foreach($aFees as $fee){ 428 if($fee['name'] == $feeName){ 429 WC()->session->extra_cart_fee = $fee->get_total(); 430 WC()->session->extra_cart_fee_tax = $fee->get_total_tax(); 431 } 432 } 433 } 434 435 protected function removeOrderFee(&$oOrder, int $feeId) { 436 $oOrder->remove_item($feeId); 437 wc_delete_order_item($feeId); 438 $oOrder->calculate_totals(); 439 } 440 441 protected function orderAddFee(&$oOrder, $amount, $feeName) { 442 $item_fee = new \WC_Order_Item_Fee(); 443 $item_fee->set_name($feeName); 444 $item_fee->set_amount($amount); 445 $item_fee->set_total($amount); 446 $item_fee->set_tax_status(true); 447 $oOrder->add_item($item_fee); 448 $oOrder->calculate_totals(); 449 } 450 451 protected function getFeeData($method) { 452 global $woocommerce; 453 $woocommerce->cart; 454 $woocommerce->cart->calculate_totals(); 455 $data = []; 456 $fee = get_option('woocommerce_' . $method . '_extra_charges'); 457 $fee = $fee == "" ? 0: $fee; 458 $label = get_option( 'woocommerce_' . $method . '_extra_charges_label'); 459 $type = get_option('woocommerce_' . $method . '_extra_charges_type'); 460 if (isset($label) && strlen($label) > 2) { 461 if ($type == 'percentage'){ 462 $label .= ' '. $fee.'%'; 463 } 464 } else { 465 $label= $this->current_gateway_title . ' Payment Charges '; 466 } 467 468 if ($type == "percentage") { 469 $cart_total = (float) $woocommerce->cart->get_subtotal('edit'); 470 $payment_fee = ($cart_total * $fee) / 100; 471 } else { 472 $payment_fee = $fee; 473 } 474 $data['fee'] = $payment_fee; 475 $data['type'] = ($type == "percentage" ? $fee . '%' : 'Fixed'); 476 $data['label'] = $label; 477 return $data; 478 } 479 480 public function has_block_checkout(){ 481 $uses_blocks = class_exists( 'Automattic\WooCommerce\Blocks\Payments\Integrations\AbstractPaymentMethodType'); 482 $isClassicCheckout = isset($_REQUEST["wc-ajax"]) && $_REQUEST["wc-ajax"] === "checkout"; 483 return ($uses_blocks && !$isClassicCheckout); 484 } 384 485 385 486 // //////////////////////////////////////////////// … … 479 580 } 480 581 } 481 if ( WC()->version < '3.0.0' ) { 482 $order_id = $order->id; 483 } else { 484 $order_id = $order->get_id(); 485 } 582 583 $order_id = $order->get_id(); 486 584 487 585 $data = [ … … 634 732 $fpExtraFee = ( empty( $woocommerce->session->extra_cart_fee ) ? 0 : $woocommerce->session->extra_cart_fee ); 635 733 $iExtraFee = round( $fpExtraFee * 100 ); 636 637 if ( $iExtraFee > 0 ) { 734 $fpExtraFeeTax = ( empty( $woocommerce->session->extra_cart_fee_tax ) ? 0 : $woocommerce->session->extra_cart_fee_tax ); 735 $iExtraFeeTax = round( $fpExtraFeeTax * 100 ); 736 737 if ($iExtraFeeTax > 0){ 738 $iTaxRate = round($iExtraFeeTax / $fpExtraFee,2); 739 $nr ++; 740 $items[ $nr ]['type'] = 'paymentfee'; 741 $items[ $nr ]['model'] = 'extra_costs'; 742 $items[ $nr ]['name'] = 'payment_fee'; 743 $items[ $nr ]['quantity'] = 1; 744 $items[ $nr ]['price_wt'] = $iExtraFee; 745 $items[ $nr ]['vat'] = $iTaxRate; 746 $items[ $nr ]['vat_amount'] = $iExtraFeeTax; 747 748 } elseif ( $iExtraFee > 0 ) { 638 749 639 750 $nr ++; … … 666 777 } 667 778 668 $iTaxDifference = round( $oOrder->get_total_tax() * 100 ) - $iCartItemTaxTotal - $ishippingTaxTotal - $i DiscountTaxTotal;779 $iTaxDifference = round( $oOrder->get_total_tax() * 100 ) - $iCartItemTaxTotal - $ishippingTaxTotal - $iExtraFeeTax - $iDiscountTaxTotal; 669 780 if ( $iTaxDifference != 0 ) { 670 781 $nr ++; … … 678 789 } 679 790 680 $iCorrection = round( $iOrderTotal - $iCartItemTotal - $iCartItemTaxTotal - $iShippingTotal - $ishippingTaxTotal - $iExtraFee - $i TaxDifference - $iDiscountTotal - $iDiscountTaxTotal);791 $iCorrection = round( $iOrderTotal - $iCartItemTotal - $iCartItemTaxTotal - $iShippingTotal - $ishippingTaxTotal - $iExtraFee - $iExtraFeeTax - $iTaxDifference - $iDiscountTotal - $iDiscountTaxTotal); 681 792 682 793 if ( $iCorrection != 0 ) { … … 706 817 public function validate_fields() { 707 818 global $woocommerce; 708 709 if ( $_POST['payment_method'] == 'cardgateideal' ) { 819 if (key_exists('wc-cardgateideal-new-payment-method',$_POST)) { 820 if ( empty( $_POST['cardgateideal_issuer'] ) || $_POST['cardgateideal_issuer'] == '0' ) { 821 wc_add_notice( __( ' Choose your bank first, please', 'cardgate' ), 'error' ); 822 return false; 823 } else { 824 $this->bankOption = $_POST['cardgateideal_issuer']; 825 } 826 } elseif (key_exists('payment_method', $_POST) && $_POST['payment_method'] == 'cardgateideal' ) { 710 827 if ( empty( $_POST['cgp_bank_options'] ) || $_POST['cgp_bank_options'] == '0' ) { 711 828 wc_add_notice( __( ' Choose your bank first, please', 'cardgate' ), 'error' ); 712 713 829 return false; 714 830 } else { -
cardgate/trunk/classes/WC_CardgateIdealqr.php
r2491968 r3054427 11 11 class WC_CardgateIdealqr extends CGP_Common_Gateway { 12 12 13 var $id = 'cardgate aIdealqr';13 var $id = 'cardgateidealqr'; 14 14 var $title = ''; 15 15 var $method_title = 'Cardgate iDEAL QR'; -
cardgate/trunk/readme.txt
r3008166 r3054427 5 5 Requires at least: 4.4 6 6 Tested up to: 6.4 7 Stable tag: 3.1.2 77 Stable tag: 3.1.28 8 8 License: GPLv3 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-3.0.html … … 75 75 76 76 == Changelog == 77 78 = 3.1.28 = 79 * Added: Woocommerce block compatibility 77 80 78 81 = 3.1.27 =
Note: See TracChangeset
for help on using the changeset viewer.