| 1 |
import { PaymentAdyen } from "@pos_adyen/app/utils/payment/payment_adyen"; |
| 2 |
import { patch } from "@web/core/utils/patch"; |
| 3 |
|
| 4 |
patch(PaymentAdyen.prototype, { |
| 5 |
_adyenPayData() { |
| 6 |
var data = super._adyenPayData(...arguments); |
| 7 |
|
| 8 |
if (data.SaleToPOIRequest.PaymentRequest.SaleData.SaleToAcquirerData) { |
| 9 |
data.SaleToPOIRequest.PaymentRequest.SaleData.SaleToAcquirerData += |
| 10 |
"&authorisationType=PreAuth"; |
| 11 |
} else { |
| 12 |
data.SaleToPOIRequest.PaymentRequest.SaleData.SaleToAcquirerData = |
| 13 |
"authorisationType=PreAuth"; |
| 14 |
} |
| 15 |
|
| 16 |
return data; |
| 17 |
}, |
| 18 |
|
| 19 |
sendPaymentAdjust(uuid) { |
| 20 |
var order = this.pos.getOrder(); |
| 21 |
var line = order.getPaymentlineByUuid(uuid); |
| 22 |
var data = { |
| 23 |
originalReference: line.transaction_id, |
| 24 |
modificationAmount: { |
| 25 |
value: parseInt(line.amount * Math.pow(10, this.pos.currency.decimal_places)), |
| 26 |
currency: this.pos.currency.name, |
| 27 |
}, |
| 28 |
merchantAccount: this.payment_method_id.adyen_merchant_account, |
| 29 |
additionalData: { |
| 30 |
industryUsage: "DelayedCharge", |
| 31 |
}, |
| 32 |
}; |
| 33 |
|
| 34 |
return this._callAdyen(data, "adjust"); |
| 35 |
}, |
| 36 |
|
| 37 |
canBeAdjusted(uuid) { |
| 38 |
var order = this.pos.getOrder(); |
| 39 |
var line = order.getPaymentlineByUuid(uuid); |
| 40 |
return ["mc", "visa", "amex", "discover"].includes(line.card_type); |
| 41 |
}, |
| 42 |
}); |