diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
| commit | 3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch) | |
| tree | a44932296ef4a9b71d5f010906253d8c53727726 /addons/pos_restaurant_adyen/models/pos_payment.py | |
| parent | 0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff) | |
initial commit 2
Diffstat (limited to 'addons/pos_restaurant_adyen/models/pos_payment.py')
| -rw-r--r-- | addons/pos_restaurant_adyen/models/pos_payment.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/addons/pos_restaurant_adyen/models/pos_payment.py b/addons/pos_restaurant_adyen/models/pos_payment.py new file mode 100644 index 00000000..4c62cacf --- /dev/null +++ b/addons/pos_restaurant_adyen/models/pos_payment.py @@ -0,0 +1,32 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +import json +import requests + +from odoo import models + +TIMEOUT = 10 + + +class PosPayment(models.Model): + _inherit = 'pos.payment' + + def _update_payment_line_for_tip(self, tip_amount): + """Capture the payment when a tip is set.""" + res = super(PosPayment, self)._update_payment_line_for_tip(tip_amount) + if self.payment_method_id.use_payment_terminal == 'adyen': + self._adyen_capture() + return res + + def _adyen_capture(self): + data = { + 'originalReference': self.transaction_id, + 'modificationAmount': { + 'value': int(self.amount * 10**self.currency_id.decimal_places), + 'currency': self.currency_id.name, + }, + 'merchantAccount': self.payment_method_id.adyen_merchant_account, + } + + return self.payment_method_id.proxy_adyen_request(data, 'capture') |
