[REM] website_sale: stop polling pending transactions from the shop

This commit removes a legacy polling system that was present to query
the server about status change of pending transactions in the shop. This
has not been necessary since that all payment flows go through the
/payment/status page, which already polls the server for pending
transactions' state change.

task-3125913

closes odoo/odoo#119473

Related: odoo/enterprise#47603
Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
This commit is contained in:
Antoine Vandevenne (anv)
2023-09-19 16:37:06 +00:00
parent cf52e381bd
commit 16cbb825a8
3 changed files with 0 additions and 64 deletions
-1
View File
@@ -70,7 +70,6 @@
'website_sale/static/src/js/website_sale_utils.js',
'website_sale/static/src/xml/website_sale_utils.xml',
'website_sale/static/src/js/website_sale_payment.js',
'website_sale/static/src/js/website_sale_validate.js',
'website_sale/static/src/js/website_sale_recently_viewed.js',
'website_sale/static/src/js/website_sale_tracking.js',
'website/static/lib/multirange/multirange_custom.js',
-15
View File
@@ -1642,21 +1642,6 @@ class WebsiteSale(http.Controller):
return request.render("website_sale.payment", render_values)
@http.route('/shop/payment/get_status/<int:sale_order_id>', type='json', auth="public", website=True)
def shop_payment_get_status(self, sale_order_id, **post):
order = request.env['sale.order'].sudo().browse(sale_order_id).exists()
if order.id != request.session.get('sale_last_order_id'):
# either something went wrong or the session is unbound
# prevent recalling every 3rd of a second in the JS widget
return {}
return {
'recall': order.get_portal_last_transaction().state == 'pending',
'message': request.env['ir.ui.view']._render_template("website_sale.payment_confirmation_status", {
'order': order
})
}
@http.route('/shop/payment/validate', type='http', auth="public", website=True, sitemap=False)
def shop_payment_validate(self, sale_order_id=None, **post):
""" Method that should be called by the server when receiving an update
@@ -1,48 +0,0 @@
/** @odoo-module **/
import publicWidget from "@web/legacy/js/public/public_widget";
import { _t } from "@web/core/l10n/translation";
publicWidget.registry.websiteSaleValidate = publicWidget.Widget.extend({
selector: 'div.oe_website_sale_tx_status[data-order-id]',
/**
* @override
*/
start: function () {
var def = this._super.apply(this, arguments);
this._poll_nbr = 0;
this._paymentTransationPollStatus();
return def;
},
//--------------------------------------------------------------------------
// Private
//--------------------------------------------------------------------------
/**
* @private
*/
_paymentTransationPollStatus: function () {
var self = this;
this._rpc({
route: '/shop/payment/get_status/' + parseInt(this.$el.data('order-id')),
}).then(function (result) {
self._poll_nbr += 1;
if (result.recall) {
if (self._poll_nbr < 20) {
setTimeout(function () {
self._paymentTransationPollStatus();
}, Math.ceil(self._poll_nbr / 3) * 1000);
} else {
var $message = $(result.message);
var $warning = $("<i class='fa fa-warning' style='margin-right:10px;'>");
$warning.attr("title", _t("We are waiting for confirmation from the bank or the payment provider"));
$message.find('span:first').prepend($warning);
result.message = $message.html();
}
}
self.$el.html(result.message);
});
},
});