| 1 |
# -*- coding: utf-8 -*- |
| 2 |
# Part of Odoo. See LICENSE file for full copyright and licensing details. |
| 3 |
|
| 4 |
import json |
| 5 |
import requests |
| 6 |
|
| 7 |
from odoo import models |
| 8 |
|
| 9 |
TIMEOUT = 10 |
| 10 |
|
| 11 |
|
| 12 |
class PosPayment(models.Model): |
| 13 |
_inherit = 'pos.payment' |
| 14 |
|
| 15 |
def _update_payment_line_for_tip(self, tip_amount): |
| 16 |
"""Capture the payment when a tip is set.""" |
| 17 |
res = super(PosPayment, self)._update_payment_line_for_tip(tip_amount) |
| 18 |
if self.payment_method_id.use_payment_terminal == 'adyen': |
| 19 |
self._adyen_capture() |
| 20 |
return res |
| 21 |
|
| 22 |
def _adyen_capture(self): |
| 23 |
data = { |
| 24 |
'originalReference': self.transaction_id, |
| 25 |
'modificationAmount': { |
| 26 |
'value': int(self.amount * 10**self.currency_id.decimal_places), |
| 27 |
'currency': self.currency_id.name, |
| 28 |
}, |
| 29 |
'merchantAccount': self.payment_method_id.adyen_merchant_account, |
| 30 |
} |
| 31 |
|
| 32 |
return self.payment_method_id.proxy_adyen_request(data, 'capture') |