Plugin Directory

Changeset 3340282


Ignore:
Timestamp:
08/06/2025 10:37:08 AM (7 months ago)
Author:
CardGate
Message:

added crypto payment

Location:
cardgate
Files:
10 added
10 edited
1 copied

Legend:

Unmodified
Added
Removed
  • cardgate/tags/4.0.0/cardgate-clientlib-php/src/Client.php

    r2846253 r3340282  
    3636         * Client version.
    3737         */
    38         const CLIENT_VERSION = "1.1.18";
     38        const CLIENT_VERSION = "1.1.20";
    3939
    4040        /**
  • cardgate/tags/4.0.0/cardgate-clientlib-php/src/Method.php

    r2588602 r3340282  
    143143        const SPRAYPAY = 'spraypay';
    144144
     145        /**
     146         * Crypto
     147         */
     148        const CRYPTO = 'crypto';
     149
    145150        /**
    146151         * The client associated with this payment method.
     
    253258         */
    254259        public function getIssuers() {
    255 
    256             if ( TRUE ) {
    257                 // Use the static version which is automatically updated every day
    258                 $aResult = [
    259                     'issuers' => $this->_oClient->doRequest(
    260                         $this->_oClient->getTestMode()
    261                             ?   '../../../cache/idealDirectoryCUROPayments-TEST.json'
    262                             :   '../../../cache/idealDirectoryCUROPayments.json'
    263                         , NULL, 'GET'
    264                     )
    265                 ];
    266             } else {
    267                 // Retrieve using API call.
    268                 // TODO: The response should be cached on the local system for 24 hours!
    269                 $sResource = $this->_sId . '/issuers/';
    270                 $aResult = $this->_oClient->doRequest( $sResource, NULL, 'GET' );
    271             }
    272             if ( empty( $aResult['issuers'] ) ) {
    273                 throw new Exception( 'Method.Issuers.Invalid', 'invalid issuer data returned' );
    274             }
    275 
    276             return $aResult['issuers'];
     260            $aIssuers   = [0=>["id"=>"ZERO", "name"=>"Deprecated"]];
     261            return  $aIssuers; //Deprecated since iDEAL2
    277262        }
    278263
  • cardgate/tags/4.0.0/cardgate.php

    r3320644 r3340282  
    77 * Author: CardGate
    88 * Author URI: https://www.cardgate.com
    9  * Version: 3.2.6
     9 * Version: 4.0.0
    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.9.5
     14 * WC tested up to: 10.0.4
    1515 * License: GPLv3 or later
     16 * Requires Plugins: woocommerce
    1617 */
    1718
     
    2829                                'Billink',
    2930                                'Bitcoin',
     31                                'Crypto',
    3032                                'Creditcard',
    3133                                'DirectDebit',
     
    157159            require_once 'classes/WC_CardgateBillink.php';
    158160            require_once 'classes/WC_CardgateBitcoin.php';
     161            require_once 'classes/WC_CardgateCrypto.php';
    159162            require_once 'classes/WC_CardgateCreditcard.php';
    160163            require_once 'classes/WC_CardgateDirectDebit.php';
     
    350353        add_submenu_page($parentSlug = 'cardgate_menu', $pageTitle = __('Settings', 'cardgate'), $menuTitle = __('Settings', 'cardgate'), $capability = 'manage_options', $menuSlug = 'cardgate_menu', $function = array(
    351354            __CLASS__, 'cardgate_config_page' ));
    352        
    353         add_submenu_page($parentSlug = 'cardgate_menu', $pageTitle = __('Payments Table', 'cardgate'), $menuTitle = __('Payments Table', 'cardgate'), $capability = 'manage_options', $menuSlug = 'cardgate_payments_table', $function = array(
    354             __CLASS__,
    355             'cardgate_payments_table'
    356         ));
    357        
    358         global $submenu;
    359355    }
    360356
     
    449445                exit('HashCheck failed.');
    450446            }
    451            
    452             // Refurbish the ref so we get the orderno
    453             $sOrderType = substr($_REQUEST['reference'], 0, 1);
     447
    454448            $sOrderNo = (int) substr($_REQUEST['reference'], 11);
    455            
    456             // check if payment is still pending
    457             $tableName = $wpdb->prefix . 'cardgate_payments';
    458             $sql = $wpdb->prepare("SELECT * FROM $tableName WHERE order_id=%d", $sOrderNo);
    459            
    460             // Cause we also have recurring we need all records
    461             $aDB_Row = $wpdb->get_results($sql, ARRAY_A);
    462             // Get the last record
    463             $aLastRow = end($aDB_Row);
    464            
    465             $sql = $wpdb->prepare("SELECT * FROM $tableName WHERE order_id=%d order by id desc ", $sOrderNo);
    466             $aDB_Row = $wpdb->get_results($sql, ARRAY_A);
    467             // Get the first record
    468             $aFirstRow = end($aDB_Row);
    469             if (is_null($aFirstRow['transaction_id'])) {
    470                 $sParent_id = $_REQUEST['transaction'];
    471             } else {
    472                 $sParent_id = $aFirstRow['transaction_id'];
    473             }
    474            
     449
    475450            // process order
    476             $order = new WC_Order($sOrderNo);
    477             method_exists($order, 'get_status') ? $sOrderStatus = $order->get_status() : $sOrderStatus = $order->status;
    478            
    479             $amount = $order->get_total() * 100;
     451            $order        = new WC_Order($sOrderNo);
     452            $sOrderStatus = $order->get_status();
    480453           
    481454            if (($sOrderStatus != 'processing' && $sOrderStatus != 'completed')) {
    482455                if ($_REQUEST['code'] >= '200' && $_REQUEST['code'] < '300') {
    483                     if (WC()->version >='3.0.0') {
    484                         $order->set_transaction_id( $_REQUEST['transaction'] );
    485                     }
     456                    $order->set_transaction_id( $_REQUEST['transaction'] );
    486457                    $order->payment_complete();
    487458                }
    488                 // process order
    489459               
    490460                if ($_REQUEST['code'] == '0') {
     
    496466                if ($_REQUEST['code'] >= '300' && $_REQUEST['code'] < '400') {
    497467                    $order->update_status('failed');
    498                    
    499468                    $sReturnStatus = 'failed';
    500469                }
     
    505474               
    506475                $order->add_order_note('Curo transaction (' . $_REQUEST['transaction'] . ') payment ' . $sReturnStatus . '.');
    507                
    508                 $sSubscription = (empty($_REQUEST['subscription']) ? 0 : $_REQUEST['subscription']);
    509                 // update payment table
    510                 if ($aLastRow['status'] == 'pending') {
    511                     $qry = $wpdb->prepare("UPDATE $tableName SET status='" . $sReturnStatus . "', transaction_id='%s', parent_id='%s', subscription_id='%s' WHERE id=%d", $_REQUEST['transaction'], $sParent_id, $sSubscription, $aLastRow['id']);
    512                     $wpdb->query($qry);
    513                 }
    514476                exit($_REQUEST['transaction'] . '.' . $_REQUEST['code']);
    515477            } else {
     
    810772        require_once 'classes/woocommerce-blocks/billink/BillinkCardgate.php';
    811773        require_once 'classes/woocommerce-blocks/bitcoin/BitcoinCardgate.php';
     774        require_once 'classes/woocommerce-blocks/crypto/CryptoCardgate.php';
    812775        require_once 'classes/woocommerce-blocks/creditcard/CreditcardCardgate.php';
    813776        require_once 'classes/woocommerce-blocks/directdebit/DirectDebitCardgate.php';
  • cardgate/tags/4.0.0/classes/CGP_Common_Gateway.php

    r3320644 r3340282  
    161161        global $woocommerce;
    162162        try {
    163             $cart = $woocommerce->cart;
    164             $oOrder = new WC_Order( $iOrderId );
    165             $this->correct_payment_fee($oOrder);
    166             $oOrder->calculate_totals(false);
    167             $oOrder->save();
    168             $this->savePaymentData( $iOrderId );
    169 
     163            $oOrder          = new WC_Order( $iOrderId );
    170164            $iMerchantId     = ( get_option( 'cgp_merchant_id' ) ? get_option( 'cgp_merchant_id' ) : 0 );
    171165            $sMerchantApiKey = ( get_option( 'cgp_merchant_api_key' ) ? get_option( 'cgp_merchant_api_key' ) : 0 );
    172166            $bIsTest         = ( get_option( 'cgp_mode' ) == 1 ? true : false );
    173167            $sLanguage       = substr( get_locale(), 0, 2 );
    174 
    175             $sVersion = ( $this->get_woocommerce_version() == '' ? 'unkown' : $this->get_woocommerce_version() );
     168            $sVersion        = ( $this->get_woocommerce_version() == '' ? 'unkown' : $this->get_woocommerce_version() );
    176169
    177170            $oCardGate = new cardgate\api\Client( (int) $iMerchantId, $sMerchantApiKey, $bIsTest );
    178171
    179172            $oCardGate->setIp( $_SERVER['REMOTE_ADDR'] );
    180 
    181173            $oCardGate->setLanguage( $sLanguage );
    182174            $oCardGate->version()->setPlatformName( 'Woocommerce' );
     
    342334        }
    343335    }
    344 
    345     protected function correct_payment_fee(&$oOrder) {
    346         if ($this->has_block_checkout()){
    347             $fees = $oOrder->get_fees();
    348             $feeData = $this->getFeeData($oOrder->get_payment_method());
    349             $hasFee = array_key_exists('fee',$feeData) && $feeData['fee'] !== 0.0;
    350             $correctedFee = false;
    351             foreach ($fees as $fee) {
    352                 $feeName = $fee->get_name();
    353                 $feeId = $fee->get_id();
    354                 $hasCardgateFee = strpos($feeName, $feeData['label']) !== false;
    355                 if ($hasCardgateFee) {
    356                     if ($feeData['amount'] == (float)$fee->get_amount('edit')) {
    357                         $correctedFee = true;
    358                         continue;
    359                     }
    360                     if (!$correctedFee) {
    361                         $this->removeOrderFee($oOrder, $feeId);
    362                         $correctedFee = true;
    363                         continue;
    364                     }
    365                     $this->removeOrderFee($oOrder, $feeId);
    366                     $this->orderAddFee($oOrder, $feeData['fee'], $feeData['label']);
    367                     $correctedFee = true;
    368                 }
    369             }
    370             if (!$correctedFee) {
    371                 if ($hasFee) {
    372                     $this->orderAddFee($oOrder, $feeData['fee'], $feeData['label']);
    373                 }
    374             }
    375         }
    376 
    377         //forlegacy gateway
    378         if ( $hasFee ) {
    379             $feeName = $feeData['label'];
    380             $this->setSessionfee( $oOrder, $feeName );
    381         }
    382 
    383         return $oOrder;
    384     }
    385 
    386336    function setSessionFee($oOrder, $feeName){
    387337        WC()->session->extra_cart_fee = WC()->session->extra_cart_fee_tax = 0;
  • cardgate/tags/4.0.0/readme.txt

    r3320644 r3340282  
    55Requires at least: 4.4
    66Tested up to: 6.8
    7 Stable tag: 3.2.6
     7Stable tag: 4.0.0
    88License: GPLv3 or later
    99License URI: https://www.gnu.org/licenses/gpl-3.0.html
     
    7575== Changelog ==
    7676
     77= 4.0.0 =
     78* Added: Payment method Crypto
     79* Fix: Double payment fee.
     80* Removed: Payment table.
     81
    7782= 3.2.6 =
    7883* Added: Currency check
  • cardgate/trunk/cardgate-clientlib-php/src/Client.php

    r2846253 r3340282  
    3636         * Client version.
    3737         */
    38         const CLIENT_VERSION = "1.1.18";
     38        const CLIENT_VERSION = "1.1.20";
    3939
    4040        /**
  • cardgate/trunk/cardgate-clientlib-php/src/Method.php

    r2588602 r3340282  
    143143        const SPRAYPAY = 'spraypay';
    144144
     145        /**
     146         * Crypto
     147         */
     148        const CRYPTO = 'crypto';
     149
    145150        /**
    146151         * The client associated with this payment method.
     
    253258         */
    254259        public function getIssuers() {
    255 
    256             if ( TRUE ) {
    257                 // Use the static version which is automatically updated every day
    258                 $aResult = [
    259                     'issuers' => $this->_oClient->doRequest(
    260                         $this->_oClient->getTestMode()
    261                             ?   '../../../cache/idealDirectoryCUROPayments-TEST.json'
    262                             :   '../../../cache/idealDirectoryCUROPayments.json'
    263                         , NULL, 'GET'
    264                     )
    265                 ];
    266             } else {
    267                 // Retrieve using API call.
    268                 // TODO: The response should be cached on the local system for 24 hours!
    269                 $sResource = $this->_sId . '/issuers/';
    270                 $aResult = $this->_oClient->doRequest( $sResource, NULL, 'GET' );
    271             }
    272             if ( empty( $aResult['issuers'] ) ) {
    273                 throw new Exception( 'Method.Issuers.Invalid', 'invalid issuer data returned' );
    274             }
    275 
    276             return $aResult['issuers'];
     260            $aIssuers   = [0=>["id"=>"ZERO", "name"=>"Deprecated"]];
     261            return  $aIssuers; //Deprecated since iDEAL2
    277262        }
    278263
  • cardgate/trunk/cardgate.php

    r3320644 r3340282  
    77 * Author: CardGate
    88 * Author URI: https://www.cardgate.com
    9  * Version: 3.2.6
     9 * Version: 4.0.0
    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.9.5
     14 * WC tested up to: 10.0.4
    1515 * License: GPLv3 or later
     16 * Requires Plugins: woocommerce
    1617 */
    1718
     
    2829                                'Billink',
    2930                                'Bitcoin',
     31                                'Crypto',
    3032                                'Creditcard',
    3133                                'DirectDebit',
     
    157159            require_once 'classes/WC_CardgateBillink.php';
    158160            require_once 'classes/WC_CardgateBitcoin.php';
     161            require_once 'classes/WC_CardgateCrypto.php';
    159162            require_once 'classes/WC_CardgateCreditcard.php';
    160163            require_once 'classes/WC_CardgateDirectDebit.php';
     
    350353        add_submenu_page($parentSlug = 'cardgate_menu', $pageTitle = __('Settings', 'cardgate'), $menuTitle = __('Settings', 'cardgate'), $capability = 'manage_options', $menuSlug = 'cardgate_menu', $function = array(
    351354            __CLASS__, 'cardgate_config_page' ));
    352        
    353         add_submenu_page($parentSlug = 'cardgate_menu', $pageTitle = __('Payments Table', 'cardgate'), $menuTitle = __('Payments Table', 'cardgate'), $capability = 'manage_options', $menuSlug = 'cardgate_payments_table', $function = array(
    354             __CLASS__,
    355             'cardgate_payments_table'
    356         ));
    357        
    358         global $submenu;
    359355    }
    360356
     
    449445                exit('HashCheck failed.');
    450446            }
    451            
    452             // Refurbish the ref so we get the orderno
    453             $sOrderType = substr($_REQUEST['reference'], 0, 1);
     447
    454448            $sOrderNo = (int) substr($_REQUEST['reference'], 11);
    455            
    456             // check if payment is still pending
    457             $tableName = $wpdb->prefix . 'cardgate_payments';
    458             $sql = $wpdb->prepare("SELECT * FROM $tableName WHERE order_id=%d", $sOrderNo);
    459            
    460             // Cause we also have recurring we need all records
    461             $aDB_Row = $wpdb->get_results($sql, ARRAY_A);
    462             // Get the last record
    463             $aLastRow = end($aDB_Row);
    464            
    465             $sql = $wpdb->prepare("SELECT * FROM $tableName WHERE order_id=%d order by id desc ", $sOrderNo);
    466             $aDB_Row = $wpdb->get_results($sql, ARRAY_A);
    467             // Get the first record
    468             $aFirstRow = end($aDB_Row);
    469             if (is_null($aFirstRow['transaction_id'])) {
    470                 $sParent_id = $_REQUEST['transaction'];
    471             } else {
    472                 $sParent_id = $aFirstRow['transaction_id'];
    473             }
    474            
     449
    475450            // process order
    476             $order = new WC_Order($sOrderNo);
    477             method_exists($order, 'get_status') ? $sOrderStatus = $order->get_status() : $sOrderStatus = $order->status;
    478            
    479             $amount = $order->get_total() * 100;
     451            $order        = new WC_Order($sOrderNo);
     452            $sOrderStatus = $order->get_status();
    480453           
    481454            if (($sOrderStatus != 'processing' && $sOrderStatus != 'completed')) {
    482455                if ($_REQUEST['code'] >= '200' && $_REQUEST['code'] < '300') {
    483                     if (WC()->version >='3.0.0') {
    484                         $order->set_transaction_id( $_REQUEST['transaction'] );
    485                     }
     456                    $order->set_transaction_id( $_REQUEST['transaction'] );
    486457                    $order->payment_complete();
    487458                }
    488                 // process order
    489459               
    490460                if ($_REQUEST['code'] == '0') {
     
    496466                if ($_REQUEST['code'] >= '300' && $_REQUEST['code'] < '400') {
    497467                    $order->update_status('failed');
    498                    
    499468                    $sReturnStatus = 'failed';
    500469                }
     
    505474               
    506475                $order->add_order_note('Curo transaction (' . $_REQUEST['transaction'] . ') payment ' . $sReturnStatus . '.');
    507                
    508                 $sSubscription = (empty($_REQUEST['subscription']) ? 0 : $_REQUEST['subscription']);
    509                 // update payment table
    510                 if ($aLastRow['status'] == 'pending') {
    511                     $qry = $wpdb->prepare("UPDATE $tableName SET status='" . $sReturnStatus . "', transaction_id='%s', parent_id='%s', subscription_id='%s' WHERE id=%d", $_REQUEST['transaction'], $sParent_id, $sSubscription, $aLastRow['id']);
    512                     $wpdb->query($qry);
    513                 }
    514476                exit($_REQUEST['transaction'] . '.' . $_REQUEST['code']);
    515477            } else {
     
    810772        require_once 'classes/woocommerce-blocks/billink/BillinkCardgate.php';
    811773        require_once 'classes/woocommerce-blocks/bitcoin/BitcoinCardgate.php';
     774        require_once 'classes/woocommerce-blocks/crypto/CryptoCardgate.php';
    812775        require_once 'classes/woocommerce-blocks/creditcard/CreditcardCardgate.php';
    813776        require_once 'classes/woocommerce-blocks/directdebit/DirectDebitCardgate.php';
  • cardgate/trunk/classes/CGP_Common_Gateway.php

    r3320644 r3340282  
    161161        global $woocommerce;
    162162        try {
    163             $cart = $woocommerce->cart;
    164             $oOrder = new WC_Order( $iOrderId );
    165             $this->correct_payment_fee($oOrder);
    166             $oOrder->calculate_totals(false);
    167             $oOrder->save();
    168             $this->savePaymentData( $iOrderId );
    169 
     163            $oOrder          = new WC_Order( $iOrderId );
    170164            $iMerchantId     = ( get_option( 'cgp_merchant_id' ) ? get_option( 'cgp_merchant_id' ) : 0 );
    171165            $sMerchantApiKey = ( get_option( 'cgp_merchant_api_key' ) ? get_option( 'cgp_merchant_api_key' ) : 0 );
    172166            $bIsTest         = ( get_option( 'cgp_mode' ) == 1 ? true : false );
    173167            $sLanguage       = substr( get_locale(), 0, 2 );
    174 
    175             $sVersion = ( $this->get_woocommerce_version() == '' ? 'unkown' : $this->get_woocommerce_version() );
     168            $sVersion        = ( $this->get_woocommerce_version() == '' ? 'unkown' : $this->get_woocommerce_version() );
    176169
    177170            $oCardGate = new cardgate\api\Client( (int) $iMerchantId, $sMerchantApiKey, $bIsTest );
    178171
    179172            $oCardGate->setIp( $_SERVER['REMOTE_ADDR'] );
    180 
    181173            $oCardGate->setLanguage( $sLanguage );
    182174            $oCardGate->version()->setPlatformName( 'Woocommerce' );
     
    342334        }
    343335    }
    344 
    345     protected function correct_payment_fee(&$oOrder) {
    346         if ($this->has_block_checkout()){
    347             $fees = $oOrder->get_fees();
    348             $feeData = $this->getFeeData($oOrder->get_payment_method());
    349             $hasFee = array_key_exists('fee',$feeData) && $feeData['fee'] !== 0.0;
    350             $correctedFee = false;
    351             foreach ($fees as $fee) {
    352                 $feeName = $fee->get_name();
    353                 $feeId = $fee->get_id();
    354                 $hasCardgateFee = strpos($feeName, $feeData['label']) !== false;
    355                 if ($hasCardgateFee) {
    356                     if ($feeData['amount'] == (float)$fee->get_amount('edit')) {
    357                         $correctedFee = true;
    358                         continue;
    359                     }
    360                     if (!$correctedFee) {
    361                         $this->removeOrderFee($oOrder, $feeId);
    362                         $correctedFee = true;
    363                         continue;
    364                     }
    365                     $this->removeOrderFee($oOrder, $feeId);
    366                     $this->orderAddFee($oOrder, $feeData['fee'], $feeData['label']);
    367                     $correctedFee = true;
    368                 }
    369             }
    370             if (!$correctedFee) {
    371                 if ($hasFee) {
    372                     $this->orderAddFee($oOrder, $feeData['fee'], $feeData['label']);
    373                 }
    374             }
    375         }
    376 
    377         //forlegacy gateway
    378         if ( $hasFee ) {
    379             $feeName = $feeData['label'];
    380             $this->setSessionfee( $oOrder, $feeName );
    381         }
    382 
    383         return $oOrder;
    384     }
    385 
    386336    function setSessionFee($oOrder, $feeName){
    387337        WC()->session->extra_cart_fee = WC()->session->extra_cart_fee_tax = 0;
  • cardgate/trunk/readme.txt

    r3320644 r3340282  
    55Requires at least: 4.4
    66Tested up to: 6.8
    7 Stable tag: 3.2.6
     7Stable tag: 4.0.0
    88License: GPLv3 or later
    99License URI: https://www.gnu.org/licenses/gpl-3.0.html
     
    7575== Changelog ==
    7676
     77= 4.0.0 =
     78* Added: Payment method Crypto
     79* Fix: Double payment fee.
     80* Removed: Payment table.
     81
    7782= 3.2.6 =
    7883* Added: Currency check
Note: See TracChangeset for help on using the changeset viewer.