Version Description
Download this release
Release Info
| Developer | mercadopago |
| Plugin | |
| Version | 5.7.6 |
| Comparing to | |
| See all releases | |
Code changes from version 5.7.5 to 5.7.6
- includes/module/config/class-wc-woomercadopago-constants.php +2 -1
- includes/module/preference/class-wc-woomercadopago-preference-ticket.php +1 -1
- includes/module/sdk/lib/class-mp.php +14 -0
- includes/notification/class-wc-woomercadopago-notification-ipn.php +20 -6
- includes/notification/class-wc-woomercadopago-notification-webhook.php +6 -3
- includes/payments/class-wc-woomercadopago-ticket-gateway.php +2 -2
- readme.txt +7 -1
- woocommerce-mercadopago.php +1 -1
includes/module/config/class-wc-woomercadopago-constants.php
CHANGED
|
@@ -21,9 +21,10 @@ class WC_WooMercadoPago_Constants {
|
|
| 21 |
const PRODUCT_ID_DESKTOP = 'BT7OF5FEOO6G01NJK3QG';
|
| 22 |
const PRODUCT_ID_MOBILE = 'BT7OFH09QS3001K5A0H0';
|
| 23 |
const PLATAFORM_ID = 'bo2hnr2ic4p001kbgpt0';
|
| 24 |
-
const VERSION = '5.7.
|
| 25 |
const MIN_PHP = 5.6;
|
| 26 |
const API_MP_BASE_URL = 'https://api.mercadopago.com';
|
|
|
|
| 27 |
const PAYMENT_GATEWAYS = array(
|
| 28 |
'WC_WooMercadoPago_Basic_Gateway',
|
| 29 |
'WC_WooMercadoPago_Custom_Gateway',
|
| 21 |
const PRODUCT_ID_DESKTOP = 'BT7OF5FEOO6G01NJK3QG';
|
| 22 |
const PRODUCT_ID_MOBILE = 'BT7OFH09QS3001K5A0H0';
|
| 23 |
const PLATAFORM_ID = 'bo2hnr2ic4p001kbgpt0';
|
| 24 |
+
const VERSION = '5.7.6';
|
| 25 |
const MIN_PHP = 5.6;
|
| 26 |
const API_MP_BASE_URL = 'https://api.mercadopago.com';
|
| 27 |
+
const DATE_EXPIRATION = 3;
|
| 28 |
const PAYMENT_GATEWAYS = array(
|
| 29 |
'WC_WooMercadoPago_Basic_Gateway',
|
| 30 |
'WC_WooMercadoPago_Custom_Gateway',
|
includes/module/preference/class-wc-woomercadopago-preference-ticket.php
CHANGED
|
@@ -30,7 +30,7 @@ class WC_WooMercadoPago_Preference_Ticket extends WC_WooMercadoPago_Preference_A
|
|
| 30 |
|
| 31 |
$helper = new WC_WooMercadoPago_Composite_Id_Helper();
|
| 32 |
$id = $ticket_checkout['paymentMethodId'];
|
| 33 |
-
$date_expiration = $payment->
|
| 34 |
$this->preference = $this->make_commum_preference();
|
| 35 |
$this->preference['payment_method_id'] = $helper->getPaymentMethodId($id);
|
| 36 |
$this->preference['date_of_expiration'] = $this->get_date_of_expiration( $date_expiration );
|
| 30 |
|
| 31 |
$helper = new WC_WooMercadoPago_Composite_Id_Helper();
|
| 32 |
$id = $ticket_checkout['paymentMethodId'];
|
| 33 |
+
$date_expiration = $payment->get_option( 'date_expiration', WC_WooMercadoPago_Constants::DATE_EXPIRATION ) . ' days';
|
| 34 |
$this->preference = $this->make_commum_preference();
|
| 35 |
$this->preference['payment_method_id'] = $helper->getPaymentMethodId($id);
|
| 36 |
$this->preference['date_of_expiration'] = $this->get_date_of_expiration( $date_expiration );
|
includes/module/sdk/lib/class-mp.php
CHANGED
|
@@ -171,6 +171,20 @@ class MP {
|
|
| 171 |
* @throws WC_WooMercadoPago_Exception Search Payment V1 Exception.
|
| 172 |
*/
|
| 173 |
public function search_payment_v1( $id, $token = null ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 174 |
$request = array(
|
| 175 |
'uri' => '/v1/payments/' . $id,
|
| 176 |
'headers' => array(
|
| 171 |
* @throws WC_WooMercadoPago_Exception Search Payment V1 Exception.
|
| 172 |
*/
|
| 173 |
public function search_payment_v1( $id, $token = null ) {
|
| 174 |
+
$key = sprintf( '%s%s', __FUNCTION__, $id );
|
| 175 |
+
|
| 176 |
+
$cache = $this->get_cache_response( $key );
|
| 177 |
+
|
| 178 |
+
if ( ! empty( $cache ) ) {
|
| 179 |
+
$this->debug_mode_log(
|
| 180 |
+
'mercadopago_requests',
|
| 181 |
+
__FUNCTION__,
|
| 182 |
+
__( 'Response from cache', 'woocommerce-mercadopago' )
|
| 183 |
+
);
|
| 184 |
+
|
| 185 |
+
return $cache;
|
| 186 |
+
}
|
| 187 |
+
|
| 188 |
$request = array(
|
| 189 |
'uri' => '/v1/payments/' . $id,
|
| 190 |
'headers' => array(
|
includes/notification/class-wc-woomercadopago-notification-ipn.php
CHANGED
|
@@ -91,16 +91,19 @@ class WC_WooMercadoPago_Notification_IPN extends WC_WooMercadoPago_Notification_
|
|
| 91 |
public function process_status_mp_business( $data, $order ) {
|
| 92 |
$status = 'pending';
|
| 93 |
$payments = $data['payments'];
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
$
|
| 97 |
-
} elseif ( count( $payments ) > 1 ) {
|
| 98 |
-
// However, if we have multiple payments, the overall payment have some rules.
|
| 99 |
$total_paid = 0.00;
|
| 100 |
$total_refund = 0.00;
|
| 101 |
-
$total = $data['shipping_cost'] + $data['total_amount'];
|
| 102 |
// Grab some information...
|
| 103 |
foreach ( $data['payments'] as $payment ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 104 |
if ( 'approved' === $payment['status'] ) {
|
| 105 |
// Get the total paid amount, considering only approved incomings.
|
| 106 |
$total_paid += (float) $payment['total_paid_amount'];
|
|
@@ -109,6 +112,7 @@ class WC_WooMercadoPago_Notification_IPN extends WC_WooMercadoPago_Notification_
|
|
| 109 |
$total_refund += (float) $payment['amount_refunded'];
|
| 110 |
}
|
| 111 |
}
|
|
|
|
| 112 |
if ( $total_paid >= $total ) {
|
| 113 |
$status = 'approved';
|
| 114 |
} elseif ( $total_refund >= $total ) {
|
|
@@ -133,12 +137,14 @@ class WC_WooMercadoPago_Notification_IPN extends WC_WooMercadoPago_Notification_
|
|
| 133 |
if ( ! empty( $data['payments'] ) ) {
|
| 134 |
$payment_ids = array();
|
| 135 |
foreach ( $data['payments'] as $payment ) {
|
|
|
|
| 136 |
$payment_ids[] = $payment['id'];
|
| 137 |
$order->update_meta_data(
|
| 138 |
'Mercado Pago - Payment ' . $payment['id'],
|
| 139 |
'[Date ' . gmdate( 'Y-m-d H:i:s', strtotime( $payment['date_created'] ) ) .
|
| 140 |
']/[Amount ' . $payment['transaction_amount'] .
|
| 141 |
']/[Paid ' . $payment['total_paid_amount'] .
|
|
|
|
| 142 |
']/[Refund ' . $payment['amount_refunded'] . ']'
|
| 143 |
);
|
| 144 |
}
|
|
@@ -162,6 +168,7 @@ class WC_WooMercadoPago_Notification_IPN extends WC_WooMercadoPago_Notification_
|
|
| 162 |
if ( ! empty( $data['payments'] ) ) {
|
| 163 |
$payment_ids = array();
|
| 164 |
foreach ( $data['payments'] as $payment ) {
|
|
|
|
| 165 |
$payment_ids[] = $payment['id'];
|
| 166 |
update_post_meta(
|
| 167 |
$order->id,
|
|
@@ -169,6 +176,7 @@ class WC_WooMercadoPago_Notification_IPN extends WC_WooMercadoPago_Notification_
|
|
| 169 |
'[Date ' . gmdate( 'Y-m-d H:i:s', strtotime( $payment['date_created'] ) ) .
|
| 170 |
']/[Amount ' . $payment['transaction_amount'] .
|
| 171 |
']/[Paid ' . $payment['total_paid_amount'] .
|
|
|
|
| 172 |
']/[Refund ' . $payment['amount_refunded'] . ']'
|
| 173 |
);
|
| 174 |
}
|
|
@@ -179,4 +187,10 @@ class WC_WooMercadoPago_Notification_IPN extends WC_WooMercadoPago_Notification_
|
|
| 179 |
}
|
| 180 |
return $status;
|
| 181 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 182 |
}
|
| 91 |
public function process_status_mp_business( $data, $order ) {
|
| 92 |
$status = 'pending';
|
| 93 |
$payments = $data['payments'];
|
| 94 |
+
|
| 95 |
+
if ( is_array($payments) ) {
|
| 96 |
+
$total = $data['shipping_cost'] + $data['total_amount'];
|
|
|
|
|
|
|
| 97 |
$total_paid = 0.00;
|
| 98 |
$total_refund = 0.00;
|
|
|
|
| 99 |
// Grab some information...
|
| 100 |
foreach ( $data['payments'] as $payment ) {
|
| 101 |
+
$coupon_mp = $this->get_payment_info($payment['id']);
|
| 102 |
+
|
| 103 |
+
if ( $coupon_mp > 0 ) {
|
| 104 |
+
$total_paid += (float) $coupon_mp;
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
if ( 'approved' === $payment['status'] ) {
|
| 108 |
// Get the total paid amount, considering only approved incomings.
|
| 109 |
$total_paid += (float) $payment['total_paid_amount'];
|
| 112 |
$total_refund += (float) $payment['amount_refunded'];
|
| 113 |
}
|
| 114 |
}
|
| 115 |
+
|
| 116 |
if ( $total_paid >= $total ) {
|
| 117 |
$status = 'approved';
|
| 118 |
} elseif ( $total_refund >= $total ) {
|
| 137 |
if ( ! empty( $data['payments'] ) ) {
|
| 138 |
$payment_ids = array();
|
| 139 |
foreach ( $data['payments'] as $payment ) {
|
| 140 |
+
$coupon_mp = $this->get_payment_info($payment['id']);
|
| 141 |
$payment_ids[] = $payment['id'];
|
| 142 |
$order->update_meta_data(
|
| 143 |
'Mercado Pago - Payment ' . $payment['id'],
|
| 144 |
'[Date ' . gmdate( 'Y-m-d H:i:s', strtotime( $payment['date_created'] ) ) .
|
| 145 |
']/[Amount ' . $payment['transaction_amount'] .
|
| 146 |
']/[Paid ' . $payment['total_paid_amount'] .
|
| 147 |
+
']/[Coupon ' . $coupon_mp .
|
| 148 |
']/[Refund ' . $payment['amount_refunded'] . ']'
|
| 149 |
);
|
| 150 |
}
|
| 168 |
if ( ! empty( $data['payments'] ) ) {
|
| 169 |
$payment_ids = array();
|
| 170 |
foreach ( $data['payments'] as $payment ) {
|
| 171 |
+
$coupon_mp = $this->get_payment_info($payment['id']);
|
| 172 |
$payment_ids[] = $payment['id'];
|
| 173 |
update_post_meta(
|
| 174 |
$order->id,
|
| 176 |
'[Date ' . gmdate( 'Y-m-d H:i:s', strtotime( $payment['date_created'] ) ) .
|
| 177 |
']/[Amount ' . $payment['transaction_amount'] .
|
| 178 |
']/[Paid ' . $payment['total_paid_amount'] .
|
| 179 |
+
']/[Coupon ' . $coupon_mp .
|
| 180 |
']/[Refund ' . $payment['amount_refunded'] . ']'
|
| 181 |
);
|
| 182 |
}
|
| 187 |
}
|
| 188 |
return $status;
|
| 189 |
}
|
| 190 |
+
public function get_payment_info( $id ) {
|
| 191 |
+
$payment_info = $this->mp->search_payment_v1($id);
|
| 192 |
+
$coupon_amount = (float) $payment_info['response']['coupon_amount'];
|
| 193 |
+
|
| 194 |
+
return $coupon_amount;
|
| 195 |
+
}
|
| 196 |
}
|
includes/notification/class-wc-woomercadopago-notification-webhook.php
CHANGED
|
@@ -143,9 +143,10 @@ class WC_WooMercadoPago_Notification_Webhook extends WC_WooMercadoPago_Notificat
|
|
| 143 |
* @return mixed|string
|
| 144 |
*/
|
| 145 |
public function process_status_mp_business( $data, $order ) {
|
| 146 |
-
$status
|
| 147 |
-
$total_paid
|
| 148 |
-
$total_refund
|
|
|
|
| 149 |
// WooCommerce 3.0 or later.
|
| 150 |
if ( method_exists( $order, 'update_meta_data' ) ) {
|
| 151 |
// Updates the type of gateway.
|
|
@@ -164,6 +165,7 @@ class WC_WooMercadoPago_Notification_Webhook extends WC_WooMercadoPago_Notificat
|
|
| 164 |
'[Date ' . gmdate( 'Y-m-d H:i:s', strtotime( $data['date_created'] ) ) .
|
| 165 |
']/[Amount ' . $data['transaction_amount'] .
|
| 166 |
']/[Paid ' . $total_paid .
|
|
|
|
| 167 |
']/[Refund ' . $total_refund . ']'
|
| 168 |
);
|
| 169 |
$order->update_meta_data( '_Mercado_Pago_Payment_IDs', $data['id'] );
|
|
@@ -186,6 +188,7 @@ class WC_WooMercadoPago_Notification_Webhook extends WC_WooMercadoPago_Notificat
|
|
| 186 |
'[Date ' . gmdate( 'Y-m-d H:i:s', strtotime( $data['date_created'] ) ) .
|
| 187 |
']/[Amount ' . $data['transaction_amount'] .
|
| 188 |
']/[Paid ' . $total_paid .
|
|
|
|
| 189 |
']/[Refund ' . $total_refund . ']'
|
| 190 |
);
|
| 191 |
update_post_meta( $order->id, '_Mercado_Pago_Payment_IDs', $data['id'] );
|
| 143 |
* @return mixed|string
|
| 144 |
*/
|
| 145 |
public function process_status_mp_business( $data, $order ) {
|
| 146 |
+
$status = isset( $data['status'] ) ? $data['status'] : 'pending';
|
| 147 |
+
$total_paid = isset( $data['transaction_details']['total_paid_amount'] ) ? $data['transaction_details']['total_paid_amount'] : 0.00;
|
| 148 |
+
$total_refund = isset( $data['transaction_amount_refunded'] ) ? $data['transaction_amount_refunded'] : 0.00;
|
| 149 |
+
$coupon_amount = isset( $data['coupon_amount'] ) ? $data['coupon_amount'] : 0.00;
|
| 150 |
// WooCommerce 3.0 or later.
|
| 151 |
if ( method_exists( $order, 'update_meta_data' ) ) {
|
| 152 |
// Updates the type of gateway.
|
| 165 |
'[Date ' . gmdate( 'Y-m-d H:i:s', strtotime( $data['date_created'] ) ) .
|
| 166 |
']/[Amount ' . $data['transaction_amount'] .
|
| 167 |
']/[Paid ' . $total_paid .
|
| 168 |
+
']/[Coupon ' . $coupon_amount .
|
| 169 |
']/[Refund ' . $total_refund . ']'
|
| 170 |
);
|
| 171 |
$order->update_meta_data( '_Mercado_Pago_Payment_IDs', $data['id'] );
|
| 188 |
'[Date ' . gmdate( 'Y-m-d H:i:s', strtotime( $data['date_created'] ) ) .
|
| 189 |
']/[Amount ' . $data['transaction_amount'] .
|
| 190 |
']/[Paid ' . $total_paid .
|
| 191 |
+
']/[Coupon ' . $coupon_amount .
|
| 192 |
']/[Refund ' . $total_refund . ']'
|
| 193 |
);
|
| 194 |
update_post_meta( $order->id, '_Mercado_Pago_Payment_IDs', $data['id'] );
|
includes/payments/class-wc-woomercadopago-ticket-gateway.php
CHANGED
|
@@ -41,7 +41,7 @@ class WC_WooMercadoPago_Ticket_Gateway extends WC_WooMercadoPago_Payment_Abstrac
|
|
| 41 |
$this->method_description = $this->description;
|
| 42 |
$this->coupon_mode = $this->get_option( 'coupon_mode', 'no' );
|
| 43 |
$this->stock_reduce_mode = $this->get_option( 'stock_reduce_mode', 'no' );
|
| 44 |
-
$this->date_expiration = (int) $this->get_option( 'date_expiration',
|
| 45 |
$this->type_payments = $this->get_option( 'type_payments', 'no' );
|
| 46 |
$this->payment_type = 'ticket';
|
| 47 |
$this->checkout_type = 'custom';
|
|
@@ -247,7 +247,7 @@ class WC_WooMercadoPago_Ticket_Gateway extends WC_WooMercadoPago_Payment_Abstrac
|
|
| 247 |
'title' => __( 'Payment Due', 'woocommerce-mercadopago' ),
|
| 248 |
'type' => 'number',
|
| 249 |
'description' => __( 'In how many days will cash payments expire.', 'woocommerce-mercadopago' ),
|
| 250 |
-
'default' =>
|
| 251 |
);
|
| 252 |
}
|
| 253 |
|
| 41 |
$this->method_description = $this->description;
|
| 42 |
$this->coupon_mode = $this->get_option( 'coupon_mode', 'no' );
|
| 43 |
$this->stock_reduce_mode = $this->get_option( 'stock_reduce_mode', 'no' );
|
| 44 |
+
$this->date_expiration = (int) $this->get_option( 'date_expiration', WC_WooMercadoPago_Constants::DATE_EXPIRATION );
|
| 45 |
$this->type_payments = $this->get_option( 'type_payments', 'no' );
|
| 46 |
$this->payment_type = 'ticket';
|
| 47 |
$this->checkout_type = 'custom';
|
| 247 |
'title' => __( 'Payment Due', 'woocommerce-mercadopago' ),
|
| 248 |
'type' => 'number',
|
| 249 |
'description' => __( 'In how many days will cash payments expire.', 'woocommerce-mercadopago' ),
|
| 250 |
+
'default' => WC_WooMercadoPago_Constants::DATE_EXPIRATION,
|
| 251 |
);
|
| 252 |
}
|
| 253 |
|
readme.txt
CHANGED
|
@@ -4,7 +4,7 @@ Tags: ecommerce, mercadopago, woocommerce
|
|
| 4 |
Requires at least: 4.9.10
|
| 5 |
Tested up to: 5.9
|
| 6 |
Requires PHP: 5.6
|
| 7 |
-
Stable tag: 5.7.
|
| 8 |
License: GPLv2 or later
|
| 9 |
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
| 10 |
|
|
@@ -133,6 +133,12 @@ Set up both the plugin and the checkouts you want to activate on your payment av
|
|
| 133 |
Check out our <a href="https://www.mercadopago.com.br/developers/pt/plugins_sdks/plugins/official/woo-commerce/">official documentation</a> for more information on the specific fields to configure.
|
| 134 |
|
| 135 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 136 |
= v5.7.5 (31/03/2022) =
|
| 137 |
* Bug fixes
|
| 138 |
- Instance a non-static class to call a method (Fatal error on PHP 8)
|
| 4 |
Requires at least: 4.9.10
|
| 5 |
Tested up to: 5.9
|
| 6 |
Requires PHP: 5.6
|
| 7 |
+
Stable tag: 5.7.6
|
| 8 |
License: GPLv2 or later
|
| 9 |
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
| 10 |
|
| 133 |
Check out our <a href="https://www.mercadopago.com.br/developers/pt/plugins_sdks/plugins/official/woo-commerce/">official documentation</a> for more information on the specific fields to configure.
|
| 134 |
|
| 135 |
== Changelog ==
|
| 136 |
+
= v5.7.6 (19/04/2022) =
|
| 137 |
+
* Bug fixes
|
| 138 |
+
- Adjusted IPN notification to recognize discount coupon
|
| 139 |
+
- Added coupon information in order details
|
| 140 |
+
- Changed default value of checkout ticket date_expiration
|
| 141 |
+
|
| 142 |
= v5.7.5 (31/03/2022) =
|
| 143 |
* Bug fixes
|
| 144 |
- Instance a non-static class to call a method (Fatal error on PHP 8)
|
woocommerce-mercadopago.php
CHANGED
|
@@ -3,7 +3,7 @@
|
|
| 3 |
* Plugin Name: Mercado Pago payments for WooCommerce
|
| 4 |
* Plugin URI: https://github.com/mercadopago/cart-woocommerce
|
| 5 |
* Description: Configure the payment options and accept payments with cards, ticket and money of Mercado Pago account.
|
| 6 |
-
* Version: 5.7.
|
| 7 |
* Author: Mercado Pago
|
| 8 |
* Author URI: https://developers.mercadopago.com/
|
| 9 |
* Text Domain: woocommerce-mercadopago
|
| 3 |
* Plugin Name: Mercado Pago payments for WooCommerce
|
| 4 |
* Plugin URI: https://github.com/mercadopago/cart-woocommerce
|
| 5 |
* Description: Configure the payment options and accept payments with cards, ticket and money of Mercado Pago account.
|
| 6 |
+
* Version: 5.7.6
|
| 7 |
* Author: Mercado Pago
|
| 8 |
* Author URI: https://developers.mercadopago.com/
|
| 9 |
* Text Domain: woocommerce-mercadopago
|
