Skip to content

Commit

Permalink
Merge pull request #877 from mollie/release/7.4.2-beta
Browse files Browse the repository at this point in the history
Release/7.5.0
  • Loading branch information
mmaymo authored Jan 29, 2024
2 parents d8e9314 + 8bf8da1 commit 07290a6
Show file tree
Hide file tree
Showing 23 changed files with 427 additions and 190 deletions.
2 changes: 1 addition & 1 deletion mollie-payments-for-woocommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: Mollie Payments for WooCommerce
* Plugin URI: https://www.mollie.com
* Description: Accept payments in WooCommerce with the official Mollie plugin
* Version: 7.4.1
* Version: 7.5.0-beta1
* Author: Mollie
* Author URI: https://www.mollie.com
* Requires at least: 5.0
Expand Down
1 change: 1 addition & 0 deletions public/images/blik.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
44 changes: 44 additions & 0 deletions public/images/twint.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
44 changes: 0 additions & 44 deletions resources/js/mollieIn3.js

This file was deleted.

12 changes: 0 additions & 12 deletions src/Assets/AssetsModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -283,13 +283,6 @@ protected function registerFrontendScripts(string $pluginUrl, string $pluginPath
(string) filemtime($this->getPluginPath($pluginPath, '/public/js/mollieBillie.min.js')),
true
);
wp_register_script(
'mollie-in3-classic-handles',
$this->getPluginUrl($pluginUrl, '/public/js/mollieIn3.min.js'),
['underscore', 'jquery'],
(string) filemtime($this->getPluginPath($pluginPath, '/public/js/mollieIn3.min.js')),
true
);
}

public function registerBlockScripts(string $pluginUrl, string $pluginPath): void
Expand Down Expand Up @@ -322,11 +315,6 @@ public function enqueueFrontendScripts($container)
if ($isBillieEnabled && $isBillieEnabledAtMollie) {
wp_enqueue_script('mollie-billie-classic-handles');
}
$isIn3Enabled = mollieWooCommerceIsGatewayEnabled('mollie_wc_gateway_in3_settings', 'enabled');
$isIn3EnabledAtMollie = in_array('in3', $allMethodsEnabledAtMollie, true);
if ($isIn3Enabled && $isIn3EnabledAtMollie) {
wp_enqueue_script('mollie-in3-classic-handles');
}

$applePayGatewayEnabled = mollieWooCommerceIsGatewayEnabled('mollie_wc_gateway_applepay_settings', 'enabled');
$isAppleEnabledAtMollie = in_array('applepay', $allMethodsEnabledAtMollie, true);
Expand Down
74 changes: 46 additions & 28 deletions src/Gateway/GatewayModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

namespace Mollie\WooCommerce\Gateway;

use Automattic\WooCommerce\Admin\Overrides\Order;
use Automattic\WooCommerce\Internal\DataStores\Orders\CustomOrdersTableController;
use Mollie\WooCommerce\Vendor\Inpsyde\Modularity\Module\ExecutableModule;
use Mollie\WooCommerce\Vendor\Inpsyde\Modularity\Module\ModuleClassNameIdTrait;
Expand Down Expand Up @@ -58,6 +59,9 @@ class GatewayModule implements ServiceModule, ExecutableModule
*/
protected $pluginId;

const FIELD_IN3_BIRTHDATE = 'billing_birthdate';
const GATEWAY_NAME_IN3 = "mollie_wc_gateway_in3";

