Skip to content

Fix/mol 978 #759

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

Draft
wants to merge 33 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
043a9db
MOL-974 bail if not our gw in webhook
mmaymo Nov 23, 2022
2410c7c
MOL-965 load test notice on settings update
mmaymo Nov 24, 2022
0bb5660
MOL-505 update paypal billing if missing
mmaymo Dec 6, 2022
034a301
MOL-958 use woo api for orders
mmaymo Dec 7, 2022
8f3d6d0
MOL-958 save order after adding meta
mmaymo Dec 7, 2022
f1f68ef
MOL-958 declare compatible with hpos
mmaymo Dec 7, 2022
0d9860c
MOL-991 check blocks on class Package instead
mmaymo Dec 23, 2022
c2eb07a
MOL-962 add fee description in new paragraph
mmaymo Dec 27, 2022
3a9d2d0
MOL-975 remove non usable settings
mmaymo Dec 27, 2022
a6c6819
MOL-985 remove voucher from pay page
mmaymo Dec 27, 2022
1cb4685
MOL-993 use wc function to restore stock
mmaymo Dec 28, 2022
0601e57
MOL-505 use meta to label as made with button
mmaymo Dec 28, 2022
06cf18b
MOL-978 add retries for api call, remove timeout and ssl
mmaymo Jan 4, 2023
46b66a7
Merge branch 'feature/MOL-958' into release/7.3.5
mmaymo Jan 10, 2023
8dd137b
Merge branch 'fix/MOL-991' into release/7.3.5
mmaymo Jan 10, 2023
cf85420
Merge branch 'fix/MOL-962' into release/7.3.5
mmaymo Jan 10, 2023
47a4d35
Merge branch 'fix/MOL-993' into release/7.3.5
mmaymo Jan 10, 2023
275a26e
MOL-985 refactor conditions update comments
mmaymo Jan 10, 2023
202a507
Merge branch 'fix/MOL-985' into release/7.3.5
mmaymo Jan 10, 2023
ced1b16
7.3.5-beta change version and wc tested
mmaymo Jan 11, 2023
3c08f63
7.3.5-beta update test
mmaymo Jan 11, 2023
c1a637b
Merge branch 'fix/MOL-975' into release/7.3.5
mmaymo Jan 12, 2023
6b61f07
Merge branch 'fix/MOL-974' into release/7.3.5
mmaymo Jan 12, 2023
80b05b8
Merge branch 'fix/MOL-965' into release/7.3.5
mmaymo Jan 12, 2023
2b275ef
MOL-967 update selector for cart total
mmaymo Jan 12, 2023
6bba8af
Merge branch 'fix/MOL-967-PayPal-min-amount' into release/7.3.5
mmaymo Jan 12, 2023
06a06ee
MOL-965 change action of test mode notice
mmaymo Jan 13, 2023
54584ca
Merge branch 'fix/MOL-965' into release/7.3.5
mmaymo Jan 13, 2023
c149cc4
1008 order methods names as in API
mmaymo Jan 16, 2023
4fb6061
1008 instantiate all known methods
mmaymo Jan 16, 2023
4a611c9
1008 fix for ApplePay name
mmaymo Jan 17, 2023
5d37479
7.3.5 update wc tested version
mmaymo Jan 17, 2023
e42869b
Merge branch 'release/7.3.5' into fix/MOL-978
mmaymo Jan 18, 2023
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
15 changes: 1 addition & 14 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 0 additions & 8 deletions .idea/misc.xml

This file was deleted.

23 changes: 23 additions & 0 deletions .idea/php.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions 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.3.4
* Version: 7.3.5-beta
* Author: Mollie
* Author URI: https://www.mollie.com
* Requires at least: 5.0
Expand All @@ -12,7 +12,7 @@
* Domain Path: /languages
* License: GPLv2 or later
* WC requires at least: 3.0
* WC tested up to: 7.0
* WC tested up to: 7.3
* Requires PHP: 7.2
*/
declare(strict_types=1);
Expand Down
2 changes: 1 addition & 1 deletion resources/js/paypalButtonCart.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ import {ajaxCallToOrder} from "./paypalButtonUtils";
const calculateTotal = () => {
let subtotalPath = document.getElementsByClassName('cart-subtotal')[0].getElementsByClassName('woocommerce-Price-amount')[0].childNodes[0]
let workingNode = subtotalPath.cloneNode(true);
let currency = workingNode.lastChild
let currency = workingNode.getElementsByClassName('woocommerce-Price-currencySymbol')[0]
workingNode.removeChild(currency)
let total = parseFloat(extractValue(workingNode));
total += calculateTaxes()
Expand Down
16 changes: 15 additions & 1 deletion src/Activation/ActivationModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

namespace Mollie\WooCommerce\Activation;

use Automattic\WooCommerce\Utilities\FeaturesUtil;
use Inpsyde\Modularity\Module\ExecutableModule;
use Inpsyde\Modularity\Module\ModuleClassNameIdTrait;
use Inpsyde\Modularity\Package;
Expand Down Expand Up @@ -43,7 +44,7 @@ public function run(ContainerInterface $container): bool
'init',
[$this, 'pluginInit']
);

