diff --git a/addons/payment_stripe/i18n/payment_stripe.pot b/addons/payment_stripe/i18n/payment_stripe.pot index ea5878a13e7..42cb9bfd6e9 100644 --- a/addons/payment_stripe/i18n/payment_stripe.pot +++ b/addons/payment_stripe/i18n/payment_stripe.pot @@ -49,6 +49,13 @@ msgstr "" msgid "No transaction found matching reference %s." msgstr "" +#. module: payment_stripe +#. odoo-python +#: code:addons/payment_stripe/models/payment_provider.py:0 +#, python-format +msgid "Other Payment Providers" +msgstr "" + #. module: payment_stripe #: model:ir.model,name:payment_stripe.model_payment_acquirer msgid "Payment Acquirer" @@ -113,6 +120,15 @@ msgstr "" msgid "Stripe" msgstr "" +#. module: payment_stripe +#. odoo-python +#: code:addons/payment_stripe/models/payment_provider.py:0 +#, python-format +msgid "" +"Stripe Connect is not available in your country, please use another payment " +"provider." +msgstr "" + #. module: payment_stripe #: model:ir.model.fields,field_description:payment_stripe.field_payment_transaction__stripe_payment_intent msgid "Stripe Payment Intent ID" diff --git a/addons/payment_stripe/models/payment_provider.py b/addons/payment_stripe/models/payment_provider.py index 0e7a803b87c..5fa2b26856d 100644 --- a/addons/payment_stripe/models/payment_provider.py +++ b/addons/payment_stripe/models/payment_provider.py @@ -7,7 +7,7 @@ import requests from werkzeug.urls import url_encode, url_join, url_parse from odoo import _, api, fields, models -from odoo.exceptions import UserError, ValidationError +from odoo.exceptions import RedirectWarning, UserError, ValidationError from odoo.addons.payment_stripe import utils as stripe_utils from odoo.addons.payment_stripe import const @@ -133,6 +133,16 @@ class PaymentProvider(models.Model): """ self.ensure_one() + if self.env.company.country_id.code not in const.SUPPORTED_COUNTRIES: + raise RedirectWarning( + _( + "Stripe Connect is not available in your country, please use another payment" + " provider." + ), + self.env.ref('payment.action_payment_provider').id, + _("Other Payment Providers"), + ) + if self.state == 'enabled': self.env['onboarding.onboarding.step'].action_validate_step_payment_provider() action = {'type': 'ir.actions.act_window_close'} @@ -415,7 +425,7 @@ class PaymentProvider(models.Model): response_content = response.json() if response_content.get('error'): # An exception was raised on the proxy error_data = response_content['error']['data'] - _logger.error("request forwarded with error: %s", error_data['message']) + _logger.warning("request forwarded with error: %s", error_data['message']) raise ValidationError(_("Stripe Proxy error: %(error)s", error=error_data['message'])) return response_content.get('result', {})