Skip to content

Commit

Permalink
Merge pull request mollie#923 from mollie/release/7.6.0
Browse files Browse the repository at this point in the history
Release/7.6.0
  • Loading branch information
mmaymo authored Jul 10, 2024
2 parents f6d4fea + 9f79a2d commit 149c74d
Show file tree
Hide file tree
Showing 10 changed files with 103 additions and 16 deletions.
6 changes: 1 addition & 5 deletions inc/utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,7 @@ function mollieWooCommerceFormatCurrencyValue($value, $currency)
if (in_array($currency, $currenciesWithNoDecimals)) {
return number_format($value, 0, '.', '');
}
// trying to avoid floating point issues
$value = $value * 1000;
$value = (int) $value / 1000; //drop the last decimal after the third
$value = round($value, 3);
$value = round($value, 2, PHP_ROUND_HALF_DOWN); //round down, as seems woo like it :)

return number_format($value, 2, '.', '');
}

Expand Down
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.5.5
* Version: 7.6.0
* 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.9
* WC tested up to: 8.9
* WC tested up to: 9.0
* Requires PHP: 7.2
* Requires Plugins: woocommerce
*/
Expand Down
1 change: 1 addition & 0 deletions public/images/trustly.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions src/MerchantCapture/Capture/Action/CapturePayment.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ class CapturePayment extends AbstractPaymentCaptureAction
public function __invoke()
{
try {
$payment = $this->order->get_payment_method();
if (strpos($payment, 'mollie') === false) {
return;
}

$paymentId = $this->order->get_meta('_mollie_payment_id');

if (!$paymentId) {
Expand Down
4 changes: 2 additions & 2 deletions src/Payment/MollieObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ protected function setOrderPaidAndProcessed(WC_Order $order)
protected function isOrderPaymentStartedByOtherGateway(WC_Order $order)
{
// Get the current payment method id for the order
$payment_method_id = $order->get_meta('_payment_method', true);
$payment_method_id = $order->get_payment_method();
// 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 @@ -1079,7 +1079,7 @@ protected function getFormatedPhoneNumber(string $phone)
$phone = transformPhoneToNLFormat($phone);

//check that $phone is in E164 format or can be changed by api
if (preg_match('/^\+[1-9]\d{10,13}$|^[1-9]\d{9,13}$/', $phone)) {
if (is_string($phone) && preg_match('/^\+[1-9]\d{10,13}$|^[1-9]\d{9,13}$/', $phone)) {
return $phone;
}
return null;
Expand Down
36 changes: 36 additions & 0 deletions src/Payment/OrderLines.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,48 @@ public function order_lines($order, $voucherDefaultCategory)
$this->process_shipping();
$this->process_fees();
$this->process_gift_cards();
$this->process_missmatch();

return [
'lines' => $this->get_order_lines(),
];
}

private function process_missmatch()
{
$orderTotal = (float) $this->order->get_total();
$orderTotalRounded = round($orderTotal, 2);
$linesTotal = array_sum(array_map(function ($line) {
return $line['totalAmount']['value'];
}, $this->order_lines));
$orderTotalDiff = $orderTotalRounded - $linesTotal;
if (abs($orderTotalDiff) > 0) {
$missmatch = [
'type' => 'surcharge',
'name' => __('Rounding difference', 'mollie-payments-for-woocommerce'),
'quantity' => 1,
'vatRate' => 0,
'unitPrice' => [
'currency' => $this->currency,
'value' => $this->dataHelper->formatCurrencyValue($orderTotalDiff, $this->currency),
],
'totalAmount' => [
'currency' => $this->currency,
'value' => $this->dataHelper->formatCurrencyValue($orderTotalDiff, $this->currency),
],
'vatAmount' => [
'currency' => $this->currency,
'value' => $this->dataHelper->formatCurrencyValue(0, $this->currency),
],
'metadata' => [
'order_item_id' => 'rounding_diff',
],
];

$this->order_lines[] = $missmatch;
}
}

/**
* Get order lines formatted for Mollie Orders API.
*
Expand Down
20 changes: 19 additions & 1 deletion src/PaymentMethods/Giropay.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,24 @@ protected function getConfig(): array

public function getFormFields($generalFormFields): array
{
return $generalFormFields;
$notice = [
'notice' => [
'title' =>
sprintf(
__(
'%1$s Paydirekt, the owner of Giropay, has decided to deprecate Giropay. On Monday, 24 June 2024, Mollie was informed that Giropay would cease onboarding new merchants and processing new payments after 30 June 2024. No action is needed from your side. Mollie will automatically remove Giropay as a payment option from your Checkout by 30 June.
Subscription renewals and refunds will continue to be processed as usual beyond June 30. More details can be found in the %2$s Giropay Deprecation FAQ. %3$s',
'mollie-payments-for-woocommerce'
),
'<p>',
'<a href="https://help.mollie.com/hc/en-us/articles/19745480480786-Giropay-Depreciation-FAQ" target="_blank">',
'</a></p>'
),
'type' => 'title',
'class' => 'notice notice-warning',
'css' => 'padding:20px;',
],
];
return array_merge($notice, $generalFormFields);
}
}
32 changes: 32 additions & 0 deletions src/PaymentMethods/Trustly.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

declare(strict_types=1);

namespace Mollie\WooCommerce\PaymentMethods;

class Trustly extends AbstractPaymentMethod implements PaymentMethodI
{
protected function getConfig(): array
{
return [
'id' => 'trustly',
'defaultTitle' => __('Trustly', 'mollie-payments-for-woocommerce'),
'settingsDescription' => '',
'defaultDescription' => '',
'paymentFields' => false,
'instructions' => true,
'supports' => [
'products',
'refunds',
],
'filtersOnBuild' => false,
'confirmationDelayed' => true,
'SEPA' => false,
];
}

public function getFormFields($generalFormFields): array
{
return $generalFormFields;
}
}
1 change: 1 addition & 0 deletions src/Shared/SharedDataDictionary.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class SharedDataDictionary
'Mollie_WC_Gateway_Twint',
'Mollie_WC_Gateway_Bancomatpay',
'Mollie_WC_Gateway_Alma',
'Mollie_WC_Gateway_Trustly',
];

public const MOLLIE_OPTIONS_NAMES = [
Expand Down
10 changes: 4 additions & 6 deletions tests/php/Functional/Payment/PaymentServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,7 @@ public function processPayment_Order_success(){
'wc_clean' => null,
]
);
$gateway->expects($this->once())
->method('getSelectedIssuer')
->willReturn('ideal_INGBNL2A');

$expectedRequestToMollie = $this->expectedRequestData($wcOrder);
$orderEndpoints->method('create')->with($expectedRequestToMollie);

Expand Down Expand Up @@ -212,7 +210,7 @@ private function wcOrder($id, $orderKey)
[
'get_id' => $id,
'get_order_key' => $orderKey,
'get_total' => '20',
'get_total' => 40.00,
'get_items' => [$this->wcOrderItem()],
'get_billing_first_name' => 'billingggivenName',
'get_billing_last_name' => 'billingfamilyName',
Expand Down Expand Up @@ -307,7 +305,7 @@ private function expectedRequestData($order){
return [
'amount' => [
'currency' => 'EUR',
'value' => '20.00'
'value' => '40.00'
],
'redirectUrl' =>
'https://webshop.example.org/wc-api/mollie_return?order_id=1&key=wc_order_hxZniP1zDcnM8',
Expand All @@ -317,7 +315,7 @@ private function expectedRequestData($order){
'ideal',
'payment' =>
[
'issuer' => 'ideal_INGBNL2A'
'issuer' => null
],
'locale' => 'en_US',
'billingAddress' => $this->billingAddress($order),
Expand Down

0 comments on commit 149c74d

Please sign in to comment.