$this->declareCompatibleWithHPOS();
$this->handleTranslations();
$this->mollieWcNoticeApiKeyMissing();
$this->appleValidationFileRewriteRules();
Expand Down Expand Up @@ -209,4 +210,17 @@ public function pluginInit()
$this->markUpdatedOrNew();
$this->initDb();
}

/**
* @return void
*/
protected function declareCompatibleWithHPOS(): void
{
$baseFile = $this->baseFile;
add_action('before_woocommerce_init', static function () use ($baseFile) {
if (class_exists('\Automattic\WooCommerce\Utilities\FeaturesUtil')) {
FeaturesUtil::declare_compatibility('custom_order_tables', $baseFile, true);
}
});
}
}
12 changes: 5 additions & 7 deletions src/Buttons/PayPalButton/PayPalAjaxRequests.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,13 +209,11 @@ protected function PayPalDataObjectHttp(): PayPalDataObjectHttp
*/
protected function updateOrderPostMeta($orderId, $order)
{
update_post_meta($orderId, '_customer_user', get_current_user_id());
update_post_meta(
$orderId,
'_payment_method',
'mollie_wc_gateway_paypal'
);
update_post_meta($orderId, '_payment_method_title', 'PayPal');
$order->update_meta_data('_customer_user', get_current_user_id());
$order->update_meta_data('_payment_method', 'mollie_wc_gateway_paypal');
$order->update_meta_data('_payment_method_title', 'PayPal');
$order->update_meta_data('_mollie_payment_method_button', 'PayPalButton');
//this saves the order
$order->update_status(
'Processing',
'PayPal Button order',
Expand Down
7 changes: 6 additions & 1 deletion src/Gateway/GatewayModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,9 @@ public function instantiatePaymentMethodGateways(ContainerInterface $container):

foreach ($paymentMethods as $paymentMethod) {
$paymentMethodId = $paymentMethod->getIdFromConfig();
if(! in_array($paymentMethodId, $container->get('gateway.paymentMethodsEnabledAtMollie'))) {
continue;
}
$isSepa = $paymentMethod->getProperty('SEPA');
$key = 'mollie_wc_gateway_' . $paymentMethodId;
if ($isSepa) {
Expand Down Expand Up @@ -532,7 +535,7 @@ public function instantiatePaymentMethodGateways(ContainerInterface $container):
protected function instantiatePaymentMethods($container): array
{
$paymentMethods = [];
$paymentMethodsNames = $container->get('gateway.paymentMethodsEnabledAtMollie');
$paymentMethodsNames = SharedDataDictionary::GATEWAY_CLASSNAMES;
$iconFactory = $container->get(IconFactory::class);
assert($iconFactory instanceof IconFactory);
$settingsHelper = $container->get('settings.settings_helper');
Expand All @@ -546,6 +549,8 @@ protected function instantiatePaymentMethods($container): array
$paymentMethodsNames[] = 'directdebit';
}
foreach ($paymentMethodsNames as $paymentMethodName) {
$paymentMethodName = strtolower($paymentMethodName);
$paymentMethodName = str_replace('mollie_wc_gateway_','',$paymentMethodName);
$paymentMethodClassName = 'Mollie\\WooCommerce\\PaymentMethods\\' . ucfirst($paymentMethodName);
$paymentMethod = new $paymentMethodClassName(
$iconFactory,
Expand Down
13 changes: 3 additions & 10 deletions src/Gateway/MolliePaymentGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -921,10 +921,7 @@ public function onOrderReceivedTitle($title, $id = null)

if ($payment->isOpen()) {
// Add a message to log and order explaining a payment with status "open", only if it hasn't been added already
if (
get_post_meta($order_id, '_mollie_open_status_note', true)
!== '1'
) {
if ($order->get_meta('_mollie_open_status_note') !== '1') {
// Get payment method title
$payment_method_title = $this->method_title;

Expand Down Expand Up @@ -952,12 +949,8 @@ public function onOrderReceivedTitle($title, $id = null)
)) : '')
)
);

update_post_meta(
$order_id,
'_mollie_open_status_note',
'1'
);
$order->update_meta_data('_mollie_open_status_note', '1');
$order->save();
}

// Update the title on the Order received page to better communicate that the payment is pending.
Expand Down
2 changes: 1 addition & 1 deletion src/Gateway/Surcharge.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function buildDescriptionWithSurcharge($description, PaymentMethodI $paym

$feeText = $this->feeTextByType($surchargeType, $paymentMethod);
if ($feeText) {
$feeLabel = '<span class="mollie-gateway-fee">' . $feeText . '</span>';
$feeLabel = '<p class="mollie-gateway-fee">' . $feeText . '</p>';
return $description . $feeLabel;
}
return $description;
Expand Down
20 changes: 10 additions & 10 deletions src/Gateway/Voucher/MaybeDisableGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,20 @@ public function maybeDisableMealVoucherGateway(array $gateways)
'wc-api',
FILTER_SANITIZE_STRING
);
// To exclude we are in Checkout or Order Pay page. These are the other options where gateways are required.
$notInCheckoutOrPayPage = $isWcApiRequest
|| !doing_action('woocommerce_payment_gateways')
|| (!wp_doing_ajax() && !is_wc_endpoint_url('order-pay'))
|| is_admin();
$notHasBlocks = !has_block('woocommerce/checkout');
/*
* There are 2 cases where we want to filter the gateway and it's when the checkout
* page render the available payments methods.(classic and block)
* There are 3 cases where we want to filter the gateway and it's when the checkout
* page render the available payments methods, either classic or block
* and when we are in the order-pay page.
*
* For any other case we want to be sure voucher gateway is included.
*/
if (
($isWcApiRequest
|| !doing_action('woocommerce_payment_gateways')
|| !wp_doing_ajax()
|| is_admin())
&& !has_block('woocommerce/checkout')

) {
if ($notInCheckoutOrPayPage && $notHasBlocks) {
return $gateways;
}
$mealVoucherGatewayIndex = false;
Expand Down
18 changes: 8 additions & 10 deletions src/Payment/MollieObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -525,9 +525,8 @@ protected function setOrderPaidAndProcessed(WC_Order $order)
*/
protected function isOrderPaymentStartedByOtherGateway(WC_Order $order)
{
$order_id = $order->get_id();
// Get the current payment method id for the order
$payment_method_id = get_post_meta($order_id, '_payment_method', $single = true);
$payment_method_id = $order->get_meta('_payment_method', true);
// If the current payment method id for the order is not Mollie, return true
return strpos($payment_method_id, 'mollie') === false;
}
Expand Down Expand Up @@ -694,17 +693,12 @@ function_exists('wcs_order_contains_renewal')
}

/**
* @param $orderId
* @param string $gatewayId
* @param WC_Order $order
*/
protected function informNotUpdatingStatus($orderId, $gatewayId, WC_Order $order)
protected function informNotUpdatingStatus($gatewayId, WC_Order $order)
{
$orderPaymentMethodTitle = get_post_meta(
$orderId,
'_payment_method_title',
$single = true
);
$orderPaymentMethodTitle = $order->get_meta('_payment_method_title');

// Add message to log
$this->logger->debug(
Expand Down Expand Up @@ -734,14 +728,18 @@ protected function addPaypalTransactionIdToOrder(
$payment = $this->getActiveMolliePayment($order->get_id());

if ($payment->isPaid() && $payment->details) {
update_post_meta($order->get_id(), '_paypal_transaction_id', $payment->details->paypalReference);
$order->add_meta_data(
'_paypal_transaction_id',
$payment->details->paypalReference
);
$order->add_order_note(sprintf(
/* translators: Placeholder 1: PayPal consumer name, placeholder 2: PayPal email, placeholder 3: PayPal transaction ID */
__("Payment completed by <strong>%1\$s</strong> - %2\$s (PayPal transaction ID: %3\$s)", 'mollie-payments-for-woocommerce'),
$payment->details->consumerName,
$payment->details->consumerAccount,
$payment->details->paypalReference
));
$order->save();
}
}
/**
Expand Down
Loading