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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 / Mollie.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 2 weeks ago HelioPay.php 1 year ago Klarna.php 1 year ago Komoju.php 2 weeks ago KustomCheckout.php 1 week ago Mastercard.php 2 weeks ago MercadoPago.php 1 year ago Mollie.php 2 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
Mollie.php
194 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\Payments;
7 use Automattic\WooCommerce\Internal\Logging\SafeGlobalFunctionProxy;
8 use Throwable;
9 use WC_Payment_Gateway;
10
11 defined( 'ABSPATH' ) || exit;
12
13 /**
14 * Mollie payment gateway provider class.
15 *
16 * This class handles all the custom logic for the Mollie payment gateway provider.
17 */
18 class Mollie extends PaymentGateway {
19
20 /**
21 * Get the settings URL for a payment gateway.
22 *
23 * @param WC_Payment_Gateway $payment_gateway The payment gateway object.
24 *
25 * @return string The settings URL for the payment gateway.
26 */
27 public function get_settings_url( WC_Payment_Gateway $payment_gateway ): string {
28 // Don't target any section because there are none to target when Mollie is not connected.
29 if ( 'mollie_stand_in' === $payment_gateway->id ) {
30 return $this->get_custom_settings_url();
31 }
32
33 // Target the payment methods section when the gateway is connected.
34 return $this->get_custom_settings_url( 'mollie_payment_methods' );
35 }
36
37 /**
38 * Check if the payment gateway has a payments processor account connected.
39 *
40 * @param WC_Payment_Gateway $payment_gateway The payment gateway object.
41 *
42 * @return bool True if the payment gateway account is connected, false otherwise.
43 * If the payment gateway does not provide the information, it will return true.
44 */
45 public function is_account_connected( WC_Payment_Gateway $payment_gateway ): bool {
46 try {
47 $sandbox_mode = $this->is_mollie_in_sandbox_mode( $payment_gateway );
48 // Let null results bubble up to the parent class.
49 if ( true === $sandbox_mode ) {
50 // If Mollie is in sandbox mode, we consider the account connected if the test API key is set.
51 return ! empty( get_option( 'mollie-payments-for-woocommerce_test_api_key', '' ) );
52 } elseif ( false === $sandbox_mode ) {
53 // In production mode, we check the live API key.
54 return ! empty( get_option( 'mollie-payments-for-woocommerce_live_api_key', '' ) );
55 }
56 } catch ( Throwable $e ) {
57 // Do nothing but log so we can investigate.
58 SafeGlobalFunctionProxy::wc_get_logger()->debug(
59 'Failed to determine if gateway has an account connected: ' . $e->getMessage(),
60 array(
61 'gateway' => $payment_gateway->id,
62 'source' => 'settings-payments',
63 'exception' => $e,
64 )
65 );
66 }
67
68 return parent::is_account_connected( $payment_gateway );
69 }
70
71 /**
72 * Determine if the payment gateway is in test mode.
73 *
74 * @param WC_Payment_Gateway $payment_gateway The payment gateway object.
75 *
76 * @return bool True if the payment gateway is in test mode, false otherwise.
77 */
78 public function is_in_test_mode( WC_Payment_Gateway $payment_gateway ): bool {
79 return $this->is_mollie_in_sandbox_mode( $payment_gateway ) ?? parent::is_in_test_mode( $payment_gateway );
80 }
81
82 /**
83 * Try to determine if the payment gateway is in test mode onboarding (aka sandbox or test-drive).
84 *
85 * This is a best-effort attempt, as there is no standard way to determine this.
86 * Trust the true value, but don't consider a false value as definitive.
87 *
88 * @param WC_Payment_Gateway $payment_gateway The payment gateway object.
89 *
90 * @return bool True if the payment gateway is in test mode onboarding, false otherwise.
91 */
92 public function is_in_test_mode_onboarding( WC_Payment_Gateway $payment_gateway ): bool {
93 return $this->is_mollie_in_sandbox_mode( $payment_gateway ) ?? parent::is_in_test_mode_onboarding( $payment_gateway );
94 }
95
96 /**
97 * Determine if at least a Mollie gateway is registered.
98 *
99 * @param array $payment_gateways The payment gateways objects.
100 *
101 * @return bool True if at least a Mollie gateway is registered, false otherwise.
102 */
103 public function is_gateway_registered( array $payment_gateways ): bool {
104 $mollie_gateways = array_filter(
105 $payment_gateways,
106 function ( $gateway ) {
107 return str_starts_with( $gateway->id, 'mollie_wc_gateway_' );
108 }
109 );
110
111 return ! empty( $mollie_gateways );
112 }
113
114 /**
115 * Get the pseudo Mollie gateway object.
116 *
117 * @param array $suggestion The suggestion data.
118 *
119 * @return PseudoWCPaymentGateway The pseudo gateway object.
120 */
121 public function get_pseudo_gateway( array $suggestion ): PseudoWCPaymentGateway {
122 // We will generate a generic gateway to represent Mollie in the settings page.
123 // The generic gateway's state will be not enabled, not connected, and not onboarded.
124 // The presentational details will be minimal, letting the suggestion provide most of the information.
125 return new PseudoWCPaymentGateway(
126 'mollie_stand_in',
127 array(
128 'method_title' => $suggestion['title'],
129 'method_description' => $suggestion['description'],
130 'enabled' => false,
131 'needs_setup' => true,
132 'test_mode' => false,
133 'dev_mode' => false,
134 'account_connected' => false,
135 'onboarding_started' => false,
136 'onboarding_completed' => false,
137 'settings_url' => $this->get_custom_settings_url(),
138 'plugin_slug' => $suggestion['plugin']['slug'],
139 'plugin_file' => $suggestion['plugin']['file'],
140 ),
141 );
142 }
143
144 /**
145 * Get the URL to the custom settings page for Mollie.
146 *
147 * @param string $section Optional. The section to navigate to.
148 *
149 * @return string The URL to the custom settings page for Mollie.
150 */
151 private function get_custom_settings_url( string $section = '' ): string {
152 $settings_url = admin_url( 'admin.php?page=wc-settings&tab=mollie_settings' );
153
154 if ( ! empty( $section ) ) {
155 $settings_url = add_query_arg( 'section', $section, $settings_url );
156 }
157
158 return add_query_arg(
159 array(
160 'from' => Payments::FROM_PAYMENTS_SETTINGS,
161 ),
162 $settings_url
163 );
164 }
165
166 /**
167 * Check if the Mollie payment gateway is in sandbox mode.
168 *
169 * @param WC_Payment_Gateway $payment_gateway The payment gateway object.
170 *
171 * @return ?bool True if the payment gateway is in sandbox mode, false otherwise.
172 * Null if the environment could not be determined.
173 */
174 private function is_mollie_in_sandbox_mode( WC_Payment_Gateway $payment_gateway ): ?bool {
175 try {
176 // Unfortunately, Mollie does not provide a standard way to determine if the gateway is in sandbox mode.
177 return filter_var( get_option( 'mollie-payments-for-woocommerce_test_mode_enabled', 'yes' ), FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE );
178 } catch ( \Throwable $e ) {
179 // Do nothing but log so we can investigate.
180 SafeGlobalFunctionProxy::wc_get_logger()->debug(
181 'Failed to determine if gateway is in sandbox mode: ' . $e->getMessage(),
182 array(
183 'gateway' => $payment_gateway->id,
184 'source' => 'settings-payments',
185 'exception' => $e,
186 )
187 );
188 }
189
190 // Let the caller know that we couldn't determine the environment.
191 return null;
192 }
193 }
194