- Implemented PayDunya payment provider with necessary models, controllers, and views. - Added configuration files for Docker and Odoo setup. - Included .gitignore for Python and Odoo specific files.
33 lines
1.0 KiB
Python
33 lines
1.0 KiB
Python
import logging
|
|
from odoo import models, fields
|
|
|
|
_logger = logging.getLogger(__name__)
|
|
|
|
|
|
class PaymentProvider(models.Model):
|
|
_inherit = 'payment.provider'
|
|
|
|
# Override code field to add paydunya option
|
|
code = fields.Selection(
|
|
selection_add=[('paydunya', 'PayDunya')],
|
|
ondelete={'paydunya': 'cascade'}
|
|
)
|
|
|
|
# PayDunya specific credentials
|
|
paydunya_master_key = fields.Char('PayDunya Master Key')
|
|
paydunya_public_key = fields.Char('PayDunya Public Key')
|
|
paydunya_private_key = fields.Char('PayDunya Private Key')
|
|
paydunya_token = fields.Char('PayDunya Token')
|
|
environment = fields.Selection([
|
|
('sandbox', 'Sandbox'),
|
|
('production', 'Production')
|
|
], string='Environment', default='sandbox')
|
|
|
|
def _get_paydunya_api_base(self):
|
|
"""Return the correct API base URL for PayDunya based on environment."""
|
|
self.ensure_one()
|
|
if self.environment == 'production':
|
|
return 'https://app.paydunya.com/api/v1'
|
|
return 'https://app.paydunya.com/sandbox-api/v1'
|
|
|