Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release/7.5.2 beta2 #896

Merged
merged 9 commits into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions mollie-payments-for-woocommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
* Plugin Name: Mollie Payments for WooCommerce
* Plugin URI: https://www.mollie.com
* Description: Accept payments in WooCommerce with the official Mollie plugin
* Version: 7.5.2-beta
* Version: 7.5.2
* Author: Mollie
* Author URI: https://www.mollie.com
* Requires at least: 5.0
* Tested up to: 6.4
* Tested up to: 6.5
* Text Domain: mollie-payments-for-woocommerce
* Domain Path: /languages
* License: GPLv2 or later
* WC requires at least: 3.9
* WC tested up to: 8.5
* WC tested up to: 8.7
* Requires PHP: 7.2
*/
declare(strict_types=1);
Expand Down
40 changes: 0 additions & 40 deletions resources/js/blocks/molliePaymentMethod.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,36 +191,6 @@ const MollieComponent = (props) => {

}, [activePaymentMethod, onCheckoutValidation, billing.billingData, shippingData.shippingAddress, item, phoneString, inputBirthdate, inputPhone]);

useEffect(() => {
let phoneLabel = getPhoneField()?.labels?.[0] ?? null;
if (!phoneLabel || phoneLabel.length === 0) {
return
}
if (activePaymentMethod === 'mollie_wc_gateway_bancomatpay') {
phoneLabel.innerText = item.phonePlaceholder
} else {
if (phoneString !== false) {
phoneLabel.innerText = phoneString
}
}
let isPhoneEmpty = (billing.billingData.phone === '' && shippingData.shippingAddress.phone === '') && inputPhone === '';
const unsubscribeProcessing = onCheckoutValidation(

() => {
if (activePaymentMethod === 'mollie_wc_gateway_bancomatpay' && isPhoneEmpty) {
return {
errorMessage: item.errorMessage,
};
}
}
);
return () => {
unsubscribeProcessing()
};

}, [activePaymentMethod, onCheckoutValidation, billing.billingData, shippingData.shippingAddress, item, phoneString, inputPhone]);


onSubmitLocal = onSubmit
const updateIssuer = ( changeEvent ) => {
selectIssuer( changeEvent.target.value )
Expand Down Expand Up @@ -269,16 +239,6 @@ const MollieComponent = (props) => {
return <>{fields}</>;
}

if (item.name === "mollie_wc_gateway_bancomatpay"){
let fields = [];
if (!isPhoneFieldVisible) {
const phoneField = item.phonePlaceholder ? item.phonePlaceholder : "Phone";
fields.push(fieldMarkup("billing-phone-bancomatpay", "tel", phoneField, updatePhone, inputPhone));
}

return <>{fields}</>;
}

return <div><p></p></div>
}

Expand Down
68 changes: 3 additions & 65 deletions src/Gateway/GatewayModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public function services(): array
return $method['id'] !== Constants::KLARNA;
});
}
$bancomatpayFlag = apply_filters('inpsyde.feature-flags.mollie-woocommerce.bancomatpay_enabled', false);
$bancomatpayFlag = apply_filters('inpsyde.feature-flags.mollie-woocommerce.bancomatpay_enabled', true);
if (!$bancomatpayFlag) {
return array_filter($availablePaymentMethods, static function ($method) {
return $method['id'] !== Constants::BANCOMATPAY;
Expand Down Expand Up @@ -277,26 +277,7 @@ static function () {
);
add_action('woocommerce_rest_checkout_process_payment_with_context', [$this, 'addPhoneWhenRest'], 11);
}
$isBancomatPayEnabled = mollieWooCommerceIsGatewayEnabled('mollie_wc_gateway_bancomatpay_settings', 'enabled');
if ($isBancomatPayEnabled) {
add_filter(
'woocommerce_after_checkout_validation',
[$this, 'bancomatpayFieldsMandatory'],
11,
2
);
add_action(
'woocommerce_before_pay_action',
[$this, 'bancomatpayFieldsMandatoryPayForOrder'],
11
);
add_action(
'woocommerce_checkout_posted_data',
[$this, 'switchFields'],
11
);
add_action('woocommerce_rest_checkout_process_payment_with_context', [$this, 'addPhoneWhenRest'], 11);
}

// Set order to paid and processed when eventually completed without Mollie
add_action('woocommerce_payment_complete', [$this, 'setOrderPaidByOtherGateway'], 10, 1);
$appleGateway = isset($container->get('gateway.instances')['mollie_wc_gateway_applepay']) ? $container->get(
Expand Down Expand Up @@ -681,15 +662,6 @@ public function in3FieldsMandatory($fields, $errors)
return $this->addPaymentMethodMandatoryFields($fields, $gatewayName, $birthdateField, $birthDateLabel, $errors);
}

public function bancomatpayFieldsMandatory($fields, $errors)
{
$gatewayName = "mollie_wc_gateway_bancomatpay";
$phoneField = 'billing_phone_bancomatpay';
$phoneLabel = __('Phone', 'mollie-payments-for-woocommerce');
return $this->addPaymentMethodMandatoryFieldsPhoneVerification($fields, $gatewayName, $phoneField, $phoneLabel, $errors);
}


/**
* @param $order
*/
Expand Down Expand Up @@ -730,34 +702,6 @@ public function in3FieldsMandatoryPayForOrder($order)
}
}

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

