WooCommerce MercadoPago - Version 1.8.1

Version Description

  • Corrigido os parametros da conexo (cURL) que podiam gerar erro (SSL connection timeout) em alguns servidores.

=

Download this release

Release Info

Developer claudiosanches
Plugin Icon 128x128 WooCommerce MercadoPago
Version 1.8.1
Comparing to
See all releases

Code changes from version 1.8.0 to 1.8.1

includes/class-wc-mercadopago-gateway.php CHANGED
@@ -13,11 +13,12 @@ class WC_MercadoPago_Gateway extends WC_Payment_Gateway {
13
  */
14
  public function __construct() {
15
 
16
- // Standards
17
- $this->id = 'mercadopago';
 
18
  $this->icon = apply_filters( 'woocommerce_mercadopago_icon', plugins_url( 'images/mercadopago.png', plugin_dir_path( __FILE__ ) ) );
19
  $this->has_fields = false;
20
- $this->method_title = __( 'MercadoPago', 'woocommerce-mercadopago' );
21
 
22
  // API URLs.
23
  $this->payment_url = 'https://api.mercadolibre.com/checkout/preferences?access_token=';
@@ -44,7 +45,7 @@ class WC_MercadoPago_Gateway extends WC_Payment_Gateway {
44
  // Actions.
45
  add_action( 'woocommerce_api_wc_mercadopago_gateway', array( $this, 'check_ipn_response' ) );
46
  add_action( 'valid_mercadopago_ipn_request', array( $this, 'successful_request' ) );
47
- add_action( 'woocommerce_receipt_mercadopago', array( $this, 'receipt_page' ) );
48
  add_action( 'wp_head', array( $this, 'css' ) );
49
  add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) );
50
 
@@ -68,23 +69,20 @@ class WC_MercadoPago_Gateway extends WC_Payment_Gateway {
68
  if ( class_exists( 'WC_Logger' ) ) {
69
  $this->log = new WC_Logger();
70
  } else {
71
- $this->log = $this->woocommerce_instance()->logger();
72
  }
73
  }
74
  }
75
 
76
  /**
77
- * Backwards compatibility with version prior to 2.1.
78
  *
79
- * @return object Returns the main instance of WooCommerce class.
 
 
80
  */
81
- protected function woocommerce_instance() {
82
- if ( function_exists( 'WC' ) ) {
83
- return WC();
84
- } else {
85
- global $woocommerce;
86
- return $woocommerce;
87
- }
88
  }
89
 
90
  /**
@@ -120,76 +118,76 @@ class WC_MercadoPago_Gateway extends WC_Payment_Gateway {
120
  */
121
  public function init_form_fields() {
122
 
123
- $api_secret_locale = sprintf( '<a href="https://www.mercadopago.com/mla/herramientas/aplicaciones" target="_blank">%1$s</a>, <a href="https://www.mercadopago.com/mlb/ferramentas/aplicacoes" target="_blank">%2$s</a>, <a href="https://www.mercadopago.com/mlm/herramientas/aplicaciones" target="_blank">%3$s</a> %5$s <a href="https://www.mercadopago.com/mlv/herramientas/aplicaciones" target="_blank">%4$s</a>', __( 'Argentine', 'woocommerce-mercadopago' ), __( 'Brazil', 'woocommerce-mercadopago' ), __( 'Mexico', 'woocommerce-mercadopago' ), __( 'Venezuela', 'woocommerce-mercadopago' ), __( 'or', 'woocommerce-mercadopago' ) );
124
 
125
  $this->form_fields = array(
126
  'enabled' => array(
127
- 'title' => __( 'Enable/Disable', 'woocommerce-mercadopago' ),
128
  'type' => 'checkbox',
129
- 'label' => __( 'Enable MercadoPago standard', 'woocommerce-mercadopago' ),
130
  'default' => 'yes'
131
  ),
132
  'title' => array(
133
- 'title' => __( 'Title', 'woocommerce-mercadopago' ),
134
  'type' => 'text',
135
- 'description' => __( 'This controls the title which the user sees during checkout.', 'woocommerce-mercadopago' ),
136
  'desc_tip' => true,
137
- 'default' => __( 'MercadoPago', 'woocommerce-mercadopago' )
138
  ),
139
  'description' => array(
140
- 'title' => __( 'Description', 'woocommerce-mercadopago' ),
141
  'type' => 'textarea',
142
- 'description' => __( 'This controls the description which the user sees during checkout.', 'woocommerce-mercadopago' ),
143
- 'default' => __( 'Pay via MercadoPago', 'woocommerce-mercadopago' )
144
  ),
145
  'client_id' => array(
146
- 'title' => __( 'MercadoPago Client_id', 'woocommerce-mercadopago' ),
147
  'type' => 'text',
148
- 'description' => __( 'Please enter your MercadoPago Client_id.', 'woocommerce-mercadopago' ) . ' ' . sprintf( __( 'You can to get this information in MercadoPago from %s.', 'woocommerce-mercadopago' ), $api_secret_locale ),
149
  'default' => ''
150
  ),
151
  'client_secret' => array(
152
- 'title' => __( 'MercadoPago Client_secret', 'woocommerce-mercadopago' ),
153
  'type' => 'text',
154
- 'description' => __( 'Please enter your MercadoPago Client_secret.', 'woocommerce-mercadopago' ) . ' ' . sprintf( __( 'You can to get this information in MercadoPago from %s.', 'woocommerce-mercadopago' ), $api_secret_locale ),
155
  'default' => ''
156
  ),
157
  'invoice_prefix' => array(
158
- 'title' => __( 'Invoice Prefix', 'woocommerce-mercadopago' ),
159
  'type' => 'text',
160
- 'description' => __( 'Please enter a prefix for your invoice numbers. If you use your MercadoPago account for multiple stores ensure this prefix is unqiue as MercadoPago will not allow orders with the same invoice number.', 'woocommerce-mercadopago' ),
161
  'desc_tip' => true,
162
  'default' => 'WC-'
163
  ),
164
  'method' => array(
165
- 'title' => __( 'Integration method', 'woocommerce-mercadopago' ),
166
  'type' => 'select',
167
- 'description' => __( 'Choose how the customer will interact with the MercadoPago. Modal Window (Inside your store) Redirect (Client goes to MercadoPago).', 'woocommerce-mercadopago' ),
168
  'desc_tip' => true,
169
  'default' => 'modal',
170
  'options' => array(
171
- 'modal' => __( 'Modal Window', 'woocommerce-mercadopago' ),
172
- 'redirect' => __( 'Redirect', 'woocommerce-mercadopago' ),
173
  )
174
  ),
175
  'testing' => array(
176
- 'title' => __( 'Gateway Testing', 'woocommerce-mercadopago' ),
177
  'type' => 'title',
178
  'description' => '',
179
  ),
180
  'sandbox' => array(
181
- 'title' => __( 'MercadoPago Sandbox', 'woocommerce-mercadopago' ),
182
  'type' => 'checkbox',
183
- 'label' => __( 'Enable MercadoPago sandbox', 'woocommerce-mercadopago' ),
184
  'default' => 'no',
185
- 'description' => __( 'MercadoPago sandbox can be used to test payments.', 'woocommerce-mercadopago' ),
186
  ),
187
  'debug' => array(
188
- 'title' => __( 'Debug Log', 'woocommerce-mercadopago' ),
189
  'type' => 'checkbox',
190
- 'label' => __( 'Enable logging', 'woocommerce-mercadopago' ),
191
  'default' => 'no',
192
- 'description' => sprintf( __( 'Log MercadoPago events, such as API requests, inside %s', 'woocommerce-mercadopago' ), '<code>woocommerce/logs/mercadopago-' . sanitize_file_name( wp_hash( 'mercadopago' ) ) . '.txt</code>' ),
193
  )
194
  );
195
  }
