If you want you totals to be recalculated after payment method select, then follow these steps
Create requirejs-config.js
in app/code/Vendor/Module/view/frontend/requirejs-config.js
the code will be:
var config = {
map: {
'*': {
'Magento_Checkout/js/action/select-payment-method':
'Vendor_Module/js/action/select-payment-method'
}
}
};
Now create select-payment-method.js
file in app/code/Vendor/Module/view/frontend/web/js/action/select-payment-method.js
the code will be:
define(
[
'Magento_Checkout/js/model/quote',
'Magento_Checkout/js/model/full-screen-loader',
'jquery',
'Magento_Checkout/js/action/get-totals'
],
function (quote, fullScreenLoader, jQuery, getTotalsAction) {
'use strict';
return function (paymentMethod) {
quote.paymentMethod(paymentMethod);
fullScreenLoader.startLoader();
getTotalsAction([]);
fullScreenLoader.stopLoader();
jQuery.ajax('/frontname/index', {
data: {payment_method: paymentMethod},
complete: function () {
getTotalsAction([]);
fullScreenLoader.stopLoader();
}
});
}
}
);
Now in your controller execute function add payment method to quote
public function execute()
{
$pMethod = $this->getRequest()->getParam('payment_method');
$quote = $this->cart->getQuote();
$quote->getPayment()->setMethod($pMethod['method']);
$quote->setTotalsCollectedFlag(false);
$quote->collectTotals();
$quote->save();
}
Hope this will help you