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 beta #888

Merged
merged 22 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
ae5b39c
Fix deprecated expression in WcPsrLoggerAdapter
vHeemstra Jul 24, 2023
a6e2f82
Check if we receive a payment before running a manualcapture logic.
inpsyde-maticluznar Feb 6, 2024
e86fee2
Move Payment object check to the capture method
inpsyde-maticluznar Feb 6, 2024
4848646
Merge remote-tracking branch 'origin/task/fix-build-action' into fix/…
inpsyde-maticluznar Feb 6, 2024
8d49e83
Remove typed order in3 method
mmaymo Feb 19, 2024
3b6a982
PIWOO-330 fix typo in variable subscription
mmaymo Feb 21, 2024
58c9de2
Merge pull request #804 from vHeemstra/patch-2
mmaymo Feb 21, 2024
04b0b3b
PIWOO-237 fix render one issuer
mmaymo Feb 22, 2024
656ee8f
PIWOO-382 dont cache empty methods
mmaymo Feb 22, 2024
273f8e4
PIWOO-389 apply filter only on payments
mmaymo Feb 22, 2024
9190f9a
Merge remote-tracking branch 'origin/fix/PIWOO-422' into release/7.5.…
mmaymo Feb 23, 2024
e61d4bc
PIWOO-422 enable capture flag and process as payment
mmaymo Feb 23, 2024
030140d
Merge remote-tracking branch 'origin/fix/PIWOO-428-in3-pay-page' into…
mmaymo Feb 26, 2024
c9d52ea
PIWOO-237 Fix cs we escaped before
mmaymo Feb 26, 2024
f3aa7b1
PIWOO-414 Add bancomat and fix in3, billie
mmaymo Mar 6, 2024
ddd7453
PIWOO-414 Add feature flag for bancomat
mmaymo Mar 7, 2024
cf4a786
PIWOO-414 Check phone is valid
mmaymo Mar 11, 2024
6faa795
PIWOO-414 Add gateway phone when on blocks
mmaymo Mar 11, 2024
ff6cedc
PIWOO-414 add phone only if optional
mmaymo Mar 13, 2024
d0e3405
PIWOO-414 add phone only if optional in blocks
mmaymo Mar 14, 2024
dedfade
PIWOO-441 phone number can be prepopulated in block preview
mmaymo Mar 19, 2024
f6e195a
Merge pull request #889 from mollie/feature/PIWOO-414-bancomat
mmaymo Apr 9, 2024
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
5 changes: 2 additions & 3 deletions src/Gateway/GatewayModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

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 @@ -639,9 +638,9 @@ public function in3FieldsMandatory($fields, $errors)
}

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

Expand Down
2 changes: 1 addition & 1 deletion src/Log/WcPsrLoggerAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public function log($level, $message, array $context = [])
}

if (\WC_Log_Levels::get_level_severity($wcLevel) < \WC_Log_Levels::get_level_severity($this->loggingLevel)) {
throw new InvalidArgumentException("Unknown log level ${$wcLevel}");
throw new InvalidArgumentException("Unknown log level {$wcLevel}");
}

