Skip to content

Commit

Permalink
Merge branch 'MOL-672'
Browse files Browse the repository at this point in the history
# Conflicts:
#	mollie-payments-for-woocommerce.php
  • Loading branch information
mmaymo committed Feb 14, 2022
2 parents 65e4ef7 + 5f4a8e2 commit 5913765
Show file tree
Hide file tree
Showing 9 changed files with 2,365 additions and 18 deletions.
2,332 changes: 2,332 additions & 0 deletions languages/mollie-payments-for-woocommerce.pot

Large diffs are not rendered by default.

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.0.0
* Version: 7.0.1
* Author: Mollie
* Author URI: https://www.mollie.com
* Requires at least: 5.0
Expand Down
12 changes: 5 additions & 7 deletions src/Assets/AssetsModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -343,13 +343,6 @@ public function registerBlockScripts(){
filemtime($this->getPluginPath('/public/js/mollieBlockIndex.min.js')),
true
);
wp_register_script(
'mollie_block_cart',
$this->getPluginUrl('/public/js/mollieBlockCart.min.js'),
['underscore', 'jquery'],
filemtime($this->getPluginPath('/public/js/mollieBlockCart.min.js')),
true
);
}

/**
Expand Down Expand Up @@ -458,6 +451,11 @@ protected function gatewayDataForWCBlocks($gatewayInstances): array
$filters = $this->dataService->wooCommerceFiltersForCheckout();
$availableGateways = WC()->payment_gateways()->get_available_payment_gateways();

foreach ($availableGateways as $key => $gateway){
if(strpos($key, 'mollie_wc_gateway_') === false){
unset($availableGateways[$key]);
}
}
if (
isset($filters['amount']['currency'])
&& isset($filters['locale'])
Expand Down
5 changes: 5 additions & 0 deletions src/BlockService/CheckoutBlockService.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ public function availableGateways()
}
if ($filters) {
$availableGateways = WC()->payment_gateways()->get_available_payment_gateways();
foreach ($availableGateways as $key => $gateway){
if(strpos($key, 'mollie_wc_gateway_') === false){
unset($availableGateways[$key]);
}
}
$filterKey = "{$filters['amount']['currency']}-{$filters['locale']}-{$filters['billingCountry']}";
foreach ($availableGateways as $key => $gateway){
$availablePaymentMethods[$filterKey][$key] = $gateway->paymentMethod->getProperty('id');
Expand Down
16 changes: 10 additions & 6 deletions src/Gateway/GatewayModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,15 +211,19 @@ static function () {
$this->molliePayPalButtonHandling($paypalGateway, $notice, $logger, $pluginUrl);
$checkoutBlockHandler = new CheckoutBlockService($container->get('settings.data_helper'));
$checkoutBlockHandler->bootstrapAjaxRequest();
add_action( 'woocommerce_blocks_checkout_update_order_meta', function($order) use($gatewayInstances){
$orderPaymentMethod = $order->get_payment_method();
$title = $orderPaymentMethod? $gatewayInstances[$orderPaymentMethod]->title: '';
add_action( 'woocommerce_rest_checkout_process_payment_with_context', function($paymentContext){
if(strpos($paymentContext->payment_method, 'mollie_wc_gateway_') === false){
return;
}
$title = isset($paymentContext->payment_data['payment_method_title'])?$paymentContext->payment_data['payment_method_title']:false;
if(!$title){
return $order;
return ;
}
$order->update_meta_data('_payment_method_title', $title);
return $order;
$order = $paymentContext->order;
$order->set_payment_method_title( $title );
$order->save();
} );

return true;
}

Expand Down
1 change: 1 addition & 0 deletions src/Gateway/MolliePaymentGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ public function __construct(
$this->method_description = $this->paymentMethod->getProperty(
'settingsDescription'
);
$this->supports = $this->paymentMethod->getProperty('supports');

// Load the settings.
$this->init_form_fields();
Expand Down
5 changes: 3 additions & 2 deletions src/Payment/MollieOrder.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Psr\Log\LogLevel;
use stdClass;
use WC_Order;
use WP_Error;

class MollieOrder extends MollieObject
{
Expand Down Expand Up @@ -564,7 +565,7 @@ public function onWebhookExpired(WC_Order $order, $payment, $paymentMethodTitle)
* @param null $amount
* @param string $reason
*
* @return bool|\WP_Error
* @return bool|WP_Error
*/
public function refund(WC_Order $order, $orderId, $paymentObject, $amount = null, $reason = '')
{
Expand Down Expand Up @@ -614,7 +615,7 @@ public function refund(WC_Order $order, $orderId, $paymentObject, $amount = null
}

$totals = number_format(abs($totals), 2); // WooCommerce - sum of all refund items
$checkAmount = number_format($amount, 2); // WooCommerce - refund amount
$checkAmount = $amount? number_format((float)$amount, 2):0; // WooCommerce - refund amount

if ($checkAmount !== $totals) {
$errorMessage = "The sum of refunds for all order lines is not identical to the refund amount, so this refund will be processed as a payment amount refund, not an order line refund.";
Expand Down
8 changes: 7 additions & 1 deletion src/Payment/PaymentModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,13 @@ public function run(ContainerInterface $container): bool
2
);

$this->handleExpiryDateCancelation();
add_action(
'init',
[$this, 'handleExpiryDateCancelation'],
10,
2
);


add_action(
OrderItemsRefunder::ACTION_AFTER_REFUND_ORDER_ITEMS,
Expand Down
2 changes: 1 addition & 1 deletion src/Shared/SharedModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function services(): array
},
'shared.plugin_version' => static function (): string {
//Get plugin version
return '7.0.0';
return '7.0.1';
},
'shared.plugin_title' => static function (): string {
//Get plugin version
Expand Down

0 comments on commit 5913765

Please sign in to comment.