if ($paymentMethod !== 'mollie_wc_gateway_bancomatpay') {
return;
}

$phoneValue = filter_input(INPUT_POST, 'billing_phone_bancomatpay', FILTER_SANITIZE_SPECIAL_CHARS) ?? false;
$phoneValue = $phoneValue && $this->isPhoneValid($phoneValue) ? $phoneValue : false;
$phoneLabel = __('Phone', 'mollie-payments-for-woocommerce');

if (!$phoneValue) {
wc_add_notice(
sprintf(
__('%s is a required field. Valid phone format +00000000000', 'mollie-payments-for-woocommerce'),
"<strong>$phoneLabel</strong>"
),
'error'
);
} else {
$order->set_billing_phone($phoneValue);
}
}

/**
* @param string $id
* @param IconFactory $iconFactory
Expand Down Expand Up @@ -867,12 +811,6 @@ public function switchFields($data)
$data['billing_phone'] = !empty($fieldPosted) ? $fieldPosted : $data['billing_phone'];
}
}
if (isset($data['payment_method']) && $data['payment_method'] === 'mollie_wc_gateway_bancomatpay') {
$fieldPosted = filter_input(INPUT_POST, 'billing_phone_bancomatpay', FILTER_SANITIZE_SPECIAL_CHARS) ?? false;
if ($fieldPosted) {
$data['billing_phone'] = !empty($fieldPosted) ? $fieldPosted : $data['billing_phone'];
}
}
if (isset($data['payment_method']) && $data['payment_method'] === 'mollie_wc_gateway_billie') {
$fieldPosted = filter_input(INPUT_POST, 'billing_company_billie', FILTER_SANITIZE_SPECIAL_CHARS) ?? false;
if ($fieldPosted) {
Expand All @@ -890,7 +828,7 @@ private function isPhoneValid($billing_phone)
public function addPhoneWhenRest($arrayContext)
{
$context = $arrayContext;
$phoneMandatoryGateways = ['mollie_wc_gateway_in3', 'mollie_wc_gateway_bancomatpay'];
$phoneMandatoryGateways = ['mollie_wc_gateway_in3'];
$paymentMethod = $context->payment_data['payment_method'];
if (in_array($paymentMethod, $phoneMandatoryGateways)) {
$billingPhone = $context->order->get_billing_phone();
Expand Down
6 changes: 3 additions & 3 deletions src/PaymentMethods/AbstractPaymentMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,9 +297,9 @@ public function defaultSettings(): array
{
$fields = $this->getAllFormFields();
//remove setting title fields
$fields = array_filter($fields, static function ($key) {
return !is_numeric($key);
}, ARRAY_FILTER_USE_KEY);
$fields = array_filter($fields, static function ($field) {
return isset($field['type']) && $field['type'] !== 'title';
});
//we don't save the default description or title, in case the language changes
unset($fields['description']);
unset($fields['title']);
Expand Down
29 changes: 2 additions & 27 deletions src/PaymentMethods/Bancomatpay.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,44 +13,19 @@ public function getConfig(): array
'defaultTitle' => __('Bancomat Pay', 'mollie-payments-for-woocommerce'),
'settingsDescription' => '',
'defaultDescription' => '',
'paymentFields' => true,
'paymentFields' => false,
'instructions' => false,
'supports' => [
'products',
'refunds',
],
'filtersOnBuild' => true,
'filtersOnBuild' => false,
'confirmationDelayed' => false,
'errorMessage' => __(
'Required field is empty. Phone field is required.',
'mollie-payments-for-woocommerce'
),
'phonePlaceholder' => __('Please enter your phone here. +00..', 'mollie-payments-for-woocommerce'),
];
}

public function getFormFields($generalFormFields): array
{
return $generalFormFields;
}

public function filtersOnBuild()
{
add_filter('woocommerce_mollie_wc_gateway_' . $this->getProperty('id') . 'payment_args', function (array $args, \WC_Order $order): array {
return $this->addPaymentArguments($args, $order);
}, 10, 2);
}
/**
* @param WC_Order $order
* @return array
*/
public function addPaymentArguments(array $args, $order)
{
$phone = $order->get_billing_phone();
if (!empty($phone)) {
$args['billingAddress']['phone'] = $phone;
}

return $args;
}
}
9 changes: 8 additions & 1 deletion src/PaymentMethods/Giftcard.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ protected function getConfig(): array

