UX was lacking comparing to other payment providers, important fields were not always shown or were checkboxes when they should be automatically true. In order to make payment flow easier and more intitive, unnecessary fields were removed, email is automatically filled. Now when user cancels transaction on paypal before paying, it automatically cancels transaction on Odoo. Additionaly, quick onboarding is only available if user already has paypal account and Stripe no longer installs ond configures paypal if Stripe's onboarding get canceled. task-2854184 closes odoo/odoo#104974 Related: odoo/upgrade#4025 Related: odoo/documentation#3063 Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
61 lines
1.8 KiB
Python
61 lines
1.8 KiB
Python
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
|
|
import logging
|
|
|
|
from odoo import _, fields, models
|
|
|
|
from odoo.addons.payment_paypal.const import SUPPORTED_CURRENCIES
|
|
|
|
|
|
_logger = logging.getLogger(__name__)
|
|
|
|
|
|
class PaymentProvider(models.Model):
|
|
_inherit = 'payment.provider'
|
|
|
|
code = fields.Selection(
|
|
selection_add=[('paypal', "Paypal")], ondelete={'paypal': 'set default'}
|
|
)
|
|
paypal_email_account = fields.Char(
|
|
string="Email",
|
|
help="The public business email solely used to identify the account with PayPal",
|
|
required_if_provider='paypal',
|
|
default=lambda self: self.env.company.email,
|
|
)
|
|
paypal_pdt_token = fields.Char(string="PDT Identity Token", groups='base.group_system')
|
|
|
|
#=== COMPUTE METHODS ===#
|
|
|
|
def _compute_feature_support_fields(self):
|
|
""" Override of `payment` to enable additional features. """
|
|
super()._compute_feature_support_fields()
|
|
self.filtered(lambda p: p.code == 'paypal').update({
|
|
'support_fees': True,
|
|
})
|
|
|
|
#=== BUSINESS METHODS ===#
|
|
|
|
def _get_supported_currencies(self):
|
|
""" Override of `payment` to return the supported currencies. """
|
|
supported_currencies = super()._get_supported_currencies()
|
|
if self.code == 'paypal':
|
|
supported_currencies = supported_currencies.filtered(
|
|
lambda c: c.name in SUPPORTED_CURRENCIES
|
|
)
|
|
return supported_currencies
|
|
|
|
def _paypal_get_api_url(self):
|
|
""" Return the API URL according to the provider state.
|
|
|
|
Note: self.ensure_one()
|
|
|
|
:return: The API URL
|
|
:rtype: str
|
|
"""
|
|
self.ensure_one()
|
|
|
|
if self.state == 'enabled':
|
|
return 'https://www.paypal.com/cgi-bin/webscr'
|
|
else:
|
|
return 'https://www.sandbox.paypal.com/cgi-bin/webscr'
|