[FIX] payment_stripe: handle error for unsupported country while stripe setup
Currently, When a user tries to set up a stripe account but his country is not
supported by stripe then he receives a error message at backend side and a
ValidationError ("Stripe Proxy: An error occurred when communicating with
the proxy.") on frontend side.
After applying this commit the error message will be updated to a warning level
which will reduce the noise in sentry. I have also added a condition in
'action_stripe_connect_account' method to check whether the country is
supported by stripe or not and if it is not supported the user will be
redirected to other payment providers page.
sentry-3935758343
closes odoo/odoo#128140
X-original-commit: c7b0d8eebe686d9c38f9f5c71577c80718ffb791
Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -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', {})
|
||||
|
||||
Reference in New Issue
Block a user