Changeset 3084475
- Timestamp:
- 05/10/2024 10:22:32 AM (21 months ago)
- Location:
- geidea-online-payments/trunk
- Files:
-
- 2 added
- 4 edited
-
assets/js/checkout.js (added)
-
class.blocks-checkout.php (added)
-
class.geidea.php (modified) (3 diffs)
-
functions/ProcessPayment.php (modified) (3 diffs)
-
readme.txt (modified) (2 diffs)
-
wc-geidea.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
geidea-online-payments/trunk/class.geidea.php
r3066643 r3084475 8 8 * @class WC_Geidea 9 9 * @extends WC_Payment_Gateway 10 * @version 3. 1.110 * @version 3.2.0 11 11 * @author Geidea 12 12 */ … … 110 110 add_action('wp_ajax_ajax_order', array('WC_Gateway_Geidea', 'init_payment')); 111 111 add_action('wp_ajax_nopriv_ajax_order', array('WC_Gateway_Geidea', 'init_payment')); 112 add_action('wp_enqueue_scripts', array($this, 'payment_scripts')); 112 113 } 113 114 … … 171 172 return $settings; 172 173 } 174 175 public function payment_scripts() 176 { 177 if (!isset($_GET['geidea-session'])) { 178 return; 179 } 180 if ($this->enabled === 'no') { 181 return; 182 } 183 if (!isset($_GET['geidea_session_nonce']) || !wp_verify_nonce(sanitize_key(wp_unslash($_GET['geidea_session_nonce'])), 'geidea_session_action')) { 184 echo '<script>alert("Nonce Verification Failed")</script>'; 185 echo '<script>setTimeout(document.location.href = "' . wc_get_checkout_url() . '", 1000)</script>'; 186 return; 187 } 188 189 $data_string = urldecode(wp_unslash($_GET['geidea-session'])); // phpcs:ignore 190 $data_array = json_decode($data_string, true); 191 192 ?> 193 <div style="display: none;"> 194 <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> 195 <script src='<?php echo $this->config['jsSdkUrl']; ?>'></script> 196 <script> 197 let y_offsetWhenScrollDisabled = 0; 198 199 function disableScrollOnBody() { 200 y_offsetWhenScrollDisabled = jQuery(window).scrollTop(); 201 jQuery('body').addClass('scrollDisabled').css('margin-top', -y_offsetWhenScrollDisabled); 202 } 203 204 function enableScrollOnBody() { 205 jQuery('body').removeClass('scrollDisabled').css('margin-top', 0); 206 jQuery(window).scrollTop(y_offsetWhenScrollDisabled); 207 } 208 209 let onError = function(error) { 210 enableScrollOnBody(); 211 jQuery("#place_order").removeAttr("disabled"); 212 alert("Geidea Payment Gateway error: " + error.responseMessage); 213 setTimeout(document.location.href = '<?php echo wc_get_checkout_url(); ?>', 1000); 214 } 215 216 let onCancel = function() { 217 enableScrollOnBody(); 218 jQuery("#place_order").removeAttr("disabled"); 219 setTimeout(document.location.href = '<?php echo wc_get_checkout_url(); ?>', 1000); 220 } 221 222 const startV2HPP = (data) => { 223 console.log("Session create API response", data); 224 disableScrollOnBody(); 225 let onSuccess = function(_message, _statusCode) { 226 setTimeout(document.location.href = data.successUrl, 1000); 227 } 228 try { 229 if (data.responseCode !== '000') { 230 throw data 231 } 232 const api = new GeideaCheckout(onSuccess, onError, onCancel); 233 api.startPayment(data.session.id); 234 } catch (error) { 235 let receivedError; 236 const errorFields = []; 237 238 if (error.status && error.errors) { 239 const errorsObject = error.errors; 240 241 for (const key of Object.keys(errorsObject)) { 242 errorFields.push(key.replace('$.', '')) 243 } 244 receivedError = { 245 responseCode: '100', 246 responseMessage: 'Field formatting errors', 247 detailResponseMessage: `Fields with errors: ${errorFields.toString()}`, 248 reference: error.reference, 249 detailResponseCode: null, 250 orderId: null 251 } 252 } else { 253 receivedError = { 254 responseCode: error.responseCode, 255 responseMessage: error.responseMessage, 256 detailResponseMessage: error.detailedResponseMessage, 257 detailResponseCode: error.detailedResponseCode, 258 orderId: null, 259 reference: error.reference, 260 } 261 } 262 onError(receivedError); 263 } 264 } 265 266 startV2HPP(JSON.parse('<?php echo $data_array; ?>')); 267 </script> 268 </div> 269 <?php 270 } 173 271 } -
geidea-online-payments/trunk/functions/ProcessPayment.php
r3040351 r3084475 40 40 $token_id = null; 41 41 try { 42 if (isset($_POST['wc-geidea-payment-token']) && isset($_POST['woocommerce-process-checkout-nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['woocommerce-process-checkout-nonce'])), 'woocommerce-process_checkout')) {43 $selected_token_id = sanitize_text_field(wp_unslash($_POST['wc-geidea-payment-token'])); 42 if (isset($_POST['wc-geidea-payment-token'])) { // phpcs:ignore 43 $selected_token_id = sanitize_text_field(wp_unslash($_POST['wc-geidea-payment-token'])); // phpcs:ignore 44 44 $token = WC_Payment_Tokens::get($selected_token_id); 45 45 if ($token) { … … 47 47 } 48 48 } 49 if (isset($_POST['wc-geidea-new-payment-method']) && isset($_POST['woocommerce-process-checkout-nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['woocommerce-process-checkout-nonce'])), 'woocommerce-process_checkout')) {49 if (isset($_POST['wc-geidea-new-payment-method']) && sanitize_text_field(wp_unslash($_POST['wc-geidea-new-payment-method']))) { // phpcs:ignore 50 50 $save_card = true; 51 51 } … … 158 158 </script> 159 159 '; 160 $geidea_session_nonce = wp_create_nonce('geidea_session_action'); 160 161 return array( 161 162 'result' => 'success', 162 'messages' => $script, 163 'refresh' => true, 164 'reload' => false, 163 'redirect' => wc_get_checkout_url() . '?geidea-session=' . urlencode(json_encode($response['body'])) . "&geidea_session_nonce=$geidea_session_nonce" 165 164 ); 166 165 } -
geidea-online-payments/trunk/readme.txt
r3066643 r3084475 2 2 3 3 Contributors: geideapg123 4 Version: 3. 1.14 Version: 3.2.0 5 5 Tags: credit card, geidea, Apple Pay, payment, payment for WordPress, payment for woocommerce, payment request, woocommerce 6 6 Requires at least: 6.0.2 7 7 Tested up to: 6.5 8 8 Requires PHP: 7.4 9 Stable tag: 3. 1.19 Stable tag: 3.2.0 10 10 License: GPLv3 11 11 License URI: https://www.gnu.org/licenses/gpl-3.0.html … … 209 209 = 3.1.1 - 2024-04-08 = 210 210 * Plugin tested on wordpress v6.5 211 212 = 3.2.0 - 2024-05-12 = 213 * Enable support for block based checkout -
geidea-online-payments/trunk/wc-geidea.php
r3066643 r3084475 4 4 Plugin Name: Geidea Online Payments 5 5 Description: Geidea Online Payments. 6 Version: 3. 1.16 Version: 3.2.0 7 7 Author: Geidea 8 8 Author URI: https://geidea.net … … 53 53 } 54 54 55 /** 56 * Function for declare compatibility with cart_checkout_blocks feature 57 */ 58 function declare_cart_checkout_blocks_compatibility() 59 { 60 if (class_exists('\Automattic\WooCommerce\Utilities\FeaturesUtil')) { 61 \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 62 'cart_checkout_blocks', 63 __FILE__, 64 true 65 ); 66 } 67 } 68 69 /** 70 * Function for register a payment method type 71 */ 72 function register_order_approval_payment_method_type() 73 { 74 if (!class_exists('Automattic\WooCommerce\Blocks\Payments\Integrations\AbstractPaymentMethodType')) { 75 return; 76 } 77 require_once('class.blocks-checkout.php'); 78 add_action( 79 'woocommerce_blocks_payment_method_type_registration', 80 function (Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry $payment_method_registry) { 81 $payment_method_registry->register(new WC_geidea_Blocks); 82 } 83 ); 84 } 85 55 86 /* 56 87 * Function for load plugin … … 75 106 add_filter('woocommerce_payment_gateways', 'geidea_add_gateway'); 76 107 add_action('admin_menu', 'geidea_add_card_tokens_menu', 99); 108 add_action('before_woocommerce_init', 'declare_cart_checkout_blocks_compatibility'); 109 add_action('woocommerce_blocks_loaded', 'register_order_approval_payment_method_type'); 77 110 }
Note: See TracChangeset
for help on using the changeset viewer.