PluginProbe
MONEI Payments for WooCommerce / 4.1.0
MONEI Payments for WooCommerce v4.1.0
7.3.3 7.3.2 7.3.1 7.3.0 7.2.4 7.2.3 7.2.2 7.2.0 7.2.1 7.1.3 2.1.0 3.0.0 3.1.0 3.1.1 4.0.0 4.1.0 4.1.1 4.2.0 4.2.1 5.0 5.1.0 5.1.1 5.1.2 5.2.2 5.2.3 All 87 releases
monei / monei.php

monei.php in MONEI Payments for WooCommerce 4.1.0, at monei.php

1,143 lines 43.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * WooCommerce MONEI Gateway
5 *
6 * @package WooCommerce MONEI Gateway
7 * @author José Conti
8 * @copyright 2020-2020 MONEI Conti
9 * @license GPL-3.0+
10 *
11 * Plugin Name: WooCommerce MONEI Gateway
12 * Plugin URI: https://wordpress.org/plugins/monei/
13 * Description: Extends WooCommerce with a MONEI gateway. Best payment gateway rates. The perfect solution to manage your digital payments.
14 * Version: 4.1.0
15 * Author: MONEI
16 * Author URI: https://www.monei.net/
17 * Tested up to: 5.6
18 * WC requires at least: 3.0
19 * WC tested up to: 4.9
20 * Text Domain: monei
21 * Domain Path: /languages/
22 * Copyright: (C) 2017 MONEI.
23 * License: GNU General Public License v3.0
24 * License URI: http://www.gnu.org/licenses/gpl-3.0.html
25 */
26
27 define( 'MONEI_VERSION', '4.1.0' );
28 define( 'MONEI_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
29 define( 'MONEI_SIGNUP', 'https://dashboard.monei.net/?action=signUp' );
30 define( 'MONEI_WEB', 'https://monei.net/' );
31 define( 'MONEI_REVIEW', 'https://wordpress.org/support/plugin/monei/reviews/?rate=5#new-post' );
32 define( 'MONEI_SUPPORT', 'https://support.monei.net/' );
33
34 add_action( 'plugins_loaded', 'woocommerce_gateway_monei_init', 0 );
35
36 require_once 'includes/vendor/autoload.php';
37
38
39 function woocommerce_gateway_monei_init() {
40 if ( ! class_exists( 'WC_Payment_Gateway' ) ) {
41 return;
42 }
43 /**
44 * Localisation
45 */
46 load_plugin_textdomain( 'monei', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
47 /**
48 * Gateway class
49 */
50 class WC_Gateway_Monei extends WC_Payment_Gateway {
51 var $notify_url;
52 /**
53 * Constructor for the gateway.
54 *
55 * @access public
56 * @return void
57 */
58 public function __construct() {
59 global $woocommerce;
60 $this->id = 'monei';
61 $logo_url = $this->get_option( 'logo' );
62 if ( ! empty( $logo_url ) ) {
63 $logo_url = $this->get_option( 'logo' );
64 $this->icon = apply_filters( 'woocommerce_monei_icon', $logo_url );
65 } else {
66 $this->icon = apply_filters( 'woocommerce_monei_icon', plugins_url( basename( plugin_dir_path( __FILE__ ) ), basename( __FILE__ ) ) . '/assets/images/MONEI-logo.png' );
67 }
68 $this->has_fields = true;
69 $this->liveurl = 'https://pay.monei.net/checkout';
70 $this->refund_url = 'https://api.monei.net/v1/refund';
71 $this->charge_url = 'https://api.monei.net/v1/charge';
72 $this->testmode = $this->get_option( 'testmode' );
73 $this->method_title = __( 'MONEI', 'monei' );
74 $this->notify_url = add_query_arg( 'wc-api', 'WC_Gateway_monei', home_url( '/' ) );
75 $this->notify_url_not_https = str_replace( 'https:', 'http:', add_query_arg( 'wc-api', 'WC_Gateway_monei', home_url( '/' ) ) );
76 // Define user set variables.
77 $this->title = $this->get_option( 'title' );
78 $this->description = $this->get_option( 'description' );
79 $this->logo = $this->get_option( 'logo' );
80 $this->orderdo = $this->get_option( 'orderdo' );
81 $this->accountid = $this->get_option( 'accountid' );
82 $this->apikey = $this->get_option( 'apikey' );
83 $this->commercename = $this->get_option( 'commercename' );
84 $this->secret = $this->get_option( 'secret' );
85 $this->password = $this->get_option( 'password' );
86 $this->tokenization = $this->get_option( 'tokenization' );
87 $this->debug = $this->get_option( 'debug' );
88 $this->log = new WC_Logger();
89 $this->supports = array(
90 'products',
91 'tokenization',
92 'refunds',
93 'subscriptions',
94 'subscription_cancellation',
95 'subscription_suspension',
96 'subscription_reactivation',
97 'subscription_amount_changes',
98 'subscription_date_changes',
99 'subscription_payment_method_change',
100 'subscription_payment_method_change_customer',
101 'subscription_payment_method_change_admin',
102 'multiple_subscriptions',
103 );
104 $this->init_form_fields();
105 $this->init_settings();
106 // Actions.
107 add_action( 'valid_monei_standard_ipn_request', array( $this, 'successful_request' ) );
108 add_action( 'woocommerce_receipt_monei', array( $this, 'receipt_page' ) );
109 add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) );
110 // Payment listener/API hook.
111 add_action( 'woocommerce_api_wc_gateway_' . $this->id, array( $this, 'check_ipn_response' ) );
112
113 if ( class_exists( 'WC_Subscriptions_Order' ) ) {
114 add_action( 'woocommerce_scheduled_subscription_payment_' . $this->id, array( $this, 'doing_scheduled_subscription_payment' ), 10, 2 );
115 }
116 if ( ! $this->is_valid_for_use() ) {
117 $this->enabled = false;
118 }
119 }
120
121 /**
122 * Check if this gateway is enabled and available in the user's country
123 *
124 * @access public
125 * @return bool
126 */
127 function is_valid_for_use() {
128
129 if ( ! in_array( get_woocommerce_currency(), array( 'EUR', 'USD', 'GBP' ), true ) ) {
130 return false;
131 } else {
132 return true;
133 }
134 }
135 function product_description( $order ) {
136
137 $product_id = '';
138 $name = '';
139 $sku = '';
140 foreach ( $order->get_items() as $item ) {
141 $product_id .= $item->get_product_id() . ', ';
142 $name .= $item->get_name() . ', ';
143 $sku .= get_post_meta( $item->get_product_id(), '_sku', true) . ', ';
144 }
145 // Can be order, id, name or sku
146 $description_type = 'name';
147
148 if ( 'id' === $description_type ) {
149 $description = $product_id;
150 } elseif ( 'name' === $description_type ) {
151 $description = $name;
152 } elseif ( 'sku' === $description_type ) {
153 $description = $sku;
154 } else {
155 $description = __( 'Order', 'monei' ) . ' ' . $order->get_order_number();
156 }
157 return $description;
158 }
159 /**
160 * Admin Panel Options
161 *
162 * @since 1.0.0
163 */
164 public function admin_options() {
165 ?>
166 <h3><?php esc_html_e( 'MONEI', 'monei' ); ?></h3>
167 <p><?php esc_html_e( 'Best payment gateway rates. The perfect solution to manage your digital payments.', 'monei' ); ?></p>
168 <?php if ( $this->is_valid_for_use() ) : ?>
169 <table class="form-table">
170 <?php
171 // Generate the HTML For the settings form.
172 $this->generate_settings_html();
173 ?>
174 </table><!--/.form-table-->
175 <?php else : ?>
176 <div class="inline error"><p><strong><?php esc_html_e( 'Gateway Disabled', 'monei' ); ?></strong>: <?php esc_html_e( 'MONEI only support EUROS, USD & GBP currencies.', 'monei' ); ?></p></div>
177 <?php
178 endif;
179 }
180 /**
181 * Initialise Gateway Settings Form Fields
182 *
183 * @access public
184 * @return void
185 */
186 function init_form_fields() {
187 $this->form_fields = array(
188 'enabled' => array(
189 'title' => __( 'Enable/Disable', 'monei' ),
190 'type' => 'checkbox',
191 'label' => __( 'Enable MONEI', 'monei' ),
192 'default' => 'no',
193 ),
194 'title' => array(
195 'title' => __( 'Title', 'monei' ),
196 'type' => 'text',
197 'description' => __( 'This controls the title which the user sees during checkout.', 'monei' ),
198 'default' => __( 'MONEI', 'monei' ),
199 'desc_tip' => true,
200 ),
201 'description' => array(
202 'title' => __( 'Description', 'monei' ),
203 'type' => 'textarea',
204 'description' => __( 'This controls the description which the user sees during checkout.', 'monei' ),
205 'default' => __( 'Pay via MONEI; you can pay with your credit card.', 'monei' ),
206 ),
207 'logo' => array(
208 'title' => __( 'Logo', 'monei' ),
209 'type' => 'text',
210 'description' => __( 'Add link to image logo.', 'monei' ),
211 'desc_tip' => true,
212 ),
213 'commercename' => array(
214 'title' => __( 'Shop Name', 'monei' ),
215 'type' => 'text',
216 'description' => __( 'Shop Name', 'monei' ),
217 'desc_tip' => true,
218 ),
219 'accountid' => array(
220 'title' => __( 'Account ID', 'monei' ),
221 'type' => 'text',
222 'description' => __( 'Account ID', 'monei' ),
223 'desc_tip' => true,
224 ),
225 'apikey' => array(
226 'title' => __( 'API Key', 'monei' ),
227 'type' => 'text',
228 'description' => __( 'API Key', 'monei' ),
229 ),
230 'password' => array(
231 'title' => __( 'Password', 'monei' ),
232 'type' => 'text',
233 'description' => __( 'MONEI Password', 'monei' ),
234 'desc_tip' => true,
235 ),
236 'tokenization' => array(
237 'title' => __( 'Enable/Disable', 'monei' ),
238 'type' => 'checkbox',
239 'label' => __( 'Enable Tokenization', 'monei' ),
240 'default' => 'no',
241 ),
242 'orderdo' => array(
243 'title' => __( 'What to do after payment?', 'monei' ),
244 'type' => 'select',
245 'description' => __( 'Chose what to do after the customer pay the order.', 'monei' ),
246 'default' => 'processing',
247 'options' => array(
248 'processing' => __( 'Mark as Processing (default & recomended)', 'monei' ),
249 'completed' => __( 'Mark as Complete', 'monei' ),
250 ),
251 ),
252 'testmode' => array(
253 'title' => __( 'Running in test mode', 'monei' ),
254 'type' => 'checkbox',
255 'label' => __( 'Running in test mode', 'monei' ),
256 'default' => 'yes',
257 'description' => sprintf( __( 'Select this option for the initial testing required by MONEI, deselect this option once you pass the required test phase and your production environment is active.', 'monei' ) ),
258 ),
259 'debug' => array(
260 'title' => __( 'Debug Log', 'monei' ),
261 'type' => 'checkbox',
262 'label' => __( 'Enable logging', 'monei' ),
263 'default' => 'no',
264 'description' => __( 'Log MONEY events, such as notifications requests, inside <code>WooCommerce > Status > Logs > Select MONEI Logs</code>', 'monei' ),
265 ),
266 );
267 }
268
269 function test_mode() {
270 if ( 'yes' === $this->testmode ) {
271 $test = 'true';
272 } else {
273 $test = 'false';
274 }
275 return $test;
276 }
277
278 function amount_format( $total ) {
279 $order_total_sign = number_format( $total, 2, '', '' );
280 return $order_total_sign;
281 }
282
283 function get_monei_args( $order ) {
284 global $woocommerce;
285
286 $order_id = $order->get_id();
287 $url_challenge = get_transient( 'monei_url_challenge_' . sanitize_title( $order_id ) );
288 $param_md = get_transient( 'monei_param_md_challenge_' . sanitize_title( $order_id ) );
289 $param_pareq = get_transient( 'monei_param_pareq_challenge_' . sanitize_title( $order_id ) );
290 $param_termurl = get_transient( 'monei_param_termurl_challenge_' . sanitize_title( $$order_id ) );
291
292 if ( $url_challenge ) {
293
294 $monei_args = array();
295
296 } else {
297
298 $currency = get_woocommerce_currency();
299 $account_id = $this->accountid;
300 $transaction_id = str_pad( $order_id, 12, '0', STR_PAD_LEFT );
301 $transaction_id1 = wp_rand( 1, 999 ); // lets to create a random number.
302 $transaction_id2 = substr_replace( $transaction_id, $transaction_id1, 0, -9 ); // new order number.
303 $amount = $order->get_total();
304 $country = new WC_Countries();
305 $shop_country = $country->get_base_country();
306 $shop_name = $this->commercename;
307 $url_callback = $this->notify_url;
308 $url_cancel = html_entity_decode( $order->get_cancel_order_url() );
309 $url_complete = utf8_encode( add_query_arg( 'utm_nooverride', '1', $this->get_return_url( $order ) ) );
310 $transaction_type = 'sale';
311 $password = $this->password;
312 $test = $this->test_mode();
313
314 $message = 'account_id' . $account_id . 'amount' . $amount . 'currency' . $currency . 'order_id' . $transaction_id2 . 'shop_name' . $shop_name . 'test' . $test . 'transaction_type' . $transaction_type . 'url_callback' . $url_callback . 'url_cancel' . $url_cancel . 'url_complete' . $url_complete;
315
316 $sign = hash_hmac('sha256', $message, $password );
317
318 if ( 'yes' === $this->debug ) {
319 $this->log->add( 'monei', 'Generating payment form for order ' . $order->get_order_number() );
320 $this->log->add( 'monei', 'Helping to understand the encrypted code: ' );
321 $this->log->add( 'monei', 'account_id: ' . $account_id );
322 $this->log->add( 'monei', 'amount: ' . $amount );
323 $this->log->add( 'monei', 'currency: ' . $currency );
324 $this->log->add( 'monei', 'order_id: ' . $transaction_id2 );
325 $this->log->add( 'monei', 'shop_name: ' . $shop_name );
326 $this->log->add( 'monei', 'test: ' . $test );
327 $this->log->add( 'monei', 'url_callback: ' . $url_callback );
328 $this->log->add( 'monei', 'url_cancel: ' . $url_cancel );
329 $this->log->add( 'monei', 'url_complete: ' . $url_complete );
330 $this->log->add( 'monei', 'Password: ' . $password );
331 $this->log->add( 'monei', 'Shop country: ' . $shop_country );
332 $this->log->add( 'monei', 'concatenated: ' . $message );
333 $this->log->add( 'monei', 'sign: ' . $sign );
334 }
335 $monei_args = array(
336 'account_id' => $account_id,
337 'amount' => $amount,
338 'currency' => $currency,
339 'order_id' => $transaction_id2,
340 'shop_name' => $shop_name,
341 'test' => $test,
342 'transaction_type' => $transaction_type,
343 'url_callback' => $url_callback,
344 'url_cancel' => $url_cancel,
345 'url_complete' => $url_complete,
346 'signature' => $sign,
347 );
348 }
349 $monei_args = apply_filters( 'woocommerce_monei_args', $monei_args );
350 return $monei_args;
351 }
352
353 /**
354 * Generate the monei form
355 *
356 * @access public
357 * @param mixed $order_id
358 * @return string
359 */
360 function generate_monei_form( $order_id ) {
361 global $woocommerce;
362
363 $order = new WC_Order( $order_id );
364 $monei_args = $this->get_monei_args( $order );
365 $form_inputs = '';
366 $url_challenge = get_transient( 'monei_url_challenge_' . sanitize_title( $order_id ) );
367 if ( $url_challenge ) {
368 $monei_adr = $url_challenge;
369 } else {
370 $monei_adr = $this->liveurl . '?';
371 }
372
373 foreach ( $monei_args as $key => $value ) {
374 $form_inputs .= '<input type="hidden" name="' . $key . '" value="' . esc_attr( $value ) . '" />';
375 }
376 wc_enqueue_js( '
377 $("body").block({
378 message: "<img src=\"' . esc_url( apply_filters( 'woocommerce_ajax_loader_url', $woocommerce->plugin_url() . '/assets/images/select2-spinner.gif' ) ) . '\" alt=\"Redirecting&hellip;\" style=\"float:left; margin-right: 10px;\" />' . __( 'Thank you for your order. We are now redirecting you to MONEI to make the payment.', 'monei' ) . '",
379 overlayCSS:
380 {
381 background: "#fff",
382 opacity: 1.0
383 },
384 css: {
385 padding: 20,
386 textAlign: "center",
387 color: "#555",
388 border: "3px solid #aaa",
389 backgroundColor:"#fff",
390 cursor: "wait",
391 lineHeight: "32px"
392 }
393 });
394 jQuery("#submit_monei_payment_form").click();
395 ' );
396 return '<form action="' . esc_url( $monei_adr ) . '" method="post" id="monei_payment_form" target="_top">
397 ' . $form_inputs . '
398 <input type="submit" class="button-alt" id="submit_monei_payment_form" value="' . __( 'Pay with Credit Card via MONEI', 'monei' ) . '" /> <a class="button cancel" href="' . esc_url( $order->get_cancel_order_url() ) . '">' . __( 'Cancel order &amp; restore cart', 'monei' ) . '</a>
399 </form>';
400 }
401
402 function get_monei_users_token() {
403 $customer_token = null;
404 if ( is_user_logged_in() ) {
405 $tokens = WC_Payment_Tokens::get_customer_tokens( get_current_user_id(), 'monei' );
406 foreach ( $tokens as $token ) {
407 if ( $token->get_gateway_id() === 'monei' ) {
408 $customer_token = $token->get_token();
409 }
410 }
411 }
412 return $customer_token;
413 }
414
415 function get_users_token_bulk( $user_id ) {
416 $customer_token = null;
417 $tokens = WC_Payment_Tokens::get_customer_tokens( $user_id, 'monei' );
418 foreach ( $tokens as $token ) {
419 if ( $token->get_gateway_id() === 'monei' ) {
420 $customer_token = $token->get_token();
421 }
422 }
423 return $customer_token;
424 }
425
426 protected function order_contains_subscription( $order_id ) {
427 if ( ! function_exists( 'wcs_order_contains_subscription' ) ) {
428 return false;
429 } elseif ( wcs_order_contains_subscription( $order_id ) ) {
430 return true;
431 } elseif ( wcs_order_contains_resubscribe( $order_id ) ) {
432 return true;
433 } elseif ( wcs_order_contains_renewal( $order_id ) ) {
434 return true;
435 } else {
436 return false;
437 }
438 }
439
440 /**
441 * Process the payment and return the result
442 *
443 * @access public
444 * @param int $order_id
445 * @return array
446 */
447 function process_payment( $order_id ) {
448
449 $order = new WC_Order( $order_id );
450 $descripcion = $this->product_description( $order );
451 $transaction_type = 'sale';
452 $currency = get_woocommerce_currency();
453 $order_id = $order->get_id();
454 $user_id = $order->get_user_id();
455 $currency = get_woocommerce_currency();
456 $account_id = $this->accountid;
457 $transaction_id = str_pad( $order_id, 12, '0', STR_PAD_LEFT );
458 $transaction_id1 = wp_rand( 1, 999 ); // lets to create a random number.
459 $transaction_id2 = substr_replace( $transaction_id, $transaction_id1, 0, -9 ); // new order number.
460 $shop_name = $this->commercename;
461 $test = $this->test_mode();
462 $url_callback = $this->notify_url;
463 $url_cancel = html_entity_decode( $order->get_cancel_order_url() );
464 $url_complete = utf8_encode( add_query_arg( 'utm_nooverride', '1', $this->get_return_url( $order ) ) );
465 $userip = WC_Geolocation::get_ip_address();
466 $useragent = wc_get_user_agent();
467 $monei_adr = $this->charge_url;
468 $amount = $this->amount_format( $order->get_total() );
469 $apikey = $this->apikey;
470 $customer_emial = $order->billing_email;
471 $token = false;
472 $token_post_id = false;
473
474 if ( isset( $_POST['moneitoken'] ) ) {
475 $token_post_id = sanitize_text_field( $_POST['moneitoken'] );
476 }
477
478 if ( $token_post_id && ( 'no' !== $token_post_id && 'yes' !== $token_post_id ) ) {
479 $token_ob = WC_Payment_Tokens::get( $token_post_id );
480 $token = $token_ob->get_token();
481 }
482
483 if ( 'yes' === $this->debug ) {
484 $this->log->add( 'monei', '$token_post_id: ' . $token_post_id );
485 $this->log->add( 'monei', '$token: ' . $token );
486 //$this->log->add( 'monei', '$token_ob: ' . print_r( $token_ob, true ) );
487 }
488
489 if ( ( $this->order_contains_subscription( $order_id ) && ! $token ) || ( 'yes' === $this->tokenization && 'yes' === $token_post_id ) ) {
490 update_post_meta( $order_id, 'get_token', 'yes' );
491 $get_token = get_post_meta( $order_id, 'get_token', true );
492 if ( 'yes' === $this->debug ) {
493 $this->log->add( 'monei', '$get_token: ' . $get_token );
494 }
495 $body = array(
496 'amount' => $amount,
497 'currency' => $currency,
498 'orderId' => $transaction_id2,
499 'description' => $descripcion,
500 'customer' => array(
501 'email' => $customer_emial,
502 ),
503 'callbackUrl' => $url_callback,
504 'completeUrl' => $url_complete,
505 'cancelUrl' => $url_cancel,
506 'generatePaymentToken' => 'true',
507 );
508 } elseif ( ( $this->order_contains_subscription( $order_id ) ) || ( 'yes' === $this->tokenization && $token ) ) {
509 $body = array(
510 'amount' => $amount,
511 'currency' => $currency,
512 'orderId' => $transaction_id2,
513 'description' => $descripcion,
514 'customer' => array(
515 'email' => $customer_emial,
516 ),
517 'callbackUrl' => $url_callback,
518 'completeUrl' => $url_complete,
519 'cancelUrl' => $url_cancel,
520 'paymentToken' => $token,
521 );
522 } else {
523 update_post_meta( $order_id, 'get_token', 'no' );
524 $get_token = get_post_meta( $order_id, 'get_token', true );
525 if ( 'yes' === $this->debug ) {
526 $this->log->add( 'monei', '$get_token: ' . $get_token );
527 }
528 $body = array(
529 'amount' => $amount,
530 'currency' => $currency,
531 'orderId' => $transaction_id2,
532 'description' => $descripcion,
533 'customer' => array(
534 'email' => $customer_emial,
535 ),
536 'callbackUrl' => $url_callback,
537 'completeUrl' => $url_complete,
538 'cancelUrl' => $url_cancel,
539 );
540 }
541
542 if ( 'yes' === $this->debug ) {
543 $this->log->add( 'monei', '$body: ' . print_r( json_decode( $body ), true ) );
544 }
545
546 $data_string = json_encode( $body );
547 $options = array(
548 'headers' => array(
549 'Content-Type' => 'application/json',
550 'Authorization' => $apikey,
551 ),
552 'body' => $data_string,
553 );
554 if ( 'yes' === $this->debug ) {
555 $this->log->add( 'monei', print_r( $options, true ) );
556 }
557 $monei_adr = 'https://api.monei.net/v1/payments';
558 $response = wp_remote_post( $monei_adr, $options );
559 $response_code = wp_remote_retrieve_response_code( $response );
560 $response_body = wp_remote_retrieve_body( $response );
561 $result = json_decode( $response_body );
562 $urlchallenge = $result->redirect_url;
563 $refultmonei = $result->result;
564 $status = $result->status;
565 $authorizationCode = $result->authorizationCode;
566 $id = $result->id;
567
568 if ( 'yes' === $this->debug ) {
569 $this->log->add( 'monei', '$response_body: ' . print_r( $response, true ) );
570 $this->log->add( 'monei', 'URL: ' . print_r( $result, true ) );
571 $this->log->add( 'monei', '/*************************/');
572 $this->log->add( 'monei', ' Get URL To redirect ');
573 $this->log->add( 'monei', '/*************************/');
574 $this->log->add( 'monei', '$response_body: ' . $response_body );
575 $this->log->add( 'monei', 'URL: ' . $result->nextAction->redirectUrl );
576 $this->log->add( 'monei', '$status: ' . $status );
577 $this->log->add( 'monei', '$authorizationCode: ' . $authorizationCode );
578 $this->log->add( 'monei', '$id: ' . $id );
579 }
580
581 return array(
582 'result' => 'success',
583 'redirect' => $result->nextAction->redirectUrl,
584 );
585 }
586 /**
587 * Output for the order received page.
588 *
589 * @access public
590 * @return void
591 */
592 function receipt_page( $order ) {
593 echo '<p>' . esc_html__( 'Thank you for your order, please click the button below to pay with Credit Card via MONEI.', 'monei' ) . '</p>';
594 echo $this->generate_monei_form( $order );
595 }
596
597 /**
598 * Check for Monei HTTP Notification
599 *
600 * @access public
601 * @return void
602 */
603 function check_ipn_response() {
604 if ( 'yes' === $this->debug ) {
605 $this->log->add( 'monei', ' ' );
606 $this->log->add( 'monei', '/****************************/' );
607 $this->log->add( 'monei', ' check_ipn_response ' );
608 $this->log->add( 'monei', '/****************************/' );
609 $this->log->add( 'monei', ' ' );
610 }
611 @ob_clean();
612 $json = file_get_contents( 'php://input' );
613 $data = json_decode( $json );
614 $result = $data->status;
615 if ( 'yes' === $this->debug ) {
616 $this->log->add( 'monei', $json );
617 $this->log->add( 'monei', '$result: ' . $result );
618 }
619
620 if ( 'SUCCEEDED' === $result ) {
621 header( 'HTTP/1.1 200 OK' );
622 do_action( 'valid_monei_standard_ipn_request', $data );
623 } else {
624 wp_die( 'MONEI Notification Request Failure' );
625 }
626 }
627 /**
628 * Successful Payment!
629 *
630 * @access public
631 * @param array $posted
632 * @return void
633 */
634 function successful_request( $data ) {
635 global $woocommerce;
636
637 $monei_order_id = sanitize_text_field( $data->id );
638 $order_id = sanitize_text_field( $data->orderId );
639 $message = sanitize_text_field( $data->message );
640 $order2 = substr( $order_id, 3 ); // cojo los 9 digitos del final.
641 $order = $this->get_monei_order( (int) $order2 );
642 $status = sanitize_text_field( $data->status );
643 $amount = floatval( $data->amount ) / 100;
644 $json = file_get_contents( 'php://input' );
645 $data = json_decode( $json );
646
647 if ( 'yes' === $this->debug ) {
648 $this->log->add( 'monei', '$monei_order_id: ' . $monei_order_id );
649 $this->log->add( 'monei', '$order_id: ' . $order_id );
650 $this->log->add( 'monei', '$status: ' . $status );
651 $this->log->add( 'monei', '$message: ' . $message );
652 }
653
654 if ( 'SUCCEEDED' === $status ) {
655 // authorized.
656 $order2 = substr( $order_id, 3 ); //cojo los 9 digitos del final
657 $order = new WC_Order( $order2 );
658 $amountwoo = floatval($order->get_total());
659
660 if ( $amountwoo !== $amount ) {
661 // amount does not match.
662 if ( 'yes' === $this->debug ) {
663 $this->log->add( 'monei', 'Payment error: Amounts do not match (order: ' . $amountwoo . ' - received: ' . $amount . ')' );
664 }
665 // Put this order on-hold for manual checking.
666 /* translators: order an received are the amount */
667 $order->update_status( 'on-hold', sprintf( __( 'Validation error: Order vs. Notification amounts do not match (order: %1$s - received: %2&s).', 'monei' ), $amountwoo, $amount ) );
668 exit;
669 }
670
671 if ( ! empty( $monei_order_id ) ) {
672 update_post_meta( $order->get_id(), '_payment_order_number_monei', $monei_order_id );
673 }
674
675 if ( ! empty( $order_id ) ) {
676 update_post_meta( $order->get_id(), '_payment_wc_order_id_monei', $order_id );
677 }
678
679 // Payment completed.
680 $order->add_order_note( __( 'HTTP Notification received - payment completed', 'monei' ) );
681 $order->add_order_note( __( 'MONEI Order Number: ', 'monei' ) . $monei_order_id );
682 $order->payment_complete();
683 if ( 'completed' === $this->orderdo ) {
684 $order->update_status( 'completed', __( 'Order Completed by MONEI', 'monei' ) );
685 }
686
687 $get_token = get_post_meta( $order->get_id(), 'get_token', true );
688
689 if ( 'yes' === $this->debug ) {
690 $this->log->add( 'monei', '$get_token: ' . $get_token );
691 }
692
693 if ( 'yes' === $get_token ) {
694 $monei = new Monei\MoneiClient( $this->apikey );
695 $data_payment = $monei->payments->get( $monei_order_id );
696
697 $data_array = json_decode( $data_payment );
698
699 if ( isset( $data_array->paymentToken ) ) {
700 if ( 'yes' === $this->debug ) {
701 $this->log->add( 'monei', '$token: ' . $data_array->paymentToken );
702 $this->log->add( 'monei', '$brand: ' .$data->paymentMethod->card->brand );
703 $this->log->add( 'monei', '$lastfour: ' . $data->paymentMethod->card->last4 );
704 }
705 $token_n = $data_array->paymentToken;
706 $brand = $data->paymentMethod->card->brand;
707 $lastfour = $data->paymentMethod->card->last4;
708 $token = new WC_Payment_Token_CC();
709 $token->set_token( $token_n );
710 $token->set_gateway_id( 'monei' );
711 $token->set_user_id( $order->get_user_id() );
712 $token->set_card_type( $brand );
713 $token->set_last4( $lastfour );
714 $token->set_expiry_month( '12' );
715 $token->set_expiry_year( '2040' );
716 $token->set_default( true );
717 $token->save();
718 }
719 }
720
721 if ( 'yes' === $this->debug ) {
722 $this->log->add( 'monei', '$data_payment: ' . $data_payment );
723 }
724
725 if ( 'yes' === $this->debug ) {
726 $this->log->add( 'monei', 'Payment complete.' );
727 }
728 } else {
729 // Tarjeta caducada.
730 if ( 'yes' === $this->debug ) {
731 $this->log->add( 'monei', 'Order cancelled by MONEI: ' . $message );
732 }
733 // Order cancelled.
734 $order->update_status( 'cancelled', 'Cancelled by MONEI: ' . $message);
735 $order->add_order_note( 'Order cancelled by MONEI: ' . $message );
736 WC()->cart->empty_cart();
737 }
738 }
739
740 /**
741 * get_monei_order function.
742 *
743 * @access public
744 * @param mixed $order_id
745 * @return void
746 */
747 function get_monei_order( $order_id ) {
748 $order = new WC_Order( $order_id );
749 return $order;
750 }
751
752 function payment_fields() {
753
754 if ( is_user_logged_in() && 'yes' === $this->tokenization ) {
755 $user_id = get_current_user_id();
756 $tokens = WC_Payment_Tokens::get_customer_tokens( $user_id, $this->id );
757 if ( ! empty( $tokens ) ) {
758 echo '<h4>Select a Credit Card</h4>';
759 echo '<div class="credit-cards-monei">';
760 foreach ( $tokens as $token ) {
761 $is_default = $token->is_default();
762 if ( $is_default ) {
763 $checked = 'checked="checked"';
764 } else {
765 $checked = '';
766 }
767 echo '<div class="moneicreditcards">';
768 echo '<input id="' . $token->get_id() . '" name="moneitoken" type="radio" ' . $checked . ' value="' . $token->get_id() . '"/>';
769 echo '<label for="' . $token->get_id() . '">' . $token->get_card_type() . ' ended in ' . $token->get_last4() . ' ' . $token->get_expiry_month() . '/' . $token->get_expiry_year() . '</label>';
770 echo '</div>';
771 continue;
772 }
773 echo '<div class="moneicreditcards">';
774 echo '<input id="yes" name="moneitoken" type="radio" value="yes"/>';
775 echo '<label for="yes">Add new Credit Card</label>';
776 echo '</div>';
777 echo '<div class="moneicreditcards">';
778 echo '<input id="no" name="moneitoken" type="radio" value="no"/>';
779 echo '<label for="no">Do not use any Credit Card</label>';
780 echo '</div>';
781 echo '</div>';
782 } else {
783 echo '<div class="credit-cards-monei">
784 <h4>Do we save your credit card?</h4>
785 <p>We won\'t keep your card, we\'ll keep a token that MONEI will provide. It\'s totally safe.</p>
786 <div class="moneicreditcards">
787 <input id="yes" name="moneitoken" type="radio" value="yes"/>
788 <label for="yes">Yes</label>
789 </div>
790 <div class="moneicreditcards">
791 <input id="no" name="moneitoken" type="radio" value="no"/>
792 <label for="no">No</label>
793 </div>
794 </div>';
795 }
796 } else {
797 echo $this->description;
798 }
799 }
800 /**
801 * Copyright: (C) 2013 - 2021 José Conti
802 */
803 public function doing_scheduled_subscription_payment( $amount_to_charge, $renewal_order ) {
804
805 $order_id = $renewal_order->get_id();
806 $order = $renewal_order;
807 $amount = $amount_to_charge;
808 $user_id = $order->get_user_id();
809 $descripcion = $this->product_description( $order );
810
811 $transaction_type = 'sale';
812 $currency = get_woocommerce_currency();
813 $currency = get_woocommerce_currency();
814 $account_id = $this->accountid;
815 $transaction_id = str_pad( $order_id, 12, '0', STR_PAD_LEFT );
816 $transaction_id1 = wp_rand( 1, 999 ); // lets to create a random number.
817 $transaction_id2 = substr_replace( $transaction_id, $transaction_id1, 0, -9 ); // new order number.
818 $shop_name = $this->commercename;
819 $test = $this->test_mode();
820 $url_callback = $this->notify_url;
821 $url_cancel = html_entity_decode( $order->get_cancel_order_url() );
822 $url_complete = utf8_encode( add_query_arg( 'utm_nooverride', '1', $this->get_return_url( $order ) ) );
823 $monei_adr = $this->charge_url;
824 $amount = $this->amount_format( $order->get_total() );
825 $apikey = $this->apikey;
826 $customer_emial = $order->billing_email;
827 $token = false;
828 $token_post_id = false;
829
830 $token = $this->get_users_token_bulk( $user_id );
831
832 $body = array(
833 'amount' => $amount,
834 'currency' => $currency,
835 'orderId' => $transaction_id2,
836 'description' => $descripcion,
837 'customer' => array(
838 'email' => $customer_emial,
839 ),
840 'callbackUrl' => $url_callback,
841 'completeUrl' => $url_complete,
842 'cancelUrl' => $url_cancel,
843 'paymentToken' => $token,
844 );
845
846 if ( 'yes' === $this->debug ) {
847 $this->log->add( 'monei', '$body: ' . print_r( json_decode( $body ), true ) );
848 }
849
850 $data_string = json_encode( $body );
851 $options = array(
852 'headers' => array(
853 'Content-Type' => 'application/json',
854 'Authorization' => $apikey,
855 ),
856 'body' => $data_string,
857 );
858 if ( 'yes' === $this->debug ) {
859 $this->log->add( 'monei', print_r( $options, true ) );
860 }
861 $monei_adr = 'https://api.monei.net/v1/payments';
862 $response = wp_remote_post( $monei_adr, $options );
863 $response_code = wp_remote_retrieve_response_code( $response );
864 $response_body = wp_remote_retrieve_body( $response );
865 $result = json_decode( $response_body );
866 $urlchallenge = $result->redirect_url;
867 $refultmonei = $result->result;
868 $status = $result->status;
869 $authorizationCode = $result->authorizationCode;
870 $id = $result->id;
871
872 if ( 'yes' === $this->debug ) {
873 $this->log->add( 'monei', '$response_body: ' . print_r( $response, true ) );
874 $this->log->add( 'monei', 'URL: ' . print_r( $result, true ) );
875 $this->log->add( 'monei', '/*************************/');
876 $this->log->add( 'monei', ' Get URL To redirect ');
877 $this->log->add( 'monei', '/*************************/');
878 $this->log->add( 'monei', '$response_body: ' . $response_body );
879 $this->log->add( 'monei', 'URL: ' . $result->nextAction->redirectUrl );
880 $this->log->add( 'monei', '$status: ' . $status );
881 $this->log->add( 'monei', '$authorizationCode: ' . $authorizationCode );
882 $this->log->add( 'monei', '$id: ' . $id );
883 }
884 }
885 /**
886 * Refund
887 */
888
889 function ask_for_refund( $order_id, $transaction_id, $amount ) {
890
891 //post code to MONEI
892 $order2 = get_post_meta( $order_id, '_payment_wc_order_id_monei', true );
893 $monei_order_number = $transaction_id;
894 $currency_codes = get_woocommerce_currency();
895 $account_id = $this->accountid;
896 $test = $this->test_mode();
897 $transaction_type = 'refund';
898 $shop_name = $this->commercename;
899 $password = $this->password;
900 $country = new WC_Countries();
901 $shop_country = $country->get_base_country();
902 $monei_adr = $this->refund_url;
903
904 $message = 'account_id' . $account_id .
905 'amount' . $amount .
906 'currency' . $currency_codes .
907 'monei_order_id' . $monei_order_number .
908 'order_id' . $order2 .
909 'shop_name' . $shop_name .
910 'test' . $test .
911 'transaction_type' . $transaction_type;
912
913 $sign = hash_hmac('sha256', $message, $password );
914
915 if ( 'yes' === $this->debug ) {
916 $this->log->add( 'monei', ' ' );
917 $this->log->add( 'monei', '$message ' . $message );
918 $this->log->add( 'monei', '$password ' . $password );
919 $this->log->add( 'monei', '$sign: ' . $sign );
920 $this->log->add( 'monei', __( 'Order Number MONEI : ', 'monei' ) . $monei_order_number );
921 }
922
923 if ( 'yes' === $this->debug ) {
924 $this->log->add( 'monei', ' ' );
925 $this->log->add( 'monei', ' ' );
926 $this->log->add( 'monei', '/**************************/' );
927 $this->log->add( 'monei', __( 'Starting asking for Refund', 'monei' ) );
928 $this->log->add( 'monei', '/**************************/' );
929 $this->log->add( 'monei', ' ' );
930 }
931
932 if ( 'yes' === $this->debug ) {
933 $this->log->add( 'monei', ' ' );
934 $this->log->add( 'monei', __( 'All data from meta', 'monei' ) );
935 $this->log->add( 'monei', '**********************' );
936 $this->log->add( 'monei', ' ' );
937 $this->log->add( 'monei', __( 'If something is empty, the data was not saved', 'monei' ) );
938 $this->log->add( 'monei', ' ' );
939 $this->log->add( 'monei', __( 'All data from meta', 'monei' ) );
940 $this->log->add( 'monei', __( 'Order Number MONEI : ', 'monei' ) . $monei_order_number );
941 }
942
943 if ( 'yes' === $this->debug ) {
944 $this->log->add( 'monei', ' ' );
945 $this->log->add( 'monei', __( 'Data sent to MONEI for refund', 'monei' ) );
946 $this->log->add( 'monei', '*********************************' );
947 $this->log->add( 'monei', ' ' );
948 $this->log->add( 'monei', __( 'URL to MONEI : ', 'monei' ) . $monei_adr );
949 $this->log->add( 'monei', __( 'account_id : ', 'monei' ) . $account_id );
950 $this->log->add( 'monei', __( 'amount : ', 'monei' ) . $amount );
951 $this->log->add( 'monei', __( 'currency : ', 'monei' ) . $currency_codes );
952 $this->log->add( 'monei', __( 'order_id : ', 'monei' ) . $order2 );
953 $this->log->add( 'monei', __( 'monei_order_id : ', 'monei' ) . $monei_order_number );
954 $this->log->add( 'monei', __( 'signature : ', 'monei' ) . $sign );
955 $this->log->add( 'monei', __( 'test : ', 'monei' ) . $test );
956 $this->log->add( 'monei', __( 'transaction_type : refund', 'monei' ) );
957 $this->log->add( 'monei', __( 'ask_for_refund Asking for order #: ', 'monei' ) . $order_id );
958 $this->log->add( 'monei', ' ' );
959 }
960
961 $body = array(
962 'account_id' => $account_id,
963 'amount' => $amount,
964 'currency' => $currency_codes,
965 'monei_order_id' => $monei_order_number,
966 'order_id' => $order2,
967 'shop_name' => $shop_name,
968 'signature' => $sign,
969 'test' => $test,
970 'transaction_type' => 'refund',
971 );
972
973 $data_string = json_encode( $body );
974
975 $options = array(
976 'headers' => array(
977 'Content-Type' => 'application/json',
978 ),
979 'body' => $data_string,
980 );
981
982 $response = wp_remote_post( $monei_adr, $options );
983 $response_code = wp_remote_retrieve_response_code( $response );
984 $response_body = wp_remote_retrieve_body( $response );
985
986 if ( is_wp_error( $response ) ) {
987 $error_string = $response->get_error_message();
988 if ( 'yes' === $this->debug ) {
989 $this->log->add( 'monei', ' ' );
990 $this->log->add( 'monei', __( 'There is an error', 'monei' ) );
991 $this->log->add( 'monei', '*********************************' );
992 $this->log->add( 'monei', ' ' );
993 $this->log->add( 'monei', __( 'The error is : ', 'monei' ) . $error_string );
994 }
995 return $error_string;
996 }
997
998 $result = json_decode( $response_body );
999 $end = $result->result;
1000
1001 if ( 'yes' === $this->debug ) {
1002 $this->log->add( 'monei', ' ' );
1003 $this->log->add( 'monei', '$result: ' . $end );
1004 $this->log->add( 'monei', ' ' );
1005 }
1006
1007 if ( 'completed' === $end ) {
1008 return true;
1009 } else {
1010 return $end;
1011 }
1012 }
1013
1014 public function process_refund( $order_id, $amount = null, $reason = '' ) {
1015
1016 // Do your refund here. Refund $amount for the order with ID $order_id _transaction_id
1017 set_time_limit( 0 );
1018 $order = $this->get_monei_order( $order_id );
1019 $order2 = get_post_meta( $order_id, '_payment_wc_order_id_monei', true );
1020 $monei_order_number = get_post_meta( $order_id, '_payment_order_number_monei', true );
1021
1022
1023 if ( ! $amount ) {
1024 $order_total_sign = $order->get_total();
1025 } else {
1026 $order_total_sign = $amount;
1027 }
1028
1029 if ( ! empty( $order2 ) ) {
1030 if ( 'yes' === $this->debug ) {
1031 $this->log->add( 'monei', ' ' );
1032 $this->log->add( 'monei', '/****************************/' );
1033 $this->log->add( 'monei', ' Once upon a time ' );
1034 $this->log->add( 'monei', '/****************************/' );
1035 $this->log->add( 'monei', ' ' );
1036 $this->log->add( 'monei', __( 'check_monei_refund Asking for order #: ', 'monei' ) . $order_id );
1037 }
1038
1039 $refund_asked = $this->ask_for_refund( $order_id, $monei_order_number, $order_total_sign );
1040
1041 if ( $refund_asked ) {
1042 if ( 'yes' === $this->debug && $result ) {
1043 $this->log->add( 'monei', __( 'check_monei_refund = true ', 'monei' ) );
1044 $this->log->add( 'monei', ' ' );
1045 $this->log->add( 'monei', '/********************************/' );
1046 $this->log->add( 'monei', ' Refund complete by MONEI ' );
1047 $this->log->add( 'monei', '/********************************/' );
1048 $this->log->add( 'monei', ' ' );
1049 $this->log->add( 'monei', '/******************************************/' );
1050 $this->log->add( 'monei', ' The final has come, this story has ended ' );
1051 $this->log->add( 'monei', '/******************************************/' );
1052 $this->log->add( 'monei', ' ' );
1053 }
1054 return true;
1055 } else {
1056 if ( is_wp_error( $refund_asked ) ) {
1057 if ( 'yes' === $this->debug ) {
1058 $this->log->add( 'monei', __( 'Refund Failed: ', 'monei' ) . $refund_asked->get_error_message() );
1059 }
1060 return new WP_Error( 'error', $refund_asked->get_error_message() );
1061 }
1062 }
1063
1064 if ( is_wp_error( $refund_asked ) ) {
1065 if ( 'yes' === $this->debug ) {
1066 $this->log->add( 'monei', __( 'Refund Failed: ', 'monei' ) . $refund_asked->get_error_message() );
1067 }
1068 return new WP_Error( 'error', $refund_asked->get_error_message() );
1069 }
1070 } else {
1071 if ( 'yes' === $this->debug && $result ) {
1072 $this->log->add( 'monei', __( 'Refund Failed: No transaction ID', 'monei' ) );
1073 }
1074 return new WP_Error( 'monei', __( 'Refund Failed: No transaction ID', 'monei' ) );
1075 }
1076 }
1077 }
1078
1079 function monei_add_notice_new_version() {
1080
1081 $version = get_option( 'hide-new-version-monei-notice' );
1082
1083 if ( ! $version ) {
1084 if ( isset( $_REQUEST['monei-hide-new-version'] ) && 'hide-new-version-monei' === $_REQUEST['monei-hide-new-version'] ) {
1085 $nonce = sanitize_text_field( $_REQUEST['_monei_hide_new_version_nonce'] );
1086 if ( wp_verify_nonce( $nonce, 'monei_hide_new_version_nonce' ) ) {
1087 update_option( 'hide-new-version-monei-notice', MONEI_VERSION );
1088 }
1089 } else {
1090 ?>
1091 <div id="message" class="updated woocommerce-message woocommerce-monei-messages">
1092 <div class="contenido-monei-notice">
1093 <a class="woocommerce-message-close notice-dismiss" style="top:0;" href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'monei-hide-new-version', 'hide-new-version-monei' ), 'monei_hide_new_version_nonce', '_monei_hide_new_version_nonce' ) ); ?>"><?php esc_html_e( 'Dismiss', 'monei' ); ?></a>
1094 <p>
1095 <h3>
1096 <?php esc_html_e( 'Thank you for install MONEI for WooCommerce. Version: ', 'monei' ) . ' ' . esc_html_e( MONEI_VERSION ); ?>
1097 </h3>
1098 </p>
1099 <p>
1100 <?php esc_html_e( 'The best payment gateway rates. The perfect solution to manage your digital payments.,', 'monei' ); ?>
1101 </p>
1102 <p class="submit">
1103 <a href="<?php esc_html_e( MONEI_SIGNUP ); ?>" class="button-primary" target="_blank"><?php esc_html_e( 'Signup', 'monei' ); ?></a>
1104 <a href="<?php esc_html_e( MONEI_WEB ); ?>" class="button-primary" target="_blank"><?php esc_html_e( 'MONEI website', 'monei' ); ?></a>
1105 <a href="<?php esc_html_e( MONEI_REVIEW ); ?>" class="button-primary" target="_blank"><?php esc_html_e( 'Leave a review', 'monei' ); ?></a>
1106 <a href="<?php esc_html_e( MONEI_SUPPORT ); ?>" class="button-primary" target="_blank"><?php esc_html_e( 'Support', 'monei' ); ?></a>
1107 </p>
1108 </div>
1109 </div>
1110 <?php }
1111 }
1112 }
1113 add_action( 'admin_notices', 'monei_add_notice_new_version' );
1114
1115 function monei_notice_style() {
1116 wp_register_style( 'monei_notice_css', MONEI_PLUGIN_URL . 'assets/css/monei-notice.css', false, MONEI_VERSION );
1117 wp_enqueue_style( 'monei_notice_css' );
1118 }
1119 add_action( 'admin_enqueue_scripts', 'monei_notice_style' );
1120
1121 function monei_style_checkout() {
1122 wp_register_style( 'monei_checkput_css', MONEI_PLUGIN_URL . 'assets/css/monei-checkout-card.css', false, MONEI_VERSION );
1123 wp_enqueue_style( 'monei_checkput_css' );
1124 }
1125 //add_action( 'wp_enqueue_scripts', 'monei_style_checkout' );
1126
1127 function woocommerce_add_gateway_monei_gateway( $methods ) {
1128 $methods[] = 'WC_Gateway_monei';
1129 return $methods;
1130 }
1131 add_filter( 'woocommerce_payment_gateways', 'woocommerce_add_gateway_monei_gateway' );
1132
1133 function add_monei_meta_box() {
1134 $date_decoded = get_post_meta( get_the_ID(), '_payment_date_monei', true );
1135 $hour_decoded = get_post_meta( get_the_ID(), '_payment_hour_monei', true );
1136 echo '<h4>' . esc_html__( 'Payment Details', 'monei' ) . '</h4>';
1137 echo '<p><strong>' . esc_html__( 'MONEI Date', 'monei' ) . ': </strong><br />' . esc_html( $date_decoded ) . '</p>';
1138 echo '<p><strong>' . esc_html__( 'MONEI Hour', 'monei' ) . ': </strong><br />' . esc_html( $hour_decoded ) . '</p>';
1139 echo '<p><strong>' . esc_html__( 'MONEI Order Number', 'monei' ) . ': </strong><br />' . esc_attr( get_post_meta( get_the_ID(), '_payment_order_number_monei', true ) ) . '</p>';
1140 }
1141 add_action( 'woocommerce_admin_order_data_after_billing_address', 'add_monei_meta_box' );
1142 }
1143