Debian Codegraph @

addons/pos_restaurant_stripe/static/src/overrides/models/payment_stripe.js

raw
1 import { PaymentStripe } from "@pos_stripe/app/payment_stripe";
2 import { patch } from "@web/core/utils/patch";
3
4 patch(PaymentStripe.prototype, {
5 async captureAfterPayment(processPayment, line) {
6 // Don't capture if the customer can tip, in that case we
7 // will capture later.
8 if (!this.canBeAdjusted(line.uuid)) {
9 return super.captureAfterPayment(...arguments);
10 }
11 },
12
13 async sendPaymentAdjust(uuid) {
14 var order = this.pos.getOrder();
15 var line = order.getPaymentlineByUuid(uuid);
16 this.capturePaymentStripe(line.transaction_id, line.amount, {
17 stripe_currency_rounding: line.currency_id.rounding,
18 });
19 },
20
21 canBeAdjusted(uuid) {
22 var order = this.pos.getOrder();
23 var line = order.getPaymentlineByUuid(uuid);
24 return (
25 this.pos.config.set_tip_after_payment &&
26 line.payment_method_id.use_payment_terminal === "stripe" &&
27 line.card_type !== "interac" &&
28 (!line.card_type || !line.card_type.includes("eftpos"))
29 );
30 },
31 });