Files
odoo_source/addons/payment_authorize/models/payment_token.py
T
Kevin BaptisteandAdrien Horgnies 660dc0ebaf [REF] payment_authorize: migrate Authorize.Net to the new payment API
This commit also drops the payment with redirection flow in favor of
the direct payment flow only, while preserving the currently used APIs.

See the merge commit for more details.

task-2333030

Co-authored-by: Adrien Horgnies <aho@odoo.com>
2021-03-30 09:25:51 +02:00

48 lines
1.4 KiB
Python

# Part of Odoo. See LICENSE file for full copyright and licensing details.
import logging
import pprint
from odoo import _, fields, models
from odoo.exceptions import UserError
from .authorize_request import AuthorizeAPI
_logger = logging.getLogger(__name__)
class PaymentToken(models.Model):
_inherit = 'payment.token'
authorize_profile = fields.Char(
string="Authorize.Net Profile ID",
help="The unique reference for the partner/token combination in the Authorize.net backend.")
def _handle_deactivation_request(self):
""" Override of payment to request Authorize.Net to delete the token.
Note: self.ensure_one()
:return: None
"""
super()._handle_deactivation_request()
if self.provider != 'authorize':
return
authorize_API = AuthorizeAPI(self.acquirer_id)
res_content = authorize_API.delete_customer_profile(self.authorize_profile)
_logger.info("delete_customer_profile request response:\n%s", pprint.pformat(res_content))
def _handle_reactivation_request(self):
""" Override of payment to raise an error informing that Auth.net tokens cannot be restored.
Note: self.ensure_one()
:return: None
"""
super()._handle_reactivation_request()
if self.provider != 'authorize':
return
raise UserError(_("Saved payment methods cannot be restored once they have been deleted."))