@@ -236,7 +234,7 @@ class WC_MercadoPago_Gateway extends WC_Payment_Gateway {
236
  }
237
  }
238
 
239
- $args['items'][0]['title'] = sprintf( __( 'Order %s', 'woocommerce-mercadopago' ), $order->get_order_number() ) . ' - ' . implode( ', ', $item_names );
240
 
241
  // Shipping Cost item.
242
  if ( version_compare( WOOCOMMERCE_VERSION, '2.1', '>=' ) ) {
@@ -246,7 +244,7 @@ class WC_MercadoPago_Gateway extends WC_Payment_Gateway {
246
  }
247
 
248
  if ( $shipping_total > 0 ) {
249
- $args['items'][0]['title'] .= ', ' . __( 'Shipping via', 'woocommerce-mercadopago' ) . ' ' . ucwords( $order->shipping_method_title );
250
  }
251
 
252
  $args = apply_filters( 'woocommerce_mercadopago_args', $args, $order );
@@ -262,10 +260,11 @@ class WC_MercadoPago_Gateway extends WC_Payment_Gateway {
262
  * @return string MercadoPago payment url.
263
  */
264
  protected function get_mercadopago_url( $order ) {
 
265
  $args = json_encode( $this->get_payment_args( $order ) );
266
 
267
  if ( 'yes' == $this->debug ) {
268
- $this->log->add( 'mercadopago', 'Payment arguments for order ' . $order->get_order_number() . ': ' . print_r( $this->get_payment_args( $order ), true ) );
269
  }
270
 
271
  $url = $this->payment_url . $this->get_client_credentials();
@@ -273,17 +272,22 @@ class WC_MercadoPago_Gateway extends WC_Payment_Gateway {
273
  $params = array(
274
  'body' => $args,
275
  'sslverify' => false,
276
- 'timeout' => 30,
277
- 'headers' => array( 'content-type' => 'application/json;charset=UTF-8' )
 
 
 
278
  );
279
 
 
280
  $response = wp_remote_post( $url, $params );
 
281
 
282
  if ( ! is_wp_error( $response ) && $response['response']['code'] == 201 && ( strcmp( $response['response']['message'], 'Created' ) == 0 ) ) {
283
  $checkout_info = json_decode( $response['body'] );
284
 
285
  if ( 'yes' == $this->debug ) {
286
- $this->log->add( 'mercadopago', 'Payment link generated with success from MercadoPago' );
287
  }
288
 
289
  if ( 'yes' == $this->sandbox ) {
@@ -294,7 +298,7 @@ class WC_MercadoPago_Gateway extends WC_Payment_Gateway {
294
 
295
  } else {
296
  if ( 'yes' == $this->debug ) {
297
- $this->log->add( 'mercadopago', 'Generate payment error response: ' . print_r( $response, true ) );
298
  }
299
  }
300
 
@@ -316,9 +320,9 @@ class WC_MercadoPago_Gateway extends WC_Payment_Gateway {
316
  if ( $url ) {
317
 
318
  // Display checkout.
319
- $html = '<p>' . __( 'Thank you for your order, please click the button below to pay with MercadoPago.', 'woocommerce-mercadopago' ) . '</p>';
320
 
321
- $html .= '<a id="submit-payment" href="' . $url . '" name="MP-Checkout" class="button alt" mp-mode="modal">' . __( 'Pay via MercadoPago', 'woocommerce-mercadopago' ) . '</a> <a class="button cancel" href="' . esc_url( $order->get_cancel_order_url() ) . '">' . __( 'Cancel order &amp; restore cart', 'woocommerce-mercadopago' ) . '</a>';
322
 
323
  // Add MercadoPago JS.
324
  $html .= '<script type="text/javascript">(function(){function $MPBR_load(){window.$MPBR_loaded !== true && (function(){var s = document.createElement("script");s.type = "text/javascript";s.async = true;s.src = ("https:"==document.location.protocol?"https://www.mercadopago.com/org-img/jsapi/mptools/buttons/":"http://mp-tools.mlstatic.com/buttons/")+"render.js";var x = document.getElementsByTagName("script")[0];x.parentNode.insertBefore(s, x);window.$MPBR_loaded = true;})();}window.$MPBR_loaded !== true ? (window.attachEvent ? window.attachEvent("onload", $MPBR_load) : window.addEventListener("load", $MPBR_load, false)) : null;})();</script>';
@@ -326,9 +330,9 @@ class WC_MercadoPago_Gateway extends WC_Payment_Gateway {
326
  return $html;
327
  } else {
328
  // Display message if a problem occurs.
329
- $html = '<p>' . __( 'An error has occurred while processing your payment, please try again. Or contact us for assistance.', 'woocommerce-mercadopago' ) . '</p>';
330
 
331
- $html .= '<a class="button cancel" href="' . esc_url( $order->get_cancel_order_url() ) . '">' . __( 'Click to try again', 'woocommerce-mercadopago' ) . '</a>';
332
 
333
  return $html;
334
  }
@@ -398,9 +402,8 @@ class WC_MercadoPago_Gateway extends WC_Payment_Gateway {
398
  * @return mixed Sucesse return the token and error return null.
399
  */
400
  protected function get_client_credentials() {
401
-
402
  if ( 'yes' == $this->debug ) {
403
- $this->log->add( 'mercadopago', 'Getting client credentials...' );
404
  }
405
 
406
  // Set postdata.
@@ -412,10 +415,16 @@ class WC_MercadoPago_Gateway extends WC_Payment_Gateway {
412
  $params = array(
413
  'body' => $postdata,
414
  'sslverify' => false,
415
- 'timeout' => 30
 
 
 
 
416
  );
417
 
 
418
  $response = wp_remote_post( $this->oauth_token, $params );
 
419
 
420
  // Check to see if the request was valid and return the token.
421
  if ( ! is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 && ( strcmp( $response['response']['message'], 'OK' ) == 0 ) ) {
@@ -423,13 +432,13 @@ class WC_MercadoPago_Gateway extends WC_Payment_Gateway {
423
  $token = json_decode( $response['body'] );
424
 
425
  if ( 'yes' == $this->debug ) {
426
- $this->log->add( 'mercadopago', 'Received valid response from MercadoPago' );
427
  }
428
 
429
  return $token->access_token;
430
  } else {
431
  if ( 'yes' == $this->debug ) {
432
- $this->log->add( 'mercadopago', 'Received invalid response from MercadoPago. Error response: ' . print_r( $response, true ) );
433
  }
434
  }
435
 
@@ -450,7 +459,7 @@ class WC_MercadoPago_Gateway extends WC_Payment_Gateway {
450
  }
451
 
452
  if ( 'yes' == $this->debug ) {
453
- $this->log->add( 'mercadopago', 'Checking IPN request...' );
454
  }
455
 
456
  if ( 'yes' == $this->sandbox ) {
@@ -463,15 +472,21 @@ class WC_MercadoPago_Gateway extends WC_Payment_Gateway {
463
 
464
  // Send back post vars.
465
  $params = array(
466
- 'sslverify' => false,
467
- 'timeout' => 30
 
 
 
 
468
  );
469
 
470
  // GET a response.
 
471
  $response = wp_remote_get( $url, $params );
 
472
 
473
  if ( 'yes' == $this->debug ) {
474
- $this->log->add( 'mercadopago', 'IPN Response: ' . print_r( $response, true ) );
475
  }
476
 
477
  // Check to see if the request was valid.
@@ -479,12 +494,12 @@ class WC_MercadoPago_Gateway extends WC_Payment_Gateway {
479
 
480
  $body = json_decode( $response['body'] );
481
 
482
- $this->log->add( 'mercadopago', 'Received valid IPN response from MercadoPago' );
483
 
484
  return $body;
485
  } else {
486
  if ( 'yes' == $this->debug ) {
487
- $this->log->add( 'mercadopago', 'Received invalid IPN response from MercadoPago.' );
488
  }
489
  }
490
 
@@ -505,7 +520,7 @@ class WC_MercadoPago_Gateway extends WC_Payment_Gateway {
505
  header( 'HTTP/1.1 200 OK' );
506
  do_action( 'valid_mercadopago_ipn_request', $data );
507
  } else {
508
- wp_die( __( 'MercadoPago Request Failure', 'woocommerce-mercadopago' ) );
509
  }
510
  }
511
 
@@ -530,8 +545,9 @@ class WC_MercadoPago_Gateway extends WC_Payment_Gateway {
530
  // If true processes the payment.
531
  if ( $order->id === $order_id ) {
532
 
533
- if ( 'yes' == $this->debug )
534
- $this->log->add( 'mercadopago', 'Payment status from order ' . $order->get_order_number() . ': ' . $data->status );
 
535
 
536
  switch ( $data->status ) {
537
  case 'approved':
@@ -540,52 +556,52 @@ class WC_MercadoPago_Gateway extends WC_Payment_Gateway {
540
  if ( ! empty( $data->id ) ) {
541
  update_post_meta(
542
  $order_id,
543
- __( 'MercadoPago Transaction ID', 'woocommerce-mercadopago' ),
544
  $data->id
545
  );
546
  }
547
  if ( ! empty( $data->payer->email ) ) {
548
  update_post_meta(
549
  $order_id,
550
- __( 'Payer email', 'woocommerce-mercadopago' ),
551
  $data->payer->email
552
  );
553
  }
554
  if ( ! empty( $data->payment_type ) ) {
555
  update_post_meta(
556
  $order_id,
557
- __( 'Payment type', 'woocommerce-mercadopago' ),
558
  $data->payment_type
559
  );
560
  }
561
 
562
  // Payment completed.
563
- $order->add_order_note( __( 'MercadoPago: Payment approved.', 'woocommerce-mercadopago' ) );
564
  $order->payment_complete();
565
 
566
  break;
567
  case 'pending':
568
- $order->add_order_note( __( 'MercadoPago: The user has not completed the payment process yet.', 'woocommerce-mercadopago' ) );
569
 
570
  break;
571
  case 'in_process':
572
- $order->update_status( 'on-hold', __( 'MercadoPago: Payment under review.', 'woocommerce-mercadopago' ) );
573
 
574
  break;
575
  case 'rejected':
576
- $order->add_order_note( __( 'MercadoPago: The payment was declined. The user can try again.', 'woocommerce-mercadopago' ) );
577
 
578
  break;
579
  case 'refunded':
580
- $order->update_status( 'refunded', __( 'MercadoPago: The payment was returned to the user.', 'woocommerce-mercadopago' ) );
581
 
582
  break;
583
  case 'cancelled':
584
- $order->update_status( 'cancelled', __( 'MercadoPago: Payment canceled.', 'woocommerce-mercadopago' ) );
585
 
586
  break;
587
  case 'in_mediation':
588
- $order->add_order_note( __( 'MercadoPago: It started a dispute for payment.', 'woocommerce-mercadopago' ) );
589
 
590
  break;
591
 
@@ -616,7 +632,7 @@ class WC_MercadoPago_Gateway extends WC_Payment_Gateway {
616
  * @return string Error Mensage.
617
  */
618
  public function client_id_missing_message() {
619
- echo '<div class="error"><p><strong>' . __( 'MercadoPago Disabled', 'woocommerce-mercadopago' ) . '</strong>: ' . sprintf( __( 'You should inform your Client_id. %s', 'woocommerce-mercadopago' ), '<a href="' . $this->admin_url() . '">' . __( 'Click here to configure!', 'woocommerce-mercadopago' ) . '</a>' ) . '</p></div>';
620
  }
621
 
622
  /**
@@ -625,7 +641,7 @@ class WC_MercadoPago_Gateway extends WC_Payment_Gateway {
625
  * @return string Error Mensage.
626
  */
627
  public function client_secret_missing_message() {
628
- echo '<div class="error"><p><strong>' . __( 'MercadoPago Disabled', 'woocommerce-mercadopago' ) . '</strong>: ' . sprintf( __( 'You should inform your Client_secret. %s', 'woocommerce-mercadopago' ), '<a href="' . $this->admin_url() . '">' . __( 'Click here to configure!', 'woocommerce-mercadopago' ) . '</a>' ) . '</p></div>';
629
  }
630
 
631
  /**
@@ -634,6 +650,6 @@ class WC_MercadoPago_Gateway extends WC_Payment_Gateway {
634
  * @return string
635
  */
636
  public function currency_not_supported_message() {
637
- echo '<div class="error"><p><strong>' . __( 'MercadoPago Disabled', 'woocommerce-mercadopago' ) . '</strong>: ' . sprintf( __( 'Currency <code>%s</code> is not supported. Please make sure that you use one of the following supported currencies: ARS, BRL, MXN, USD or VEF.', 'woocommerce-mercadopago' ), get_woocommerce_currency() ) . '</p></div>';
638
  }
639
  }
13
  */
14
  public function __construct() {
15
 
16
+ // Standards.
17
+ $this->id = WC_MercadoPago::get_gateway_id();
18
+ $this->plugin_slug = WC_MercadoPago::get_plugin_slug();
19
  $this->icon = apply_filters( 'woocommerce_mercadopago_icon', plugins_url( 'images/mercadopago.png', plugin_dir_path( __FILE__ ) ) );
20
  $this->has_fields = false;
21
+ $this->method_title = __( 'MercadoPago', $this->plugin_slug );
22
 
23
  // API URLs.
24
  $this->payment_url = 'https://api.mercadolibre.com/checkout/preferences?access_token=';
45
  // Actions.
46
  add_action( 'woocommerce_api_wc_mercadopago_gateway', array( $this, 'check_ipn_response' ) );
47
  add_action( 'valid_mercadopago_ipn_request', array( $this, 'successful_request' ) );
48
+ add_action( 'woocommerce_receipt_' . $this->id, array( $this, 'receipt_page' ) );
49
  add_action( 'wp_head', array( $this, 'css' ) );
50
  add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) );
51
 
69
  if ( class_exists( 'WC_Logger' ) ) {
70
  $this->log = new WC_Logger();
71
  } else {
72
+ $this->log = WC_MercadoPago::woocommerce_instance()->logger();
73
  }
74
  }
75
  }
76
 
77
  /**
78
+ * Fix cURL to works with MercadoPago.
79
  *
80
+ * @param $handle cURL handle.
81
+ *
82
+ * @return void
83
  */
84
+ public function fix_curl_to_mercadopago( $handle ) {
85
+ curl_setopt( $handle, CURLOPT_SSLVERSION, 3 );
 
 
 
 
 
86
  }
87
 
88
  /**
118
  */
119
  public function init_form_fields() {
120
 
121
+ $api_secret_locale = sprintf( '<a href="https://www.mercadopago.com/mla/herramientas/aplicaciones" target="_blank">%1$s</a>, <a href="https://www.mercadopago.com/mlb/ferramentas/aplicacoes" target="_blank">%2$s</a>, <a href="https://www.mercadopago.com/mlm/herramientas/aplicaciones" target="_blank">%3$s</a> %5$s <a href="https://www.mercadopago.com/mlv/herramientas/aplicaciones" target="_blank">%4$s</a>', __( 'Argentine', $this->plugin_slug ), __( 'Brazil', $this->plugin_slug ), __( 'Mexico', $this->plugin_slug ), __( 'Venezuela', $this->plugin_slug ), __( 'or', $this->plugin_slug ) );
122
 
123
  $this->form_fields = array(
124
  'enabled' => array(
125
+ 'title' => __( 'Enable/Disable', $this->plugin_slug ),
126
  'type' => 'checkbox',
127
+ 'label' => __( 'Enable MercadoPago standard', $this->plugin_slug ),
128
  'default' => 'yes'
129
  ),
130
  'title' => array(
131
+ 'title' => __( 'Title', $this->plugin_slug ),
132
  'type' => 'text',
133
+ 'description' => __( 'This controls the title which the user sees during checkout.', $this->plugin_slug ),
134
  'desc_tip' => true,
135
+ 'default' => __( 'MercadoPago', $this->plugin_slug )
136
  ),
137
  'description' => array(
138
+ 'title' => __( 'Description', $this->plugin_slug ),
139
  'type' => 'textarea',
140
+ 'description' => __( 'This controls the description which the user sees during checkout.', $this->plugin_slug ),
141
+ 'default' => __( 'Pay via MercadoPago', $this->plugin_slug )
142
  ),
143
  'client_id' => array(
144
+ 'title' => __( 'MercadoPago Client_id', $this->plugin_slug ),
145
  'type' => 'text',
146
+ 'description' => __( 'Please enter your MercadoPago Client_id.', $this->plugin_slug ) . ' ' . sprintf( __( 'You can to get this information in MercadoPago from %s.', $this->plugin_slug ), $api_secret_locale ),
147
  'default' => ''
148
  ),
149
  'client_secret' => array(
150
+ 'title' => __( 'MercadoPago Client_secret', $this->plugin_slug ),
151
  'type' => 'text',
152
+ 'description' => __( 'Please enter your MercadoPago Client_secret.', $this->plugin_slug ) . ' ' . sprintf( __( 'You can to get this information in MercadoPago from %s.', $this->plugin_slug ), $api_secret_locale ),
153
  'default' => ''
154
  ),
155
  'invoice_prefix' => array(
156
+ 'title' => __( 'Invoice Prefix', $this->plugin_slug ),
157
  'type' => 'text',
158
+ 'description' => __( 'Please enter a prefix for your invoice numbers. If you use your MercadoPago account for multiple stores ensure this prefix is unqiue as MercadoPago will not allow orders with the same invoice number.', $this->plugin_slug ),
159
  'desc_tip' => true,
160
  'default' => 'WC-'
161
  ),
162
  'method' => array(
163
+ 'title' => __( 'Integration method', $this->plugin_slug ),
164
  'type' => 'select',
165
+ 'description' => __( 'Choose how the customer will interact with the MercadoPago. Modal Window (Inside your store) Redirect (Client goes to MercadoPago).', $this->plugin_slug ),
166
  'desc_tip' => true,
167
  'default' => 'modal',
168
  'options' => array(
169
+ 'modal' => __( 'Modal Window', $this->plugin_slug ),
170
+ 'redirect' => __( 'Redirect', $this->plugin_slug ),
171
  )
172
  ),
173
  'testing' => array(
174
+ 'title' => __( 'Gateway Testing', $this->plugin_slug ),
175
  'type' => 'title',
176
  'description' => '',
177
  ),
178
  'sandbox' => array(
179
+ 'title' => __( 'MercadoPago Sandbox', $this->plugin_slug ),
180
  'type' => 'checkbox',
181
+ 'label' => __( 'Enable MercadoPago sandbox', $this->plugin_slug ),
182
  'default' => 'no',
183
+ 'description' => __( 'MercadoPago sandbox can be used to test payments.', $this->plugin_slug ),
184
  ),
185
  'debug' => array(
186
+ 'title' => __( 'Debug Log', $this->plugin_slug ),
187
  'type' => 'checkbox',
188
+ 'label' => __( 'Enable logging', $this->plugin_slug ),
189
  'default' => 'no',
190
+ 'description' => sprintf( __( 'Log MercadoPago events, such as API requests, inside %s', $this->plugin_slug ), '<code>woocommerce/logs/' . $this->id . '-' . sanitize_file_name( wp_hash( $this->id ) ) . '.txt</code>' ),
191
  )
192
  );
193
  }
234
  }
235
  }
236
 
237
+ $args['items'][0]['title'] = sprintf( __( 'Order %s', $this->plugin_slug ), $order->get_order_number() ) . ' - ' . implode( ', ', $item_names );
238
 
239
  // Shipping Cost item.
240
  if ( version_compare( WOOCOMMERCE_VERSION, '2.1', '>=' ) ) {
244
  }
245
 
246
  if ( $shipping_total > 0 ) {
247
+ $args['items'][0]['title'] .= ', ' . __( 'Shipping via', $this->plugin_slug ) . ' ' . ucwords( $order->shipping_method_title );
248
  }
249
 
250
  $args = apply_filters( 'woocommerce_mercadopago_args', $args, $order );
260
  * @return string MercadoPago payment url.
261
  */
262
  protected function get_mercadopago_url( $order ) {
263
+
264
  $args = json_encode( $this->get_payment_args( $order ) );
265
 
266
  if ( 'yes' == $this->debug ) {
267
+ $this->log->add( $this->id, 'Payment arguments for order ' . $order->get_order_number() . ': ' . print_r( $this->get_payment_args( $order ), true ) );
268
  }
269
 
270
  $url = $this->payment_url . $this->get_client_credentials();
272
  $params = array(
273
  'body' => $args,
274
  'sslverify' => false,
275
+ 'timeout' => 60,
276
+ 'headers' => array(
277
+ 'Accept' => 'application/json',
278
+ 'Content-Type' => 'application/json;charset=UTF-8'
279
+ )
280
  );
281
 
282
+ add_action( 'http_api_curl', array( $this, 'fix_curl_to_mercadopago' ) );
283
  $response = wp_remote_post( $url, $params );
284
+ remove_action( 'http_api_curl', array( $this, 'fix_curl_to_mercadopago' ) );
285
 
286
  if ( ! is_wp_error( $response ) && $response['response']['code'] == 201 && ( strcmp( $response['response']['message'], 'Created' ) == 0 ) ) {
287
  $checkout_info = json_decode( $response['body'] );
288
 
289
  if ( 'yes' == $this->debug ) {
290
+ $this->log->add( $this->id, 'Payment link generated with success from MercadoPago' );
291
  }
292
 
293
  if ( 'yes' == $this->sandbox ) {
298
 
299
  } else {
300
  if ( 'yes' == $this->debug ) {
301
+ $this->log->add( $this->id, 'Generate payment error response: ' . print_r( $response, true ) );
302
  }
303
  }
304
 
320
  if ( $url ) {
321
 
322
  // Display checkout.
323
+ $html = '<p>' . __( 'Thank you for your order, please click the button below to pay with MercadoPago.', $this->plugin_slug ) . '</p>';
324
 
325
+ $html .= '<a id="submit-payment" href="' . $url . '" name="MP-Checkout" class="button alt" mp-mode="modal">' . __( 'Pay via MercadoPago', $this->plugin_slug ) . '</a> <a class="button cancel" href="' . esc_url( $order->get_cancel_order_url() ) . '">' . __( 'Cancel order &amp; restore cart', $this->plugin_slug ) . '</a>';
326
 
327
  // Add MercadoPago JS.
328
  $html .= '<script type="text/javascript">(function(){function $MPBR_load(){window.$MPBR_loaded !== true && (function(){var s = document.createElement("script");s.type = "text/javascript";s.async = true;s.src = ("https:"==document.location.protocol?"https://www.mercadopago.com/org-img/jsapi/mptools/buttons/":"http://mp-tools.mlstatic.com/buttons/")+"render.js";var x = document.getElementsByTagName("script")[0];x.parentNode.insertBefore(s, x);window.$MPBR_loaded = true;})();}window.$MPBR_loaded !== true ? (window.attachEvent ? window.attachEvent("onload", $MPBR_load) : window.addEventListener("load", $MPBR_load, false)) : null;})();</script>';
330
  return $html;
331
  } else {
332
  // Display message if a problem occurs.
333
+ $html = '<p>' . __( 'An error has occurred while processing your payment, please try again. Or contact us for assistance.', $this->plugin_slug ) . '</p>';
334
 
335
+ $html .= '<a class="button cancel" href="' . esc_url( $order->get_cancel_order_url() ) . '">' . __( 'Click to try again', $this->plugin_slug ) . '</a>';
336
 
337
  return $html;
338
  }
402
  * @return mixed Sucesse return the token and error return null.
403
  */
404
  protected function get_client_credentials() {
 
405
  if ( 'yes' == $this->debug ) {
406
+ $this->log->add( $this->id, 'Getting client credentials...' );
407
  }
408
 
409
  // Set postdata.
415
  $params = array(
416
  'body' => $postdata,
417
  'sslverify' => false,
418
+ 'timeout' => 60,
419
+ 'headers' => array(
420
+ 'Accept' => 'application/json',
421
+ 'Content-Type' => 'application/x-www-form-urlencoded'
422
+ )
423
  );
424
 
425
+ add_action( 'http_api_curl', array( $this, 'fix_curl_to_mercadopago' ) );
426
  $response = wp_remote_post( $this->oauth_token, $params );
427
+ remove_action( 'http_api_curl', array( $this, 'fix_curl_to_mercadopago' ) );
428
 
429
  // Check to see if the request was valid and return the token.
430
  if ( ! is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 && ( strcmp( $response['response']['message'], 'OK' ) == 0 ) ) {
432
  $token = json_decode( $response['body'] );
433
 
434
  if ( 'yes' == $this->debug ) {
435
+ $this->log->add( $this->id, 'Received valid response from MercadoPago' );
436
  }
437
 
438
  return $token->access_token;
439
  } else {
440
  if ( 'yes' == $this->debug ) {
441
+ $this->log->add( $this->id, 'Received invalid response from MercadoPago. Error response: ' . print_r( $response, true ) );
442
  }
443
  }
444
 
459
  }
460
 
461
  if ( 'yes' == $this->debug ) {
462
+ $this->log->add( $this->id, 'Checking IPN request...' );
463
  }
464
 
465
  if ( 'yes' == $this->sandbox ) {
472
 
473
  // Send back post vars.
474
  $params = array(
475
+ 'sslverify' => false,
476
+ 'timeout' => 60,
477
+ 'headers' => array(
478
+ 'Accept' => 'application/json',
479
+ 'Content-Type' => 'application/json;charset=UTF-8'
480
+ )
481
  );
482
 
483
  // GET a response.
484
+ add_action( 'http_api_curl', array( $this, 'fix_curl_to_mercadopago' ) );
485
  $response = wp_remote_get( $url, $params );
486
+ remove_action( 'http_api_curl', array( $this, 'fix_curl_to_mercadopago' ) );
487
 
488
  if ( 'yes' == $this->debug ) {
489
+ $this->log->add( $this->id, 'IPN Response: ' . print_r( $response, true ) );
490
  }
491
 
492
  // Check to see if the request was valid.
494
 
495
  $body = json_decode( $response['body'] );
496
 
497
+ $this->log->add( $this->id, 'Received valid IPN response from MercadoPago' );
498
 
499
  return $body;
500
  } else {
501
  if ( 'yes' == $this->debug ) {
502
+ $this->log->add( $this->id, 'Received invalid IPN response from MercadoPago.' );
503
  }
504
  }
505
 
520
  header( 'HTTP/1.1 200 OK' );
521
  do_action( 'valid_mercadopago_ipn_request', $data );
522
  } else {
523
+ wp_die( __( 'MercadoPago Request Failure', $this->plugin_slug ) );
524
  }
525
  }
526
 
545
  // If true processes the payment.
546
  if ( $order->id === $order_id ) {
547
 
548
+ if ( 'yes' == $this->debug ) {
549
+ $this->log->add( $this->id, 'Payment status from order ' . $order->get_order_number() . ': ' . $data->status );
550
+ }
551
 
552
  switch ( $data->status ) {
553
  case 'approved':
556
  if ( ! empty( $data->id ) ) {
557
  update_post_meta(
558
  $order_id,
559
+ __( 'MercadoPago Transaction ID', $this->plugin_slug ),
560
  $data->id
561
  );
562
  }
563
  if ( ! empty( $data->payer->email ) ) {
564
  update_post_meta(
565
  $order_id,
566
+ __( 'Payer email', $this->plugin_slug ),
567
  $data->payer->email
568
  );
569
  }
570
  if ( ! empty( $data->payment_type ) ) {
571
  update_post_meta(
572
  $order_id,
573
+ __( 'Payment type', $this->plugin_slug ),
574
  $data->payment_type
575
  );
576
  }
577
 
578
  // Payment completed.
579
+ $order->add_order_note( __( 'MercadoPago: Payment approved.', $this->plugin_slug ) );
580
  $order->payment_complete();
581
 
582
  break;
583
  case 'pending':
584
+ $order->add_order_note( __( 'MercadoPago: The user has not completed the payment process yet.', $this->plugin_slug ) );
585
 
586
  break;
587
  case 'in_process':
588
+ $order->update_status( 'on-hold', __( 'MercadoPago: Payment under review.', $this->plugin_slug ) );
589
 
590
  break;
591
  case 'rejected':
592
+ $order->add_order_note( __( 'MercadoPago: The payment was declined. The user can try again.', $this->plugin_slug ) );
593
 
594
  break;
595
  case 'refunded':
596
+ $order->update_status( 'refunded', __( 'MercadoPago: The payment was returned to the user.', $this->plugin_slug ) );
597
 
598
  break;
599
  case 'cancelled':
600
+ $order->update_status( 'cancelled', __( 'MercadoPago: Payment canceled.', $this->plugin_slug ) );
601
 
602
  break;
603
  case 'in_mediation':
604
+ $order->add_order_note( __( 'MercadoPago: It started a dispute for payment.', $this->plugin_slug ) );
605
 
606
  break;
607
 
632
  * @return string Error Mensage.
633
  */
634
  public function client_id_missing_message() {
635
+ echo '<div class="error"><p><strong>' . __( 'MercadoPago Disabled', $this->plugin_slug ) . '</strong>: ' . sprintf( __( 'You should inform your Client_id. %s', $this->plugin_slug ), '<a href="' . $this->admin_url() . '">' . __( 'Click here to configure!', $this->plugin_slug ) . '</a>' ) . '</p></div>';
636
  }
637
 
638
  /**
641
  * @return string Error Mensage.
642
  */
643
  public function client_secret_missing_message() {
644
+ echo '<div class="error"><p><strong>' . __( 'MercadoPago Disabled', $this->plugin_slug ) . '</strong>: ' . sprintf( __( 'You should inform your Client_secret. %s', $this->plugin_slug ), '<a href="' . $this->admin_url() . '">' . __( 'Click here to configure!', $this->plugin_slug ) . '</a>' ) . '</p></div>';
645
  }
646
 
647
  /**
650
  * @return string
651
  */
652
  public function currency_not_supported_message() {
653
+ echo '<div class="error"><p><strong>' . __( 'MercadoPago Disabled', $this->plugin_slug ) . '</strong>: ' . sprintf( __( 'Currency <code>%s</code> is not supported. Please make sure that you use one of the following supported currencies: ARS, BRL, MXN, USD or VEF.', $this->plugin_slug ), get_woocommerce_currency() ) . '</p></div>';
654
  }
655
  }
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: claudiosanches
3
  Donate link: http://claudiosmweb.com/doacoes/
4
  Tags: woocommerce, mercadopago, payment
5
  Requires at least: 3.5
6
- Tested up to: 3.8
7
- Stable tag: 1.8.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -188,6 +188,10 @@ Entre em contato [clicando aqui](http://claudiosmweb.com/plugins/mercadopago-par
188
 
189
  == Changelog ==
190
 
 
 
 
 
191
  = 1.8.0 - 04/12/2013 =
192
 
193
  * Corrigido padrões de código.
@@ -255,10 +259,9 @@ Entre em contato [clicando aqui](http://claudiosmweb.com/plugins/mercadopago-par
255
 
256
  == Upgrade Notice ==
257
 
258
- = 1.8.0 =
259
 
260
- * Removida compatibilidade com versões 1.6.x ou inferiores do WooCommerce.
261
- * Adicionada compatibilidade com WooCommerce 2.1 ou superior.
262
 
263
  == License ==
264
 
3
  Donate link: http://claudiosmweb.com/doacoes/
4
  Tags: woocommerce, mercadopago, payment
5
  Requires at least: 3.5
6
+ Tested up to: 3.9
7
+ Stable tag: 1.8.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
188
 
189
  == Changelog ==
190
 
191
+ = 1.8.1 - 17/12/2013 =
192
+
193
+ * Corrigido os parametros da conexão (cURL) que podiam gerar erro (`SSL connection timeout`) em alguns servidores.
194
+
195
  = 1.8.0 - 04/12/2013 =
196
 
197
  * Corrigido padrões de código.
259
 
260
  == Upgrade Notice ==
261
 
262
+ = 1.8.1 =
263
 
264
+ * Corrigido os parametros da conexão (cURL) que podiam gerar erro (`SSL connection timeout`) em alguns servidores.
 
265
 
266
  == License ==
267
 
wc-mercadopago.php CHANGED
@@ -5,56 +5,172 @@
5
  * Description: MercadoPago gateway for Woocommerce.
6
  * Author: claudiosanches
7
  * Author URI: http://claudiosmweb.com/
8
- * Version: 1.8.0
9
  * License: GPLv2 or later
10
  * Text Domain: woocommerce-mercadopago
11
  * Domain Path: /languages/
12
  */
13
 
14
- /**
15
- * WooCommerce fallback notice.
16
- */
17
- function wcmercadopago_woocommerce_fallback_notice() {
18
- echo '<div class="error"><p>' . sprintf( __( 'WooCommerce MercadoPago Gateway depends on the last version of %s to work!', 'woocommerce-mercadopago' ), '<a href="http://wordpress.org/extend/plugins/woocommerce/">WooCommerce</a>' ) . '</p></div>';
19
  }
20
 
 
 
21
  /**
22
- * Load functions.
23
  */
24
- function wcmercadopago_gateway_load() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
 
26
- if ( ! class_exists( 'WC_Payment_Gateway' ) ) {
27
- add_action( 'admin_notices', 'wcmercadopago_woocommerce_fallback_notice' );
 
 
 
 
 
 
 
 
 
 
 
28
 
29
- return;
 
 
 
 
 
 
 
 
30
  }
31
 
32
  /**
33
- * Load textdomain.
 
 
 
 
34
  */
35
- load_plugin_textdomain( 'woocommerce-mercadopago', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
 
 
 
 
 
 
36
 
37
  /**
38
  * Add the gateway to WooCommerce.
39
  *
40
- * @param array $methods Default methods.
 
 
41
  *
42
- * @return array Methods with MercadoPago gateway.
43
  */
44
- function wcmercadopago_add_gateway( $methods ) {
45
  $methods[] = 'WC_MercadoPago_Gateway';
46
 
47
  return $methods;
48
  }
49
 
50
- add_filter( 'woocommerce_payment_gateways', 'wcmercadopago_add_gateway' );
51
-
52
- // Include the WC_MercadoPago_Gateway class.
53
- require_once plugin_dir_path( __FILE__ ) . 'includes/class-wc-mercadopago-gateway.php';
 
 
 
 
 
 
54
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
  }
56
 
57
- add_action( 'plugins_loaded', 'wcmercadopago_gateway_load', 0 );
58
 
59
  /**
60
  * Adds support to legacy IPN.
@@ -63,15 +179,13 @@ add_action( 'plugins_loaded', 'wcmercadopago_gateway_load', 0 );
63
  */
64
  function wcmercadopago_legacy_ipn() {
65
  if ( isset( $_GET['topic'] ) && ! isset( $_GET['wc-api'] ) ) {
66
- if ( version_compare( WOOCOMMERCE_VERSION, '2.1', '>=' ) ) {
67
- WC()->payment_gateways();
68
- } else {
69
- global $woocommerce;
70
- $woocommerce->payment_gateways();
71
- }
72
 
73
  do_action( 'woocommerce_api_wc_mercadopago_gateway' );
74
  }
75
  }
76
 
77
  add_action( 'init', 'wcmercadopago_legacy_ipn' );
 
 
5
  * Description: MercadoPago gateway for Woocommerce.
6
  * Author: claudiosanches
7
  * Author URI: http://claudiosmweb.com/
8
+ * Version: 1.9.0
9
  * License: GPLv2 or later
10
  * Text Domain: woocommerce-mercadopago
11
  * Domain Path: /languages/
12
  */
13
 
14
+ if ( ! defined( 'ABSPATH' ) ) {
15
+ exit; // Exit if accessed directly.
 
 
 
16
  }
17
 
18
+ if ( ! class_exists( 'WC_MercadoPago' ) ) :
19
+
20
  /**
21
+ * WooCommerce MercadoPago main class.
22
  */
23
+ class WC_MercadoPago {
24
+
25
+ /**
26
+ * Plugin version.
27
+ *
28
+ * @since 1.9.0
29
+ *
30
+ * @var string
31
+ */
32
+ const VERSION = '1.9.0';
33
+
34
+ /**
35
+ * Integration id.
36
+ *
37
+ * @since 1.9.0
38
+ *
39
+ * @var string
40
+ */
41
+ protected static $gateway_id = 'mercadopago';
42
+
43
+ /**
44
+ * Plugin slug.
45
+ *
46
+ * @since 1.9.0
47
+ *
48
+ * @var string
49
+ */
50
+ protected static $plugin_slug = 'woocommerce-mercadopago';
51
+
52
+ /**
53
+ * Instance of this class.
54
+ *
55
+ * @since 1.9.0
56
+ *
57
+ * @var object
58
+ */
59
+ protected static $instance = null;
60
+
61
+ /**
62
+ * Initialize the plugin.
63
+ */
64
+ private function __construct() {
65
+ // Load plugin text domain
66
+ add_action( 'init', array( $this, 'load_plugin_textdomain' ) );
67
+
68
+ // Checks with WooCommerce is installed.
69
+ if ( class_exists( 'WC_Payment_Gateway' ) ) {
70
+ // Include the WC_MercadoPago_Gateway class.
71
+ include_once 'includes/class-wc-mercadopago-gateway.php';
72
+
73
+ add_filter( 'woocommerce_payment_gateways', array( $this, 'add_gateway' ) );
74
+ } else {
75
+ add_action( 'admin_notices', array( $this, 'woocommerce_missing_notice' ) );
76
+ }
77
+ }
78
+
79
+ /**
80
+ * Return an instance of this class.
81
+ *
82
+ * @since 1.9.0
83
+ *
84
+ * @return object A single instance of this class.
85
+ */
86
+ public static function get_instance() {
87
+ // If the single instance hasn't been set, set it now.
88
+ if ( null == self::$instance ) {
89
+ self::$instance = new self;
90
+ }
91
 
92
+ return self::$instance;
93
+ }
94
+
95
+ /**
96
+ * Return the plugin slug.
97
+ *
98
+ * @since 1.9.0
99
+ *
100
+ * @return string Plugin slug variable.
101
+ */
102
+ public static function get_plugin_slug() {
103
+ return self::$plugin_slug;
104
+ }
105
 
106
+ /**
107
+ * Return the gateway id/slug.
108
+ *
109
+ * @since 1.9.0
110
+ *
111
+ * @return string Gateway id/slug variable.
112
+ */
113
+ public static function get_gateway_id() {
114
+ return self::$gateway_id;
115
  }
116
 
117
  /**
118
+ * Load the plugin text domain for translation.
119
+ *
120
+ * @since 1.9.0
121
+ *
122
+ * @return void
123
  */
124
+ public function load_plugin_textdomain() {
125
+ $domain = self::$plugin_slug;
126
+ $locale = apply_filters( 'plugin_locale', get_locale(), $domain );
127
+
128
+ load_textdomain( $domain, trailingslashit( WP_LANG_DIR ) . $domain . '/' . $domain . '-' . $locale . '.mo' );
129
+ load_plugin_textdomain( $domain, false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
130
+ }
131
 
132
  /**
133
  * Add the gateway to WooCommerce.
134
  *
135
+ * @version 1.9.0
136
+ *
137
+ * @param array $methods WooCommerce payment methods.
138
  *
139
+ * @return array Payment methods with MercadoPago.
140
  */
141
+ public function add_gateway( $methods ) {
142
  $methods[] = 'WC_MercadoPago_Gateway';
143
 
144
  return $methods;
145
  }
146
 
147
+ /**
148
+ * WooCommerce fallback notice.
149
+ *
150
+ * @version 1.9.0
151
+ *
152
+ * @return string
153
+ */
154
+ public function woocommerce_missing_notice() {
155
+ echo '<div class="error"><p>' . sprintf( __( 'WooCommerce MercadoPago Gateway depends on the last version of %s to work!', self::$plugin_slug ), '<a href="http://wordpress.org/extend/plugins/woocommerce/">' . __( 'WooCommerce', self::$plugin_slug ) . '</a>' ) . '</p></div>';
156
+ }
157
 
158
+ /**
159
+ * Backwards compatibility with version prior to 2.1.
160
+ *
161
+ * @return object Returns the main instance of WooCommerce class.
162
+ */
163
+ public static function woocommerce_instance() {
164
+ if ( function_exists( 'WC' ) ) {
165
+ return WC();
166
+ } else {
167
+ global $woocommerce;
168
+ return $woocommerce;
169
+ }
170
+ }
171
  }
172
 
173
+ add_action( 'plugins_loaded', array( 'WC_MercadoPago', 'get_instance' ), 0 );
174
 
175
  /**
176
  * Adds support to legacy IPN.
179
  */
180
  function wcmercadopago_legacy_ipn() {
181
  if ( isset( $_GET['topic'] ) && ! isset( $_GET['wc-api'] ) ) {
182
+ $woocommerce = WC_MercadoPago::woocommerce_instance();
183
+ $woocommerce->payment_gateways();
 
 
 
 
184
 
185
  do_action( 'woocommerce_api_wc_mercadopago_gateway' );
186
  }
187
  }
188
 
189
  add_action( 'init', 'wcmercadopago_legacy_ipn' );
190
+
191
+ endif;