Debian Codegraph @

addons/l10n_id_pos/static/src/app/components/popups/qr_code_popup.js

raw
1 import { QRPopup } from "@point_of_sale/app/components/popups/qr_code_popup/qr_code_popup";
2 import { patch } from "@web/core/utils/patch";
3 import { AlertDialog } from "@web/core/confirmation_dialog/confirmation_dialog";
4 import { useService } from "@web/core/utils/hooks";
5 import { _t } from "@web/core/l10n/translation";
6
7 patch(QRPopup.prototype, {
8 setup() {
9 super.setup(...arguments);
10 this.orm = useService("orm");
11 },
12
13 async _confirm() {
14 // Verify whether the payment has been recieved by QRIS
15
16 this.setButtonsDisabled(true);
17
18 const pm_line = this.props.line;
19 let result;
20
21 try {
22 result = await this.orm.call("pos.payment.method", "l10n_id_verify_qris_status", [
23 [pm_line.payment_method_id.id],
24 pm_line.pos_order_id.uuid,
25 ]);
26 } catch {
27 this.env.services.dialog.add(AlertDialog, {
28 title: _t("Failure"),
29 body: _t("Failure to verify QRIS payment status"),
30 });
31 this.setButtonsDisabled(false);
32 return false;
33 }
34
35 if (!result) {
36 this.env.services.dialog.add(AlertDialog, {
37 title: _t("Payment Status Update"),
38 body: _t("Payment Status returns unpaid"),
39 });
40 this.setButtonsDisabled(false);
41 return false;
42 }
43 this.setButtonsDisabled(false);
44 return super._confirm();
45 },
46 });