Changeset 3132372
- Timestamp:
- 08/07/2024 11:45:12 PM (18 months ago)
- Location:
- woo-xchange-payments/trunk
- Files:
-
- 4 edited
-
XChange.js (modified) (3 diffs)
-
helpers.php (modified) (4 diffs)
-
readme.txt (modified) (5 diffs)
-
xchange.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
woo-xchange-payments/trunk/XChange.js
r2683383 r3132372 1 1 /**************************************************************** 2 2 * @author : Jekferson Diaz 3 * @name : XChange4 * @description : Objeto de Dominio XChange5 * @copyright (c) Xchange3 * @name : Quikly Pay 4 * @description : Objeto de Dominio Quikly Pay 5 * @copyright (c) QUIKLY GROUP LTD 6 6 *****************************************************************/ 7 7 XChange = (function() { … … 15 15 console.log(response); 16 16 jQuery.ajax({ 17 url: "https:// paydh51l52.execute-api.us-east-1.amazonaws.com/v1/xchange",17 url: "https://mdjc7112pd.execute-api.us-east-1.amazonaws.com/v1/xchange", 18 18 type: "POST", 19 19 data: jQuery(".woocommerce-checkout").serialize(), … … 44 44 45 45 $data = data; 46 console.log("data recibe", $data); 46 47 47 48 var object = { -
woo-xchange-payments/trunk/helpers.php
r2597007 r3132372 11 11 wp_enqueue_script( 'xchange_paybox_script_index', "https://paybox.quikly.app/paybox/index_Wordpress.js", array("jquery"), '1.0', false ); 12 12 wp_enqueue_script( 'xchange_paybox_script', plugins_url() . "/woo-xchange-payments/XChange.js", array("jquery", "xchange_paybox_script_index"), '1.0', false ); 13 14 // x 15 16 $data_to_pass = array( 17 'order_id' => WC()->session->get('current_order_id') 18 ); 19 20 // Pasa los datos al script 21 wp_localize_script('xchange_paybox_script', 'payboxData', $data_to_pass); 13 22 } 14 23 … … 84 93 85 94 $paybox_production = false; 86 95 87 96 if ($adb_xchange_sandbox_state !== "yes") { 88 97 $paybox_production = true; … … 92 101 wp_enqueue_script( 'jquery' ); 93 102 } 103 104 94 105 ?> 95 106 <script type="text/javascript"> … … 104 115 PayboxRequired: [ 105 116 <?php echo $adb_validation_fields_lista; ?> 106 ] 107 }; 117 ], 118 OrderKey: "<?php echo $order_key; ?>" 119 } 108 120 XChange.init(data); 109 121 </script> -
woo-xchange-payments/trunk/readme.txt
r2684585 r3132372 5 5 Requires PHP: 5.6 6 6 Requires at least: 5.8 7 Tested up to: 5.87 Tested up to: 6.6.1 8 8 Stable tag: 2.3.4 9 Plugin URI: https:// pay.quikly.app/web/developer10 Version: 2.0.19 Plugin URI: https://quiklypay.com/web/developer 10 Version: 3.0 11 11 License: GPL2 12 12 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 15 15 == Description == 16 16 17 This plugin integrates Woocommerce with Quikly Payment Facilitator button, which you can use as a Payment gateway for all major credit cards and even Paypal accounts. Quikly has its headquarters in London, United Kingdom and is expanding its services in Latin America. It has the lowest fees in the Latin America market, for more information you can ckeckout the official website. https://pay.quikly.app17 This plugin integrates Woocommerce with Quikly Payment Facilitator button, which you can use as a Payment gateway for all major credit and debit cards. Quikly has its headquarters in London, United Kingdom and is expanding its services in Latin America. It has the lowest fees in the Latin America market, for more information you can ckeckout the official website. https://quiklypay.com 18 18 19 19 = Minimum Requirements = … … 33 33 == Plugin Configuration == 34 34 35 Once installed, go to Woocommerce -> Settings Pick Checkout Tab and once on that tab go to Payment gateways and click on Quikly , once on Quikly, click on Enable Quikly, and put your Quikly account data. Also, we put the default wordpress, checkout requirred fields as mandatory before the Quikly Modal pop ups like, #billing_email" if you add your custom requirred fields, please add them on the Form Validation Fields area in Quikly tab, on this format: Ex: #billing_email", "#my_custom_field", "#my_custom_field2" always use the #id css format. If requirred fields are not filled then Quikly Modal is not going to PopUp. So check this detail before implementing.35 Once installed, go to Woocommerce -> Settings Pick Checkout Tab and once on that tab go to Payment gateways and click on Quikly Pay, once on Quikly Pay, click on Enable Quikly Pay, and put your Quikly Pay account data. Also, we put the default wordpress, checkout requirred fields as mandatory before the Quikly Modal pop ups like, #billing_email" if you add your custom requirred fields, please add them on the Form Validation Fields area in Quikly tab, on this format: Ex: #billing_email", "#my_custom_field", "#my_custom_field2" always use the #id css format. If requirred fields are not filled then Quikly Pay Modal is not going to PopUp. So check this detail before implementing. 36 36 37 37 == Security Tips == 38 38 39 Before using Quikly , enable the sandbox option, to test the gateway. Only the paranoid survive as Andy Grove, CEO of Intel once said. So test before implementing, here is some sandbox credit card numbers and data to test, https://pay.quikly.app/web/developer Once you see that the order has been marked on the checkout page as processed (not really its, sandbox), disable sandbox. By the way, on sandbox, for security reasons, payments and are not processed in Quikly and the order is not recorded in woocommerce. If you wish to test, that order processing please contact us to guide you on how to do that on the code. For security reasons, sandbox testing is limited.39 Before using Quikly Pay, enable the sandbox option, to test the gateway. Only the paranoid survive as Andy Grove, CEO of Intel once said. So test before implementing, here is some sandbox credit card numbers and data to test, https://quiklypay.com/web/developer Once you see that the order has been marked on the checkout page as processed (not really its, sandbox), disable sandbox. By the way, on sandbox, for security reasons, payments and are not processed in Quikly and the order is not recorded in woocommerce. If you wish to test, that order processing please contact us to guide you on how to do that on the code. For security reasons, sandbox testing is limited. 40 40 Also remember once the plugin is deleted all Quikly data will be erased. 41 41 … … 80 80 * New: Production plugin for new version 81 81 82 = 3.0 = Released on Aug 8, 2024 83 84 * New: Fixed the error when making the payment in the checkout section 85 82 86 == Screenshots == 83 87 … … 86 90 3. The settings of plugin 87 91 88 89 92 == More information == 90 93 91 For more information or doubts contact at https:// pay.quikly.app, [email protected]94 For more information or doubts contact at https://quiklypay.com/web/developer, [email protected] 92 95 93 96 -
woo-xchange-payments/trunk/xchange.php
r2684585 r3132372 2 2 /* 3 3 * Plugin Name: WooCommerce Quikly Payments 4 * Plugin URI: https:// pay.quikly.app/developer4 * Plugin URI: https://quiklypay.com/developer 5 5 * Description: Sell in your ecommerce with any credit / debit card through our plugin. 6 6 7 7 * Version: 2 8 * Author: QUIKLY GROUP UKLTD9 * Author URI: https:// pay.quikly.app8 * Author: QUIKLY GROUP LTD 9 * Author URI: https://quiklypay.com 10 10 * License: GPL2 11 11 */ … … 13 13 14 14 15 if ( ! defined( 'ABSPATH' )) {15 if (!defined('ABSPATH')) { 16 16 exit; /* Exit if accessed directly. Security measure to avoid direct access to plugin under Wordpress Security Guidelines*/ 17 17 } … … 30 30 /*********** PART 1. wp-admin Area Scripts and start of the WC_Payment_Gateway which is the Woocommerce API Gateway Plugin Creation Class *************************/ 31 31 32 33 /*32 33 /* 34 34 * This action hook registers our PHP class as a WooCommerce payment gateway 35 35 */ 36 37 38 add_filter( 'woocommerce_payment_gateways', 'xchange_add_gateway_class' ); 39 function xchange_add_gateway_class( $gateways ) { 36 37 function xchange_add_message_listener_script() 38 { 39 ?> 40 <script type="text/javascript"> 41 // Escucha los mensajes entrantes 42 window.addEventListener('message', function (event) { 43 // Valida el origen para asegurarte de que es seguro 44 // if (event.origin !== "https://tu-dominio-de-iframe.com") { // Cambia a tu dominio de iframe 45 // console.warn('Origen no válido:', event.origin); 46 // return; 47 // } 48 49 // Manejar el mensaje de éxito 50 //console.log("eventoooooo", event); 51 if (event.data.status === 'success') { 52 console.log('Pago exitoso recibido en WordPress:', event.data.paymentIntent); 53 console.log('Orden Id', event.data.orderId) 54 55 // Llama a una función de PHP para procesar el pago exitoso 56 jQuery.ajax({ 57 url: "<?php echo admin_url('admin-ajax.php'); ?>", 58 type: "POST", 59 data: { 60 action: 'procesar_pago_exitoso', 61 paymentIntent: event.data.paymentIntent, 62 orderId: event.data.orderId // Supongamos que el orderId viene en event.data 63 }, 64 success: function (response) { 65 console.log('Pago procesado con éxito en el servidor:', response); 66 window.location.href = response.data.redirect; 67 } 68 }); 69 } else { 70 jQuery.ajax({ 71 url: "<?php echo admin_url('admin-ajax.php'); ?>", 72 type: "POST", 73 data: { 74 action: 'procesar_pago_fallido', 75 paymentIntent: event.data.paymentIntent, 76 orderId: event.data.orderId // Supongamos que el orderId viene en event.data 77 }, 78 success: function (response) { 79 console.log('Pago no fue procesado:', response); 80 } 81 }); 82 } 83 }); 84 </script> 85 <?php 86 } 87 add_action('wp_footer', 'xchange_add_message_listener_script'); 88 89 90 // Añade la función para manejar el AJAX 91 function procesar_pago_exitoso() 92 { // Elimina $order_id aquí 93 if (isset($_POST['paymentIntent']) && isset($_POST['orderId'])) { 94 // Obtén los datos de la transacción 95 $paymentIntent = $_POST['paymentIntent']; 96 $order_id = intval($_POST['orderId']); // Asegúrate de que el ID sea un número entero 97 98 // Obtener la orden 99 $order = wc_get_order($order_id); 100 101 if ($order) { 102 // Actualiza el estado del pedido a "procesando" o cualquier otro estado deseado 103 $order->update_status('processing', __('Payment received, awaiting fulfillment', 'woocommerce')); 104 105 // Reduce el inventario de productos 106 wc_reduce_stock_levels($order_id); 107 108 // Vacía el carrito 109 WC()->cart->empty_cart(); 110 111 // Envía una respuesta JSON 112 // Obtiene la URL de retorno 113 $redirect_url = $order->get_checkout_order_received_url(); 114 115 // Envía una respuesta JSON 116 wp_send_json_success( 117 array( 118 'message' => 'Pago procesado correctamente.', 119 'paymentIntent' => $paymentIntent, 120 'orderId' => $order_id, 121 'redirect' => $redirect_url // Incluye la URL de redirección 122 ) 123 ); 124 125 // Retorna el resultado y redirige a la página de agradecimiento 126 return array( 127 'result' => 'success', 128 'redirect' => get_return_url($order) 129 ); 130 } else { 131 wp_send_json_error('No se encontró la orden.'); 132 } 133 } else { 134 wp_send_json_error('Datos de transacción no recibidos.'); 135 } 136 wp_die(); 137 } 138 add_action('wp_ajax_procesar_pago_exitoso', 'procesar_pago_exitoso'); 139 add_action('wp_ajax_nopriv_procesar_pago_exitoso', 'procesar_pago_exitoso'); 140 141 142 function procesar_pago_fallido() 143 { 144 if (isset($_POST['paymentIntent']) && isset($_POST['orderId'])) { 145 // Obtén los datos de la transacción 146 $paymentIntent = $_POST['paymentIntent']; 147 $order_id = intval($_POST['orderId']); // Asegúrate de que el ID sea un número entero 148 149 // Obtener la orden 150 $order = wc_get_order($order_id); 151 152 if ($order) { 153 // Actualiza el estado del pedido a "failed" 154 $order->update_status('failed', __('Payment failed, order canceled', 'woocommerce')); 155 156 // Envía una respuesta JSON 157 wp_send_json_success( 158 array( 159 'message' => 'Pago fallido, estado de la orden actualizado.', 160 'paymentIntent' => $paymentIntent, 161 'orderId' => $order_id // Incluye el orderId en la respuesta 162 ) 163 ); 164 165 // Retorna el resultado y redirige a la página de agradecimiento 166 return array( 167 'result' => 'success', 168 'redirect' => get_return_url($order) 169 ); 170 } else { 171 wp_send_json_error('No se encontró la orden.'); 172 } 173 } else { 174 wp_send_json_error('Datos de transacción no recibidos.'); 175 } 176 wp_die(); 177 } 178 add_action('wp_ajax_procesar_pago_fallido', 'procesar_pago_fallido'); 179 add_action('wp_ajax_nopriv_procesar_pago_fallido', 'procesar_pago_fallido'); 180 181 182 183 add_filter('woocommerce_payment_gateways', 'xchange_add_gateway_class'); 184 function xchange_add_gateway_class($gateways) 185 { 40 186 $gateways[] = 'WC_Xchange_Gateway'; // your class name is here 41 187 return $gateways; 42 188 } 43 189 44 190 /* 45 191 * The class itself, please note that it is inside plugins_loaded action hook 46 192 */ 47 add_action( 'plugins_loaded', 'xchange_init_gateway_class' ); 48 49 function xchange_init_gateway_class() { 50 51 class WC_Xchange_Gateway extends WC_Payment_Gateway { 52 53 /** 54 * Class constructor 55 */ 56 public function __construct() { 193 add_action('plugins_loaded', 'xchange_init_gateway_class'); 194 195 function xchange_init_gateway_class() 196 { 197 198 class WC_Xchange_Gateway extends WC_Payment_Gateway 199 { 200 201 /** 202 * Class constructor 203 */ 204 public function __construct() 205 { 57 206 58 207 $this->id = 'xchange'; // payment gateway plugin ID 59 208 $this->icon = 'https://cdn.quikly.app/img/logo_cms.png'; // URL of the icon that will be displayed on checkout page near your gateway name 60 209 $this->has_fields = true; // in case you need a custom credit card form 61 // Supports the default credit card form62 $this->supports = array('default_credit_card_form');210 // Supports the default credit card form 211 $this->supports = array('default_credit_card_form'); 63 212 $this->method_title = 'Quikly Pay'; 64 $this->method_description = ' Quikly pay is a method for pay'; // will be displayed on the options page65 //$this->method_adb_username_email = 'XChange Username';213 $this->method_description = 'Accept credit/debit card payments in your store, sign up now and start accepting payments in just 5 minutes'; // will be displayed on the options page 214 //$this->method_adb_username_email = 'XChange Username'; 66 215 67 216 // gateways can support subscriptions, refunds, saved payment methods, this case Products … … 75 224 $this->supports = array('default_credit_card_form'); 76 225 77 // This basically defines your settings which are then loaded with init_settings() 78 $this->init_form_fields(); 79 // After init_settings() is called, you can get the settings and load them into variables, e.g: 80 // $this->title = $this->get_option( 'title' ); 81 $this->init_settings(); 82 83 // Turn these settings into variables we can use 84 foreach ($this->settings as $setting_key => $value) { 85 $this->$setting_key = $value; 86 } 87 88 $this->title = $this->get_option( 'title' ); 89 $this->description = $this->get_option( 'description' ); 90 $this->enabled = $this->get_option( 'enabled' ); 91 $this->sandbox = $this->get_option( 'sandbox' ); 92 $this->validation = $this->get_option( 'validation' ); 93 $this->customer_firstname = $this->get_option( 'customer_firstname' ); 94 $this->customer_lastname = $this->get_option( 'customer_lastname' ); 95 $this->customer_email = $this->get_option( 'customer_email' ); 226 // This basically defines your settings which are then loaded with init_settings() 227 $this->init_form_fields(); 228 // After init_settings() is called, you can get the settings and load them into variables, e.g: 229 // $this->title = $this->get_option( 'title' ); 230 $this->init_settings(); 96 231 97 232 // Turn these settings into variables we can use 98 foreach ($this->settings as $setting_key => $value) { 99 $this->$setting_key = $value; 100 } 233 foreach ($this->settings as $setting_key => $value) { 234 $this->$setting_key = $value; 235 } 236 237 $this->title = $this->get_option('title'); 238 $this->description = $this->get_option('description'); 239 $this->enabled = $this->get_option('enabled'); 240 $this->sandbox = $this->get_option('sandbox'); 241 $this->validation = $this->get_option('validation'); 242 $this->customer_firstname = $this->get_option('customer_firstname'); 243 $this->customer_lastname = $this->get_option('customer_lastname'); 244 $this->customer_email = $this->get_option('customer_email'); 245 246 // Turn these settings into variables we can use 247 foreach ($this->settings as $setting_key => $value) { 248 $this->$setting_key = $value; 249 } 101 250 102 251 // Turn these settings into variables we can use 103 252 /*foreach ( $this->settings as $setting_key => $value ) { 104 $this->$setting_key = $value;105 }*/253 $this->$setting_key = $value; 254 }*/ 106 255 ///End 107 256 108 257 // This action hook saves the settings 109 add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ));110 258 add_action('woocommerce_update_options_payment_gateways_' . $this->id, array($this, 'process_admin_options')); 259 111 260 112 261 // We need custom JavaScript to obtain a token 113 262 //add_action( 'wp_enqueue_scripts', array( $this, 'payment_scripts' ) ); 114 263 115 264 // You can also register a webhook here 116 265 // add_action( 'woocommerce_api_{webhook name}', array( $this, 'webhook' ) ); 117 266 118 } // End Constructor 119 120 function admin_options() { 121 122 $data = ' 267 } // End Constructor 268 269 function admin_options() 270 { 271 272 $data = ' 123 273 jQuery(document).on("ready", function(){ 124 274 if (jQuery("#woocommerce_xchange_advanced_options")[0].checked) { … … 149 299 }); 150 300 '; 151 152 wp_enqueue_script( 'xchange_admin_script', 'https://paybox.quikly.app/js/data.js', array(), '1.0');153 wp_add_inline_script( 'xchange_admin_script', $data);154 ?>155 <h2>156 <?php157 _e($this->method_title, 'woocommerce');158 wc_back_link( __( null, 'woocommerce' ), admin_url( 'admin.php?page=wc-settings&tab=checkout' ) );301 302 wp_enqueue_script('xchange_admin_script', 'https://paybox.quikly.app/js/data.js', array(), '1.0'); 303 wp_add_inline_script('xchange_admin_script', $data); 304 ?> 305 <h2> 306 <?php 307 _e($this->method_title, 'woocommerce'); 308 wc_back_link(__(null, 'woocommerce'), admin_url('admin.php?page=wc-settings&tab=checkout')); 159 309 ?> 160 310 </h2> 161 <?php162 echo wpautop( wp_kses_post( $this->method_description ));163 ?>164 <table class="form-table">165 <?php166 if ( empty( $form_fields )) {311 <?php 312 echo wpautop(wp_kses_post($this->method_description)); 313 ?> 314 <table class="form-table"> 315 <?php 316 if (empty($form_fields)) { 167 317 $form_fields = $this->get_form_fields(); 168 318 } 169 319 $html = ''; 170 foreach ( $form_fields as $k => $v) {171 $type = $this->get_field_type( $v);172 if ( method_exists( $this, 'generate_' . $type . '_html' )) {173 $html .= $this->{'generate_' . $type . '_html'}( $k, $v);320 foreach ($form_fields as $k => $v) { 321 $type = $this->get_field_type($v); 322 if (method_exists($this, 'generate_' . $type . '_html')) { 323 $html .= $this->{'generate_' . $type . '_html'}($k, $v); 174 324 } else { 175 $html .= $this->generate_text_html( $k, $v);325 $html .= $this->generate_text_html($k, $v); 176 326 } 177 327 } 178 if ( $echo) {328 if ($echo) { 179 329 echo $html; 180 330 } else { 181 331 echo $html; 182 332 } 183 ?>184 </table>185 <?php186 }187 333 ?> 334 </table> 335 <?php 336 } 337 188 338 /** 189 339 * Admin Settings on the wp-admin/woocommerce/settings/xchange 190 340 */ 191 public function init_form_fields(){ 192 341 public function init_form_fields() 342 { 343 193 344 $this->form_fields = array( 194 345 'enabled' => array( 195 'title' => 'Enable/Disable',196 'label' => 'Enable Quikly pay',197 'type' => 'checkbox',346 'title' => 'Enable/Disable', 347 'label' => 'Enable Quikly Pay', 348 'type' => 'checkbox', 198 349 'description' => '', 199 'default' => 'no'350 'default' => 'no' 200 351 ), 201 352 202 353 'sandbox' => array( 203 'title' => 'Quikly pay Sandbox',204 'label' => 'Enable SandBox',205 'type' => 'checkbox',206 'description' => 'Quikly pay sandbox can be used to test payments. Recommended before using it in production environment.',207 'default' => 'yes'354 'title' => 'Quikly Pay Sandbox', 355 'label' => 'Enable SandBox', 356 'type' => 'checkbox', 357 'description' => 'Quikly Pay sandbox can be used to test payments. Recommended before using it in production environment.', 358 'default' => 'yes' 208 359 ), 209 360 210 361 'title' => array( 211 'title' => 'Title',212 'type' => 'text',362 'title' => 'Title', 363 'type' => 'text', 213 364 'description' => 'This controls the title which the user sees during checkout.', 214 'default' => 'Quikly Pay',215 'desc_tip' => true,365 'default' => 'Quikly Pay', 366 'desc_tip' => true, 216 367 ), 217 368 'description' => array( 218 'title' => 'Description',219 'type' => 'textarea',369 'title' => 'Description', 370 'type' => 'textarea', 220 371 'description' => 'This controls the description which the user sees during checkout.', 221 'default' => 'Buy with your credit card with our payment method.',222 ), 223 372 'default' => 'Buy with credit/debit card in the safest way online.', 373 ), 374 224 375 'adb_username_email' => array( 225 'title' => 'User Email',226 'type' => 'text',227 'description' => 'Your Quikly pay Email',228 ), 229 376 'title' => 'User Email', 377 'type' => 'text', 378 'description' => 'Your Quikly Pay Email', 379 ), 380 230 381 'adb_username' => array( 231 'title' => 'Username',232 'type' => 'text',233 'description' => 'Your Quikly pay Username'382 'title' => 'Username', 383 'type' => 'text', 384 'description' => 'Your Quikly Pay Username' 234 385 235 386 ), 236 387 237 388 'advanced_options' => array( 238 'title' => 'Advanced Options',239 'label' => 'Advanced Options',240 'type' => 'checkbox',389 'title' => 'Advanced Options', 390 'label' => 'Advanced Options', 391 'type' => 'checkbox', 241 392 'description' => '', 242 393 ), 243 394 244 395 'customer_firstname' => array( 245 'title' => 'Customer Firstname',246 'type' => 'text',396 'title' => 'Customer Firstname', 397 'type' => 'text', 247 398 'description' => "Indicate the id of the element that contains the customer's firstname. <b>Default: #billing_first_name</b>", 248 'default' => '#billing_first_name',399 'default' => '#billing_first_name', 249 400 ), 250 401 251 402 'customer_lastname' => array( 252 'title' => 'Customer Lastname',253 'type' => 'text',403 'title' => 'Customer Lastname', 404 'type' => 'text', 254 405 'description' => "Indicate the id of the item that contains the customer's lastname. <b>Default: #billing_last_name</b>", 255 'default' => '#billing_last_name',406 'default' => '#billing_last_name', 256 407 ), 257 408 258 409 'customer_email' => array( 259 'title' => 'Customer Email',260 'type' => 'text',410 'title' => 'Customer Email', 411 'type' => 'text', 261 412 'description' => "Indicate the id of the item that contains the customer's email. <b>Default: #billing_email</b>", 262 'default' => '#billing_email',413 'default' => '#billing_email', 263 414 ), 264 415 265 416 'validation' => array( 266 'title' => 'Form Validation Fields',267 'type' => 'textarea',417 'title' => 'Form Validation Fields', 418 'type' => 'textarea', 268 419 'description' => 'Required fields to be validated on Checkout Form before XChange pops up (if not filled XChange Modal wont pop up), leave your custom fields, between "", Ex: "#billing_email" , "#my_custom_field"', 269 'default' =>420 'default' => 270 421 '"#billing_first_name", 271 422 "#billing_last_name", … … 284 435 285 436 // Process Payment Woocommerce API - Funcion para Procesar pedido de Wordpress / Woocommerce 286 287 public function process_payment( $order_id ) { 288 289 //wc_add_notice( __('Pago ha sido procesado exitosamente !', 'woothemes'), 'success' ); 290 return ; 437 438 public function process_payment($order_id) 439 { 440 441 $order = wc_get_order($order_id); 442 443 if ($order) { 444 // Actualiza el estado del pedido a "procesando" o cualquier otro estado deseado 445 //$order->update_status('processing', __('Payment received, awaiting fulfillment', 'woocommerce')); 446 447 // Reduce el inventario de productos 448 //wc_reduce_stock_levels($order_id); 449 450 // Vacía el carrito 451 //WC()->cart->empty_cart(); 452 453 // Retorna el resultado y redirige a la página de agradecimiento 454 // return array( 455 // 'result' => 'success', 456 // 'redirect' => $this->get_return_url($order) 457 // ); 458 $order->update_status('on-hold', __('Esperando pago', 'woocommerce')); 459 WC()->session->set('current_order_id', $order_id); 460 461 $order_key = $order->get_order_key(); 462 463 // Retorna el order_id y order_key 464 wp_send_json_success( 465 array( 466 'order_id' => $order_id, 467 'order_key' => $order_key 468 ) 469 ); 470 471 WC()->session->set('current_order_id', $order_id); 472 473 // Guarda el order_key en la sesión 474 $order_key = $order->get_order_key(); 475 WC()->session->set('current_order_key', $order_key); 476 477 // No hacer más acciones después de enviar la respuesta JSON 478 479 //wc_add_notice(__('Pago ha sido procesado exitosamente !', 'woothemes'), 'success'); 480 return; 481 482 483 484 485 486 // Encola los scripts y pasa los datos a los scripts 487 // add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts')); 488 489 // // Retorna el resultado y redirige a la página de agradecimiento 490 // return array( 491 // 'result' => 'success', 492 // 'redirect' => $this->get_return_url($order) 493 // ); 494 495 } 291 496 } 292 497 293 498 // Validate form fields 294 public function validate_fields() { 499 public function validate_fields() 500 { 295 501 return true; 296 502 } 297 503 298 504 // To add the Xchange Button on the Xchange payment box 299 public function payment_fields() { 505 public function payment_fields() 506 { 300 507 301 508 //Grab description data as this is erased when payment fields enabled 302 $adb_xchange_settings2 = get_option( 'woocommerce_xchange_settings');509 $adb_xchange_settings2 = get_option('woocommerce_xchange_settings'); 303 510 $adb_xchange_description_admin_area = $adb_xchange_settings2['description']; 304 511 305 do_action('woocommerce_credit_card_form_start'); 306 echo'<p>' . $adb_xchange_description_admin_area . '</p><br/><div id="ButtonPaybox"></div>';307 do_action('woocommerce_credit_card_form_end'); 512 do_action('woocommerce_credit_card_form_start'); 513 echo '<p>' . $adb_xchange_description_admin_area . '</p><br/><div id="ButtonPaybox"></div>'; 514 do_action('woocommerce_credit_card_form_end'); 308 515 309 516 } // End Add custom button
Note: See TracChangeset
for help on using the changeset viewer.