public function getFormFields($generalFormFields): array
{
$searchKey = 'advanced';
$keys = array_keys($generalFormFields);
$index = array_search($searchKey, $keys);
$before = array_slice($generalFormFields, 0, $index + 1, true);
$after = array_slice($generalFormFields, $index + 1, null, true);
$paymentMethodFormFields = [
'issuers_dropdown_shown' => [
'title' => __(
Expand Down Expand Up @@ -105,6 +110,8 @@ public function getFormFields($generalFormFields): array
'default' => __('Select your gift card', 'mollie-payments-for-woocommerce'),
],
];
return array_merge($generalFormFields, $paymentMethodFormFields);
$before = array_merge($before, $paymentMethodFormFields);
$formFields = array_merge($before, $after);
return $formFields;
}
}
9 changes: 8 additions & 1 deletion src/PaymentMethods/Ideal.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ public function getConfig(): array

public function getFormFields($generalFormFields): array
{
$searchKey = 'advanced';
$keys = array_keys($generalFormFields);
$index = array_search($searchKey, $keys);
$before = array_slice($generalFormFields, 0, $index + 1, true);
$after = array_slice($generalFormFields, $index + 1, null, true);
$paymentMethodFormFieds = [
'issuers_dropdown_shown' => [
'title' => __('Show iDEAL banks dropdown', 'mollie-payments-for-woocommerce'),
Expand All @@ -55,6 +60,8 @@ public function getFormFields($generalFormFields): array
'default' => __('Select your bank', 'mollie-payments-for-woocommerce'),
],
];
return array_merge($generalFormFields, $paymentMethodFormFieds);
$before = array_merge($before, $paymentMethodFormFieds);
$formFields = array_merge($before, $after);
return $formFields;
}
}
9 changes: 8 additions & 1 deletion src/PaymentMethods/Kbc.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ protected function getConfig(): array

public function getFormFields($generalFormFields): array
{
$searchKey = 'advanced';
$keys = array_keys($generalFormFields);
$index = array_search($searchKey, $keys);
$before = array_slice($generalFormFields, 0, $index + 1, true);
$after = array_slice($generalFormFields, $index + 1, null, true);
$paymentMethodFormFieds = [
'issuers_dropdown_shown' => [
'title' => __(
Expand Down Expand Up @@ -60,6 +65,8 @@ public function getFormFields($generalFormFields): array
'default' => __('Select your bank', 'mollie-payments-for-woocommerce'),
],
];
return array_merge($generalFormFields, $paymentMethodFormFieds);
$before = array_merge($before, $paymentMethodFormFieds);
$formFields = array_merge($before, $after);
return $formFields;
}
}
Loading
Loading