if (isset($context['source']) && $context['source'] !== $this-> loggerSource) {
Expand Down
8 changes: 6 additions & 2 deletions src/MerchantCapture/MerchantCaptureModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,17 @@ public function run(ContainerInterface $container): bool
add_action('init', static function () use ($container) {
$pluginId = $container->get('shared.plugin_id');
$captureSettings = new MollieCaptureSettings();
if (!apply_filters('mollie_wc_gateway_enable_merchant_capture_module', false)) {
if (!apply_filters('mollie_wc_gateway_enable_merchant_capture_module', true)) {
return;
}

add_action(
$pluginId . '_after_webhook_action',
static function (Payment $payment, WC_Order $order) use ($container) {
static function ($payment, WC_Order $order) use ($container) {

if (!$payment instanceof Payment) {
return;
}

if ($payment->isAuthorized()) {
if (!$payment->getAmountCaptured() == 0.0) {
Expand Down
8 changes: 4 additions & 4 deletions src/Payment/MollieObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -588,13 +588,13 @@ protected function addMandateIdMetaToFirstPaymentSubscriptionOrder(
$subscription->update_meta_data('_mollie_payment_id', $payment->id);
$subscription->set_payment_method('mollie_wc_gateway_' . $payment->method);
$subscription->save();
$subcriptionParentOrder = $subscription->get_parent();
if ($subcriptionParentOrder) {
$subcriptionParentOrder->update_meta_data(
$subscriptionParentOrder = $subscription->get_parent();
if ($subscriptionParentOrder) {
$subscriptionParentOrder->update_meta_data(
'_mollie_mandate_id',
$payment->mandateId
);
$subcriptionParentOrder->save();
$subscriptionParentOrder->save();
}
}
}
Expand Down
20 changes: 20 additions & 0 deletions src/Payment/PaymentService.php
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,11 @@ protected function processAsMolliePayment(
$data,
$order
);
$data = apply_filters(
'woocommerce_' . $this->gateway->id . 'payment_args',
$data,
$order
);

try {
// Only enable this for hardcore debugging!
Expand Down Expand Up @@ -524,6 +529,21 @@ protected function processPaymentForMollie(
// PROCESS REGULAR PAYMENT AS MOLLIE ORDER
//
if ($molliePaymentType === self::PAYMENT_METHOD_TYPE_ORDER) {
// if the capture is set to manual, and this is a credit card payment, we need to create a payment instead of an order
$captureType = get_option('mollie-payments-for-woocommerce_place_payment_onhold');
if ($captureType === 'later_capture' && $this->gateway->id === 'mollie_wc_gateway_creditcard') {
$this->logger->debug(
"{$this->gateway->id}: Create payment for order {$orderId} capture set to manual",
[true]
);

$paymentObject = $this->processAsMolliePayment(
$order,
$customer_id,
$apiKey
);
return $paymentObject;
}
$this->logger->debug(
"{$this->gateway->id}: Create Mollie payment object for order {$orderId}",
[true]
Expand Down
2 changes: 1 addition & 1 deletion src/PaymentMethods/Banktransfer.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function getFormFields($generalFormFields): array

public function filtersOnBuild()
{
add_filter('woocommerce_mollie_wc_gateway_' . $this->getProperty('id') . '_args', function (array $args, \WC_Order $order): array {
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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,13 @@ public function execute($gateway, $dataHelper)
if (count($issuers) === 1) {
$issuer = $issuers[0];
$issuerImageSvg = $this->checkSvgIssuers($issuers);
$issuerImageSvg && ($html .= '<img src="' . $issuerImageSvg . '" style="vertical-align:middle" />');
$html .= $issuer->name;
echo esc_html(wpautop(wptexturize($html)));
if ($issuerImageSvg && isset($issuer->name)) {
$issuerImageSvg = esc_url($issuerImageSvg);
$issuerName = esc_html($issuer->name);
$html .= '<img src="' . $issuerImageSvg . '" style="vertical-align:middle" />' . $issuerName;
}
//phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo wpautop(wptexturize($html));

return;
}
Expand Down
6 changes: 3 additions & 3 deletions src/Shared/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,7 @@ public function getAllAvailablePaymentMethods($useCache = true)
delete_transient($transient_id);
}
// No cache exists, call the API and cache the result
if ($methods === false) {
if (empty($methods)) {
if (!$apiKey) {
return [];
}
Expand All @@ -720,8 +720,8 @@ public function getAllAvailablePaymentMethods($useCache = true)
// $methods_cleaned is empty array when the API doesn't return any methods, cache the empty array
$methods = $methods_cleaned;

// Set new transients (as cache)
if ($useCache) {
// Set new transients (as cache) only if we have something in
if ($useCache && !empty($methods)) {
set_transient($transient_id, $methods, HOUR_IN_SECONDS);
}
}
Expand Down
20 changes: 10 additions & 10 deletions src/Subscription/MollieSubscriptionGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,15 +235,15 @@ public function scheduled_subscription_payment($renewal_total, WC_Order $renewal
$subscriptions = wcs_get_subscriptions_for_renewal_order($renewal_order->get_id());
$subscription = array_pop($subscriptions); // Just need one valid subscription
$subscription_mollie_payment_id = $subscription->get_meta('_mollie_payment_id');
$subcriptionParentOrder = $subscription->get_parent();
$mandateId = !empty($subcriptionParentOrder) ? $subcriptionParentOrder->get_meta('_mollie_mandate_id') : null;
$subscriptionParentOrder = $subscription->get_parent();
$mandateId = !empty($subscriptionParentOrder) ? $subscriptionParentOrder->get_meta('_mollie_mandate_id') : null;

if (! empty($subscription_mollie_payment_id) && ! empty($subscription)) {
$customer_id = $this->restore_mollie_customer_id_and_mandate($customer_id, $subscription_mollie_payment_id, $subscription);
}

// Get all data for the renewal payment
$initialPaymentUsedOrderAPI = $this->initialPaymentUsedOrderAPI($subcriptionParentOrder);
$initialPaymentUsedOrderAPI = $this->initialPaymentUsedOrderAPI($subscriptionParentOrder);
$data = $this->subscriptionObject->getRecurringPaymentRequestData($renewal_order, $customer_id, $initialPaymentUsedOrderAPI);

// Allow filtering the renewal payment data
Expand Down Expand Up @@ -301,14 +301,14 @@ public function scheduled_subscription_payment($renewal_total, WC_Order $renewal
(property_exists($payment, 'mandateId')
&& $payment->mandateId !== null)
&& $payment->mandateId !== $mandateId
&& !empty($subcriptionParentOrder)
&& !empty($subscriptionParentOrder)
) {
$this->logger->debug("{$this->id}: updating to mandate {$payment->mandateId}");
$subcriptionParentOrder->update_meta_data(
$subscriptionParentOrder->update_meta_data(
'_mollie_mandate_id',
$payment->mandateId
);
$subcriptionParentOrder->save();
$subscriptionParentOrder->save();
$mandateId = $payment->mandateId;
}
} else {
Expand Down Expand Up @@ -722,15 +722,15 @@ public function is_available(): bool
}

/**
* @param $subcriptionParentOrder
* @param $subscriptionParentOrder
* @return bool
*/
protected function initialPaymentUsedOrderAPI($subcriptionParentOrder): bool
protected function initialPaymentUsedOrderAPI($subscriptionParentOrder): bool
{
if (!$subcriptionParentOrder) {
if (!$subscriptionParentOrder) {
return false;
}
$orderIdMeta = $subcriptionParentOrder->get_meta('_mollie_order_id');
$orderIdMeta = $subscriptionParentOrder->get_meta('_mollie_order_id');

$parentOrderMeta = $orderIdMeta ?: PaymentService::PAYMENT_METHOD_TYPE_PAYMENT;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function __construct($name = null, array $data = [], $dataName = '')
* THEN THE ORDER NOTES ARE CREATED
* @test
*/
public function renewSubcriptionPaymentTest()
public function renewSubscriptionPaymentTest()
{
$gatewayName = 'mollie_wc_gateway_ideal';
$renewalOrder = $this->wcOrder();
Expand Down
Loading