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 5.2.0-beta.1 10.0.2 5.2.0-rc.1 10.0.3 5.2.0-rc.2 10.0.4 5.2.1 10.0.5 5.2.2 10.0.6 5.2.3 10.1.0 5.2.4 10.1.0-rc.1 5.2.5 10.1.0-rc.2 5.3.0 10.1.0-rc.3 5.3.0-beta.1 10.1.0-rc.4 5.3.0-rc.1 10.1.1 5.3.0-rc.2 10.1.2 5.3.1 10.1.3 5.3.2 10.1.4 5.3.3 10.2.0 5.4.0 10.2.0-beta.1 5.4.0-beta.1 10.2.0-beta.2 5.4.0-rc.1 10.2.0-rc.1 5.4.1 10.2.1 5.4.2 10.2.2 5.4.3 10.2.3 5.4.4 10.2.4 5.4.5 10.3.0 5.5.0 10.3.0-beta.1 5.5.0-beta.1 10.3.0-beta.2 5.5.0-rc.1 10.3.0-rc.1 5.5.0-rc.2 10.3.0-rc.2 5.5.1 10.3.1 5.5.2 10.3.2 5.5.3 10.3.3 5.5.4 10.3.4 5.5.5 10.3.5 5.6.0 10.3.6 5.6.0-beta.1 10.3.7 5.6.0-rc.1 10.3.8 5.6.0-rc.2 10.4.0 5.6.1 10.4.0-beta.1 5.6.2 10.4.0-beta.2 5.6.3 10.4.0-rc.1 5.7.0 10.4.1 5.7.0-beta.1 10.4.2 5.7.0-rc.1 10.4.3 5.7.1 10.4.4 5.7.2 10.5.0 5.7.3 10.5.0-beta.1 5.8.0 10.5.0-beta.2 5.8.0-beta.1 10.5.0-rc.1 5.8.0-beta.2 10.5.0-rc.2 5.8.0-rc.1 10.5.0-rc.3 5.8.1 10.5.1 5.8.2 10.5.2 5.9.0 10.5.3 5.9.0-beta.1 10.6.0 5.9.0-rc.1 10.6.0-beta.1 5.9.0-rc.2 10.6.0-beta.2 5.9.1 10.6.0-rc.1 5.9.2 10.6.1 6.0.0 10.6.2 6.0.0-beta.1 10.7.0 6.0.0-rc.1 10.7.0-beta.1 6.0.1 10.7.0-beta.2 6.0.2 10.7.0-rc.1 6.1.0 3.0.0 6.1.0-beta.1 3.0.1 6.1.0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7.1.0-rc.1 3.7.1 7.1.0-rc.2 3.7.2 7.1.1
woocommerce / src / Internal / Admin / Settings / PaymentsProviders / MercadoPago.php
woocommerce / src / Internal / Admin / Settings / PaymentsProviders Last commit date
WooPayments 5 days ago Affirm.php 1 year ago AfterpayClearpay.php 1 year ago Airwallex.php 1 year ago AmazonPay.php 1 year ago Antom.php 1 year ago Eway.php 11 months ago GoCardless.php 1 year ago Helcim.php 3 weeks ago HelioPay.php 1 year ago Klarna.php 1 year ago Komoju.php 3 weeks ago KustomCheckout.php 1 week ago Mastercard.php 3 weeks ago MercadoPago.php 1 year ago Mollie.php 3 weeks ago Monei.php 1 year ago NexiCheckout.php 11 months ago PayPal.php 1 year ago PayUIndia.php 1 year ago Payfast.php 1 year ago PaymentGateway.php 5 months ago Paymob.php 1 year ago Payoneer.php 1 year ago Paystack.php 1 year ago Paytrail.php 1 year ago PseudoWCPaymentGateway.php 1 year ago Razorpay.php 1 year ago Stripe.php 1 year ago Tilopay.php 1 year ago Visa.php 11 months ago Vivacom.php 1 year ago WCCore.php 9 months ago WooPayments.php 9 months ago
MercadoPago.php
186 lines
1 <?php
2 declare( strict_types=1 );
3
4 namespace Automattic\WooCommerce\Internal\Admin\Settings\PaymentsProviders;
5
6 use Automattic\WooCommerce\Internal\Admin\Settings\Utils;
7 use Automattic\WooCommerce\Internal\Logging\SafeGlobalFunctionProxy;
8 use WC_Payment_Gateway;
9
10 defined( 'ABSPATH' ) || exit;
11
12 /**
13 * MercadoPago payment gateway provider class.
14 *
15 * This class handles all the custom logic for the MercadoPago payment gateway provider.
16 */
17 class MercadoPago extends PaymentGateway {
18
19 /**
20 * Check if the payment gateway needs setup.
21 *
22 * @param WC_Payment_Gateway $payment_gateway The payment gateway object.
23 *
24 * @return bool True if the payment gateway needs setup, false otherwise.
25 */
26 public function needs_setup( WC_Payment_Gateway $payment_gateway ): bool {
27 $is_onboarded = $this->is_mercado_pago_onboarded( $payment_gateway );
28 if ( ! is_null( $is_onboarded ) ) {
29 return ! $is_onboarded;
30 }
31
32 return parent::needs_setup( $payment_gateway );
33 }
34
35 /**
36 * Try to determine if the payment gateway is in test mode.
37 *
38 * This is a best-effort attempt, as there is no standard way to determine this.
39 * Trust the true value, but don't consider a false value as definitive.
40 *
41 * @param WC_Payment_Gateway $payment_gateway The payment gateway object.
42 *
43 * @return bool True if the payment gateway is in test mode, false otherwise.
44 */
45 public function is_in_test_mode( WC_Payment_Gateway $payment_gateway ): bool {
46 return $this->is_mercado_pago_in_sandbox_mode( $payment_gateway ) ?? parent::is_in_test_mode( $payment_gateway );
47 }
48
49 /**
50 * Try to determine if the payment gateway is in dev mode.
51 *
52 * This is a best-effort attempt, as there is no standard way to determine this.
53 * Trust the true value, but don't consider a false value as definitive.
54 *
55 * @param WC_Payment_Gateway $payment_gateway The payment gateway object.
56 *
57 * @return bool True if the payment gateway is in dev mode, false otherwise.
58 */
59 public function is_in_dev_mode( WC_Payment_Gateway $payment_gateway ): bool {
60 return $this->is_mercado_pago_in_sandbox_mode( $payment_gateway ) ?? parent::is_in_dev_mode( $payment_gateway );
61 }
62
63 /**
64 * Check if the payment gateway has a payments processor account connected.
65 *
66 * @param WC_Payment_Gateway $payment_gateway The payment gateway object.
67 *
68 * @return bool True if the payment gateway account is connected, false otherwise.
69 * If the payment gateway does not provide the information, it will return true.
70 */
71 public function is_account_connected( WC_Payment_Gateway $payment_gateway ): bool {
72 return $this->is_mercado_pago_onboarded( $payment_gateway ) ?? parent::is_account_connected( $payment_gateway );
73 }
74
75 /**
76 * Check if the payment gateway has completed the onboarding process.
77 *
78 * @param WC_Payment_Gateway $payment_gateway The payment gateway object.
79 *
80 * @return bool True if the payment gateway has completed the onboarding process, false otherwise.
81 * If the payment gateway does not provide the information,
82 * it will infer it from having a connected account.
83 */
84 public function is_onboarding_completed( WC_Payment_Gateway $payment_gateway ): bool {
85 return $this->is_mercado_pago_onboarded( $payment_gateway ) ?? parent::is_onboarding_completed( $payment_gateway );
86 }
87
88 /**
89 * Try to determine if the payment gateway is in test mode onboarding (aka sandbox or test-drive).
90 *
91 * This is a best-effort attempt, as there is no standard way to determine this.
92 * Trust the true value, but don't consider a false value as definitive.
93 *
94 * @param WC_Payment_Gateway $payment_gateway The payment gateway object.
95 *
96 * @return bool True if the payment gateway is in test mode onboarding, false otherwise.
97 */
98 public function is_in_test_mode_onboarding( WC_Payment_Gateway $payment_gateway ): bool {
99 return $this->is_mercado_pago_in_sandbox_mode( $payment_gateway ) ?? parent::is_in_test_mode_onboarding( $payment_gateway );
100 }
101
102 /**
103 * Check if the MercadoPago payment gateway is in sandbox mode.
104 *
105 * For MercadoPago, there are two different environments: sandbox and production.
106 *
107 * @param WC_Payment_Gateway $payment_gateway The payment gateway object.
108 *
109 * @return ?bool True if the payment gateway is in sandbox mode, false otherwise.
110 * Null if the environment could not be determined.
111 */
112 private function is_mercado_pago_in_sandbox_mode( WC_Payment_Gateway $payment_gateway ): ?bool {
113 global $mercadopago;
114
115 try {
116 // phpcs:disable WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
117 if ( class_exists( '\MercadoPago\Woocommerce\WoocommerceMercadoPago' ) &&
118 class_exists( '\MercadoPago\Woocommerce\Configs\Store' ) &&
119 $mercadopago instanceof \MercadoPago\Woocommerce\WoocommerceMercadoPago &&
120 ! is_null( $mercadopago->storeConfig ) &&
121 $mercadopago->storeConfig instanceof \MercadoPago\Woocommerce\Configs\Store &&
122 is_callable( array( $mercadopago->storeConfig, 'isTestMode' ) )
123 ) {
124 return wc_string_to_bool( $mercadopago->storeConfig->isTestMode() );
125
126 }
127 } catch ( \Throwable $e ) {
128 // Do nothing but log so we can investigate.
129 SafeGlobalFunctionProxy::wc_get_logger()->debug(
130 'Failed to determine if gateway is in sandbox mode: ' . $e->getMessage(),
131 array(
132 'gateway' => $payment_gateway->id,
133 'source' => 'settings-payments',
134 'exception' => $e,
135 )
136 );
137 }
138
139 // Let the caller know that we couldn't determine the environment.
140 return null;
141 }
142
143 /**
144 * Check if the MercadoPago payment gateway is onboarded.
145 *
146 * For MercadoPago, there are two different environments: sandbox/test and production/sale.
147 *
148 * @param WC_Payment_Gateway $payment_gateway The payment gateway object.
149 *
150 * @return ?bool True if the payment gateway is onboarded, false otherwise.
151 * Null if we failed to determine the onboarding status.
152 */
153 private function is_mercado_pago_onboarded( WC_Payment_Gateway $payment_gateway ): ?bool {
154 global $mercadopago;
155
156 try {
157 // phpcs:disable WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
158 if ( class_exists( '\MercadoPago\Woocommerce\WoocommerceMercadoPago' ) &&
159 class_exists( '\MercadoPago\Woocommerce\Configs\Seller' ) &&
160 $mercadopago instanceof \MercadoPago\Woocommerce\WoocommerceMercadoPago &&
161 ! is_null( $mercadopago->sellerConfig ) &&
162 $mercadopago->sellerConfig instanceof \MercadoPago\Woocommerce\Configs\Seller &&
163 is_callable( array( $mercadopago->sellerConfig, 'getCredentialsPublicKey' ) ) &&
164 is_callable( array( $mercadopago->sellerConfig, 'getCredentialsAccessToken' ) )
165 ) {
166 return ! empty( $mercadopago->sellerConfig->getCredentialsPublicKey() ) &&
167 ! empty( $mercadopago->sellerConfig->getCredentialsAccessToken() );
168
169 }
170 } catch ( \Throwable $e ) {
171 // Do nothing but log so we can investigate.
172 SafeGlobalFunctionProxy::wc_get_logger()->debug(
173 'Failed to determine if gateway is onboarded: ' . $e->getMessage(),
174 array(
175 'gateway' => $payment_gateway->id,
176 'source' => 'settings-payments',
177 'exception' => $e,
178 )
179 );
180 }
181
182 // Let the caller know that we couldn't determine the onboarding status.
183 return null;
184 }
185 }
186