Files
odoo_source/addons/payment_adyen/tests/common.py
T
Demesmaeker 8442ea9c1a [IMP] payment_adyen: allow splitting authorization and capture
Being able to first authorize then capture a payment has several
advantages:
- Confirm a quotation when the payment is authorized and capture it
  when the order is shipped.
- Review orders before capturing the payment.
- Prevent credit card fees in the case of a refund

This commit implements this feature for the payment acquirer Adyen.

task-2507304

closes odoo/odoo#70591

Related: odoo/upgrade#3088
Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
2022-02-18 09:49:20 +00:00

53 lines
1.9 KiB
Python

# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo.addons.payment.tests.common import PaymentCommon
class AdyenCommon(PaymentCommon):
@classmethod
def setUpClass(cls, chart_template_ref=None):
super().setUpClass(chart_template_ref=chart_template_ref)
cls.adyen = cls._prepare_acquirer('adyen', update_values={
'adyen_merchant_account': 'dummy',
'adyen_api_key': 'dummy',
'adyen_client_key': 'dummy',
'adyen_hmac_key': '12345678',
'adyen_checkout_api_url': 'https://this.is.an.url',
'adyen_recurring_api_url': 'https://this.is.an.url',
})
# Override default values
cls.acquirer = cls.adyen
cls.psp_reference = '0123456789ABCDEF'
cls.original_reference = 'FEDCBA9876543210'
cls.webhook_notification_payload = {
'additionalData': {
'hmacSignature': 'kK6vSQvfWP3AtT2TTK1ePj9e7XPb7bF5jHC7jDWyU5c='
},
'amount': {
'currency': 'USD',
'value': 999,
},
'eventCode': 'AUTHORISATION',
'merchantAccountCode': 'DuckSACom123',
'merchantReference': cls.reference,
'originalReference': cls.original_reference,
'pspReference': cls.psp_reference,
'success': 'true',
} # Include all keys used in the computation of the signature to the payload
cls.webhook_notification_batch_data = {
'notificationItems': [
{
'NotificationRequestItem': cls.webhook_notification_payload,
}
]
}
def create_transaction(self, *args, acquirer_reference=None, **kwargs):
if not acquirer_reference:
acquirer_reference = self.psp_reference
return super().create_transaction(*args, acquirer_reference=acquirer_reference, **kwargs)