public function services(): array
{
return [
Expand Down Expand Up @@ -101,7 +105,7 @@ public function services(): array
},
'gateway.getKlarnaPaymentMethodsAfterFeatureFlag' => static function (ContainerInterface $container): array {
$availablePaymentMethods = $container->get('gateway.listAllMethodsAvailable');
$klarnaOneFlag = apply_filters('inpsyde.feature-flags.mollie-woocommerce.klarna_one_enabled', getenv('MOL_KLARNA_ENABLED') === '1');
$klarnaOneFlag = apply_filters('inpsyde.feature-flags.mollie-woocommerce.klarna_one_enabled', true);
if (!$klarnaOneFlag) {
return array_filter($availablePaymentMethods, static function ($method) {
return $method['id'] !== Constants::KLARNA;
Expand Down Expand Up @@ -255,6 +259,11 @@ static function () {
11,
2
);
add_action(
'woocommerce_before_pay_action',
[$this, 'in3FieldsMandatoryPayForOrder'],
11
);
}
// Set order to paid and processed when eventually completed without Mollie
add_action('woocommerce_payment_complete', [$this, 'setOrderPaidByOtherGateway'], 10, 1);
Expand Down Expand Up @@ -614,18 +623,44 @@ public function BillieFieldsMandatory($fields, $errors)
{
$gatewayName = "mollie_wc_gateway_billie";
$field = 'billing_company';
$paymentMethodName = 'Billie';
return $this->addPaymentMethodMandatoryFields($fields, $gatewayName, $field, $errors, $paymentMethodName);
$companyLabel = __('Company', 'mollie-payments-for-woocommerce');
return $this->addPaymentMethodMandatoryFields($fields, $gatewayName, $field, $companyLabel, $errors);
}

public function in3FieldsMandatory($fields, $errors)
{
$gatewayName = "mollie_wc_gateway_in3";
$phoneField = 'billing_phone';
$birthdateField = 'billing_birthdate';
$paymentMethodName = 'in3';
$fields = $this->addPaymentMethodMandatoryFields($fields, $gatewayName, $phoneField, $errors, $paymentMethodName);
return $this->addPaymentMethodMandatoryFields($fields, $gatewayName, $birthdateField, $errors, $paymentMethodName);
$birthdateField = self::FIELD_IN3_BIRTHDATE;
$phoneLabel = __('Phone', 'mollie-payments-for-woocommerce');
$birthDateLabel = __('Birthdate', 'mollie-payments-for-woocommerce');
$fields = $this->addPaymentMethodMandatoryFields($fields, $gatewayName, $phoneField, $phoneLabel, $errors);
return $this->addPaymentMethodMandatoryFields($fields, $gatewayName, $birthdateField, $birthDateLabel, $errors);
}

/**
* @param Order $order
*/
public function in3FieldsMandatoryPayForOrder(Order $order)
{
$paymentMethod = filter_input(INPUT_POST, 'payment_method', FILTER_SANITIZE_SPECIAL_CHARS) ?? false;

if ($paymentMethod !== self::GATEWAY_NAME_IN3) {
return;
}

$birthdateValue = filter_input(INPUT_POST, self::FIELD_IN3_BIRTHDATE, FILTER_SANITIZE_SPECIAL_CHARS) ?? false;
$birthDateLabel = __('Birthdate', 'mollie-payments-for-woocommerce');

if (!$birthdateValue) {
wc_add_notice(
sprintf(
__('%s is a required field.', 'woocommerce'),
"<strong>$birthDateLabel</strong>"
),
'error'
);
}
}

/**
Expand Down Expand Up @@ -664,10 +699,9 @@ public function buildPaymentMethod(
* @param string $gatewayName
* @param string $field
* @param $errors
* @param string $paymentMethodName
* @return mixed
*/
public function addPaymentMethodMandatoryFields($fields, string $gatewayName, string $field, $errors, string $paymentMethodName)
public function addPaymentMethodMandatoryFields($fields, string $gatewayName, string $field, string $fieldLabel, $errors)
{
if ($fields['payment_method'] !== $gatewayName) {
return $fields;
Expand All @@ -680,29 +714,13 @@ public function addPaymentMethodMandatoryFields($fields, string $gatewayName, st
$errors->add(
'validation',
sprintf(
__(
'Error processing %1$s payment, the %2$s field is required.',
'mollie-payments-for-woocommerce'
),
$paymentMethodName,
$field
__('%s is a required field.', 'woocommerce'),
"<strong>$fieldLabel</strong>"
)
);
}
}
if ($fields[$field] === '') {
$errors->add(
'validation',
sprintf(
__(
'Please enter your %1$s, this is required for %2$s payments',
'mollie-payments-for-woocommerce'
),
$field,
$paymentMethodName
)
);
}

return $fields;
}
}
2 changes: 1 addition & 1 deletion src/MerchantCapture/Capture/Action/VoidPayment.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function __invoke()
$this->logger->error($exception->getMessage());
$this->order->add_order_note(
__(
'Payment Void Failed. We encountered an issue while canceling the pre-authorized payment.',
'Payment cancelation failed. We encountered an issue while canceling the pre-authorized payment.',
'mollie-payments-for-woocommerce'
)
);
Expand Down
5 changes: 4 additions & 1 deletion src/MerchantCapture/Capture/Type/ManualCapture.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ public function enableOrderCaptureButton(array $actions, \WC_Order $order): arra

public function sendManualCaptureMode(array $paymentData): array
{
if ($this->container->get('merchant.manual_capture.enabled')) {
if (
$this->container->get('merchant.manual_capture.enabled') &&
$this->container->get('merchant.manual_capture.cart_can_be_captured')
) {
$paymentData['captureMode'] = 'manual';
}
return $paymentData;
Expand Down
9 changes: 9 additions & 0 deletions src/MerchantCapture/Capture/Type/StateChangeCapture.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,16 @@ class StateChangeCapture
public function __construct(ContainerInterface $container)
{
$this->container = $container;
$pluginId = $container->get('shared.plugin_id');

add_action('woocommerce_order_status_changed', [$this, "orderStatusChange"], 10, 3);

/** When the webhook process is activated we don't need automatic status change. Status change is handled
* by the webhook logic.
*/
add_action($pluginId . '_before_webhook_payment_action', function () {
remove_action('woocommerce_order_status_changed', [$this, "orderStatusChange"]);
});
}

public function orderStatusChange(int $orderId, string $oldStatus, string $newStatus)
Expand Down
Loading

0 comments on commit 07290a6

Please sign in to comment.