Changeset 3340282
- Timestamp:
- 08/06/2025 10:37:08 AM (7 months ago)
- Location:
- cardgate
- Files:
-
- 10 added
- 10 edited
- 1 copied
-
tags/4.0.0 (copied) (copied from cardgate/trunk)
-
tags/4.0.0/cardgate-clientlib-php/src/Client.php (modified) (1 diff)
-
tags/4.0.0/cardgate-clientlib-php/src/Method.php (modified) (2 diffs)
-
tags/4.0.0/cardgate.php (modified) (8 diffs)
-
tags/4.0.0/classes/CGP_Common_Gateway.php (modified) (2 diffs)
-
tags/4.0.0/classes/WC_CardgateCrypto.php (added)
-
tags/4.0.0/classes/woocommerce-blocks/crypto (added)
-
tags/4.0.0/classes/woocommerce-blocks/crypto/CryptoCardgate.php (added)
-
tags/4.0.0/classes/woocommerce-blocks/crypto/build (added)
-
tags/4.0.0/classes/woocommerce-blocks/crypto/build/index.js (added)
-
tags/4.0.0/readme.txt (modified) (2 diffs)
-
trunk/cardgate-clientlib-php/src/Client.php (modified) (1 diff)
-
trunk/cardgate-clientlib-php/src/Method.php (modified) (2 diffs)
-
trunk/cardgate.php (modified) (8 diffs)
-
trunk/classes/CGP_Common_Gateway.php (modified) (2 diffs)
-
trunk/classes/WC_CardgateCrypto.php (added)
-
trunk/classes/woocommerce-blocks/crypto (added)
-
trunk/classes/woocommerce-blocks/crypto/CryptoCardgate.php (added)
-
trunk/classes/woocommerce-blocks/crypto/build (added)
-
trunk/classes/woocommerce-blocks/crypto/build/index.js (added)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
cardgate/tags/4.0.0/cardgate-clientlib-php/src/Client.php
r2846253 r3340282 36 36 * Client version. 37 37 */ 38 const CLIENT_VERSION = "1.1. 18";38 const CLIENT_VERSION = "1.1.20"; 39 39 40 40 /** -
cardgate/tags/4.0.0/cardgate-clientlib-php/src/Method.php
r2588602 r3340282 143 143 const SPRAYPAY = 'spraypay'; 144 144 145 /** 146 * Crypto 147 */ 148 const CRYPTO = 'crypto'; 149 145 150 /** 146 151 * The client associated with this payment method. … … 253 258 */ 254 259 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 277 262 } 278 263 -
cardgate/tags/4.0.0/cardgate.php
r3320644 r3340282 7 7 * Author: CardGate 8 8 * Author URI: https://www.cardgate.com 9 * Version: 3.2.69 * Version: 4.0.0 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: 9.9.514 * WC tested up to: 10.0.4 15 15 * License: GPLv3 or later 16 * Requires Plugins: woocommerce 16 17 */ 17 18 … … 28 29 'Billink', 29 30 'Bitcoin', 31 'Crypto', 30 32 'Creditcard', 31 33 'DirectDebit', … … 157 159 require_once 'classes/WC_CardgateBillink.php'; 158 160 require_once 'classes/WC_CardgateBitcoin.php'; 161 require_once 'classes/WC_CardgateCrypto.php'; 159 162 require_once 'classes/WC_CardgateCreditcard.php'; 160 163 require_once 'classes/WC_CardgateDirectDebit.php'; … … 350 353 add_submenu_page($parentSlug = 'cardgate_menu', $pageTitle = __('Settings', 'cardgate'), $menuTitle = __('Settings', 'cardgate'), $capability = 'manage_options', $menuSlug = 'cardgate_menu', $function = array( 351 354 __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;359 355 } 360 356 … … 449 445 exit('HashCheck failed.'); 450 446 } 451 452 // Refurbish the ref so we get the orderno 453 $sOrderType = substr($_REQUEST['reference'], 0, 1); 447 454 448 $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 475 450 // 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(); 480 453 481 454 if (($sOrderStatus != 'processing' && $sOrderStatus != 'completed')) { 482 455 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'] ); 486 457 $order->payment_complete(); 487 458 } 488 // process order489 459 490 460 if ($_REQUEST['code'] == '0') { … … 496 466 if ($_REQUEST['code'] >= '300' && $_REQUEST['code'] < '400') { 497 467 $order->update_status('failed'); 498 499 468 $sReturnStatus = 'failed'; 500 469 } … … 505 474 506 475 $order->add_order_note('Curo transaction (' . $_REQUEST['transaction'] . ') payment ' . $sReturnStatus . '.'); 507 508 $sSubscription = (empty($_REQUEST['subscription']) ? 0 : $_REQUEST['subscription']);509 // update payment table510 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 }514 476 exit($_REQUEST['transaction'] . '.' . $_REQUEST['code']); 515 477 } else { … … 810 772 require_once 'classes/woocommerce-blocks/billink/BillinkCardgate.php'; 811 773 require_once 'classes/woocommerce-blocks/bitcoin/BitcoinCardgate.php'; 774 require_once 'classes/woocommerce-blocks/crypto/CryptoCardgate.php'; 812 775 require_once 'classes/woocommerce-blocks/creditcard/CreditcardCardgate.php'; 813 776 require_once 'classes/woocommerce-blocks/directdebit/DirectDebitCardgate.php'; -
cardgate/tags/4.0.0/classes/CGP_Common_Gateway.php
r3320644 r3340282 161 161 global $woocommerce; 162 162 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 ); 170 164 $iMerchantId = ( get_option( 'cgp_merchant_id' ) ? get_option( 'cgp_merchant_id' ) : 0 ); 171 165 $sMerchantApiKey = ( get_option( 'cgp_merchant_api_key' ) ? get_option( 'cgp_merchant_api_key' ) : 0 ); 172 166 $bIsTest = ( get_option( 'cgp_mode' ) == 1 ? true : false ); 173 167 $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() ); 176 169 177 170 $oCardGate = new cardgate\api\Client( (int) $iMerchantId, $sMerchantApiKey, $bIsTest ); 178 171 179 172 $oCardGate->setIp( $_SERVER['REMOTE_ADDR'] ); 180 181 173 $oCardGate->setLanguage( $sLanguage ); 182 174 $oCardGate->version()->setPlatformName( 'Woocommerce' ); … … 342 334 } 343 335 } 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 gateway378 if ( $hasFee ) {379 $feeName = $feeData['label'];380 $this->setSessionfee( $oOrder, $feeName );381 }382 383 return $oOrder;384 }385 386 336 function setSessionFee($oOrder, $feeName){ 387 337 WC()->session->extra_cart_fee = WC()->session->extra_cart_fee_tax = 0; -
cardgate/tags/4.0.0/readme.txt
r3320644 r3340282 5 5 Requires at least: 4.4 6 6 Tested up to: 6.8 7 Stable tag: 3.2.67 Stable tag: 4.0.0 8 8 License: GPLv3 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-3.0.html … … 75 75 == Changelog == 76 76 77 = 4.0.0 = 78 * Added: Payment method Crypto 79 * Fix: Double payment fee. 80 * Removed: Payment table. 81 77 82 = 3.2.6 = 78 83 * Added: Currency check -
cardgate/trunk/cardgate-clientlib-php/src/Client.php
r2846253 r3340282 36 36 * Client version. 37 37 */ 38 const CLIENT_VERSION = "1.1. 18";38 const CLIENT_VERSION = "1.1.20"; 39 39 40 40 /** -
cardgate/trunk/cardgate-clientlib-php/src/Method.php
r2588602 r3340282 143 143 const SPRAYPAY = 'spraypay'; 144 144 145 /** 146 * Crypto 147 */ 148 const CRYPTO = 'crypto'; 149 145 150 /** 146 151 * The client associated with this payment method. … … 253 258 */ 254 259 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 277 262 } 278 263 -
cardgate/trunk/cardgate.php
r3320644 r3340282 7 7 * Author: CardGate 8 8 * Author URI: https://www.cardgate.com 9 * Version: 3.2.69 * Version: 4.0.0 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: 9.9.514 * WC tested up to: 10.0.4 15 15 * License: GPLv3 or later 16 * Requires Plugins: woocommerce 16 17 */ 17 18 … … 28 29 'Billink', 29 30 'Bitcoin', 31 'Crypto', 30 32 'Creditcard', 31 33 'DirectDebit', … … 157 159 require_once 'classes/WC_CardgateBillink.php'; 158 160 require_once 'classes/WC_CardgateBitcoin.php'; 161 require_once 'classes/WC_CardgateCrypto.php'; 159 162 require_once 'classes/WC_CardgateCreditcard.php'; 160 163 require_once 'classes/WC_CardgateDirectDebit.php'; … … 350 353 add_submenu_page($parentSlug = 'cardgate_menu', $pageTitle = __('Settings', 'cardgate'), $menuTitle = __('Settings', 'cardgate'), $capability = 'manage_options', $menuSlug = 'cardgate_menu', $function = array( 351 354 __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;359 355 } 360 356 … … 449 445 exit('HashCheck failed.'); 450 446 } 451 452 // Refurbish the ref so we get the orderno 453 $sOrderType = substr($_REQUEST['reference'], 0, 1); 447 454 448 $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 475 450 // 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(); 480 453 481 454 if (($sOrderStatus != 'processing' && $sOrderStatus != 'completed')) { 482 455 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'] ); 486 457 $order->payment_complete(); 487 458 } 488 // process order489 459 490 460 if ($_REQUEST['code'] == '0') { … … 496 466 if ($_REQUEST['code'] >= '300' && $_REQUEST['code'] < '400') { 497 467 $order->update_status('failed'); 498 499 468 $sReturnStatus = 'failed'; 500 469 } … … 505 474 506 475 $order->add_order_note('Curo transaction (' . $_REQUEST['transaction'] . ') payment ' . $sReturnStatus . '.'); 507 508 $sSubscription = (empty($_REQUEST['subscription']) ? 0 : $_REQUEST['subscription']);509 // update payment table510 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 }514 476 exit($_REQUEST['transaction'] . '.' . $_REQUEST['code']); 515 477 } else { … … 810 772 require_once 'classes/woocommerce-blocks/billink/BillinkCardgate.php'; 811 773 require_once 'classes/woocommerce-blocks/bitcoin/BitcoinCardgate.php'; 774 require_once 'classes/woocommerce-blocks/crypto/CryptoCardgate.php'; 812 775 require_once 'classes/woocommerce-blocks/creditcard/CreditcardCardgate.php'; 813 776 require_once 'classes/woocommerce-blocks/directdebit/DirectDebitCardgate.php'; -
cardgate/trunk/classes/CGP_Common_Gateway.php
r3320644 r3340282 161 161 global $woocommerce; 162 162 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 ); 170 164 $iMerchantId = ( get_option( 'cgp_merchant_id' ) ? get_option( 'cgp_merchant_id' ) : 0 ); 171 165 $sMerchantApiKey = ( get_option( 'cgp_merchant_api_key' ) ? get_option( 'cgp_merchant_api_key' ) : 0 ); 172 166 $bIsTest = ( get_option( 'cgp_mode' ) == 1 ? true : false ); 173 167 $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() ); 176 169 177 170 $oCardGate = new cardgate\api\Client( (int) $iMerchantId, $sMerchantApiKey, $bIsTest ); 178 171 179 172 $oCardGate->setIp( $_SERVER['REMOTE_ADDR'] ); 180 181 173 $oCardGate->setLanguage( $sLanguage ); 182 174 $oCardGate->version()->setPlatformName( 'Woocommerce' ); … … 342 334 } 343 335 } 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 gateway378 if ( $hasFee ) {379 $feeName = $feeData['label'];380 $this->setSessionfee( $oOrder, $feeName );381 }382 383 return $oOrder;384 }385 386 336 function setSessionFee($oOrder, $feeName){ 387 337 WC()->session->extra_cart_fee = WC()->session->extra_cart_fee_tax = 0; -
cardgate/trunk/readme.txt
r3320644 r3340282 5 5 Requires at least: 4.4 6 6 Tested up to: 6.8 7 Stable tag: 3.2.67 Stable tag: 4.0.0 8 8 License: GPLv3 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-3.0.html … … 75 75 == Changelog == 76 76 77 = 4.0.0 = 78 * Added: Payment method Crypto 79 * Fix: Double payment fee. 80 * Removed: Payment table. 81 77 82 = 3.2.6 = 78 83 * Added: Currency check
Note: See TracChangeset
for help on using the changeset viewer.