Plugin Directory

Changeset 3320644


Ignore:
Timestamp:
07/01/2025 01:00:42 PM (8 months ago)
Author:
CardGate
Message:

added currency check

Location:
cardgate
Files:
6 edited
1 copied

Legend:

Unmodified
Added
Removed
  • cardgate/tags/3.2.6/cardgate.php

    r3305647 r3320644  
    77 * Author: CardGate
    88 * Author URI: https://www.cardgate.com
    9  * Version: 3.2.5
     9 * Version: 3.2.6
    1010 * Text Domain: cardgate
    1111 * Domain Path: /i18n/languages
    1212 * Requires at least: 4.4
    1313 * WC requires at least: 3.0.0
    14  * WC tested up to: 9.8.4
     14 * WC tested up to: 9.9.5
    1515 * License: GPLv3 or later
    1616 */
  • cardgate/tags/3.2.6/classes/CGP_Common_Gateway.php

    r3305647 r3320644  
    2121    var $bSeperateSalesTax;
    2222    var $instructions;
    23     protected $only_euro_payments = ['cardgateideal',
    24         'cardgateidealqr',
    25         'cardgatebancontact',
    26         'cardgatebanktransfer',
    27         'cardgatebillink',
    28         'cardgatesofortbanking',
    29         'cardgatedirectdebit',
    30         'cardgateonlineueberweisen',
    31         'cardgatespraypay',
    32     ];
    3323
    3424    // ////////////////////////////////////////////////
     
    4737
    4838    /**
     39     *  Check if the currency is allowed for this payment method.
     40     *
     41     * @param $currency
     42     * @param $payment_method
     43     *
     44     * @return bool
     45     */
     46    public function check_payment_currency($currency,$payment_method) {
     47        $strictly_euro = in_array($payment_method,['cardgateideal',
     48            'cardgateidealqr',
     49            'cardgatebancontact',
     50            'cardgatebanktransfer',
     51            'cardgatebillink',
     52            'cardgatesofortbanking',
     53            'cardgatedirectdebit',
     54            'cardgateonlineueberweisen',
     55            'cardgatespraypay']);
     56        if ($strictly_euro && $currency != 'EUR') return false;
     57
     58        $strictly_pln = in_array($payment_method,['cardgateprzelewy24']);
     59        if ($strictly_pln && $currency != 'PLN') return false;
     60
     61        return true;
     62    }
     63
     64    /**
    4965     * Check if the gateway is available for use.
    5066     *
     
    5470        $is_available = ( 'yes' === $this->enabled );
    5571        $site_currency = get_woocommerce_currency() ;
    56         if ( WC()->cart && $site_currency !== 'EUR' && in_array($this->id, $this->only_euro_payments)) {
     72        if ( WC()->cart && !$this->check_payment_currency( $site_currency, $this->id ) ) {
    5773            $is_available = false;
    5874        }
  • cardgate/tags/3.2.6/readme.txt

    r3305647 r3320644  
    55Requires at least: 4.4
    66Tested up to: 6.8
    7 Stable tag: 3.2.5
     7Stable tag: 3.2.6
    88License: GPLv3 or later
    99License URI: https://www.gnu.org/licenses/gpl-3.0.html
     
    7575== Changelog ==
    7676
     77= 3.2.6 =
     78* Added: Currency check
     79
    7780= 3.2.5 =
    7881* Restrict payment methods by currency
  • cardgate/trunk/cardgate.php

    r3305647 r3320644  
    77 * Author: CardGate
    88 * Author URI: https://www.cardgate.com
    9  * Version: 3.2.5
     9 * Version: 3.2.6
    1010 * Text Domain: cardgate
    1111 * Domain Path: /i18n/languages
    1212 * Requires at least: 4.4
    1313 * WC requires at least: 3.0.0
    14  * WC tested up to: 9.8.4
     14 * WC tested up to: 9.9.5
    1515 * License: GPLv3 or later
    1616 */
  • cardgate/trunk/classes/CGP_Common_Gateway.php

    r3305647 r3320644  
    2121    var $bSeperateSalesTax;
    2222    var $instructions;
    23     protected $only_euro_payments = ['cardgateideal',
    24         'cardgateidealqr',
    25         'cardgatebancontact',
    26         'cardgatebanktransfer',
    27         'cardgatebillink',
    28         'cardgatesofortbanking',
    29         'cardgatedirectdebit',
    30         'cardgateonlineueberweisen',
    31         'cardgatespraypay',
    32     ];
    3323
    3424    // ////////////////////////////////////////////////
     
    4737
    4838    /**
     39     *  Check if the currency is allowed for this payment method.
     40     *
     41     * @param $currency
     42     * @param $payment_method
     43     *
     44     * @return bool
     45     */
     46    public function check_payment_currency($currency,$payment_method) {
     47        $strictly_euro = in_array($payment_method,['cardgateideal',
     48            'cardgateidealqr',
     49            'cardgatebancontact',
     50            'cardgatebanktransfer',
     51            'cardgatebillink',
     52            'cardgatesofortbanking',
     53            'cardgatedirectdebit',
     54            'cardgateonlineueberweisen',
     55            'cardgatespraypay']);
     56        if ($strictly_euro && $currency != 'EUR') return false;
     57
     58        $strictly_pln = in_array($payment_method,['cardgateprzelewy24']);
     59        if ($strictly_pln && $currency != 'PLN') return false;
     60
     61        return true;
     62    }
     63
     64    /**
    4965     * Check if the gateway is available for use.
    5066     *
     
    5470        $is_available = ( 'yes' === $this->enabled );
    5571        $site_currency = get_woocommerce_currency() ;
    56         if ( WC()->cart && $site_currency !== 'EUR' && in_array($this->id, $this->only_euro_payments)) {
     72        if ( WC()->cart && !$this->check_payment_currency( $site_currency, $this->id ) ) {
    5773            $is_available = false;
    5874        }
  • cardgate/trunk/readme.txt

    r3305647 r3320644  
    55Requires at least: 4.4
    66Tested up to: 6.8
    7 Stable tag: 3.2.5
     7Stable tag: 3.2.6
    88License: GPLv3 or later
    99License URI: https://www.gnu.org/licenses/gpl-3.0.html
     
    7575== Changelog ==
    7676
     77= 3.2.6 =
     78* Added: Currency check
     79
    7780= 3.2.5 =
    7881* Restrict payment methods by currency
Note: See TracChangeset for help on using the changeset viewer.