summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authornie <nie@odoo.com>2021-01-11 16:49:23 +0000
committernie <nie@odoo.com>2021-01-13 11:18:03 +0000
commit2636b9f5059808b443be67b06fca129cf9d3a913 (patch)
treefe2f3b101dddb060626b4f7f45d57727b3b8ccd4 /addons
parentb850a4ee4ed6688d7d5d1f51e29015cd279495bb (diff)
[FIX] payment_authorize: Show UserError to user
Steps: - Install website_sale and payment_authorize - Set up a tunnel (e.g. ngrok) - Log in to Authorize.Net backend - Go to Account > Response/Receipt URLs > Add Url - Enter the tunnel URL - In Odoo, go to Website > Configuration > eCommerce > Payment Acquirers - Edit "Authorize.Net" - Credentials tab: - State: Test Mode - API Login Id, Transaction and Signature key - Save, then Generate Client Key - Configuration tab: - Payment Flow: Payment from Odoo - Stop the server - Replace https://github.com/odoo/odoo/blob/1b9b99dc2643910c1412b564affccf02ba1e55d9/addons/payment_authorize/models/authorize_request.py#L46 with `resp = {'messages': {'resultCode': 'Error', 'message': [{'code': 'E00027', 'text': 'An error occurred during processing. Call Merchant Service Provider.'}]}}` - Restart the server - Go to "Website" > "Go to Website" > Shop - Add a product to the basket - Check out the basket - Choose "Credit Card (powered by Authorize) Test Mode" - Pay Now - Enter any card data (e.g. 4111 1111 1111 1111 - 01/22 - 900) Bug: When the Pay Now process is done, the customer is redirected to `/shop?error=invalid_token_id`. No errors are shown. Explanation: The patch simulates an error from Authorize.Net happening during their process. Using the special card numbers won't trigger the wanted behavior. When getting an error from Authorize.net, a `UserError` is raised. This error is then caught in the controller to return a formatted message. However, returning a dict in this part of the code embeds it inside `{'result': [...]}`. The error message is, thus, not blocking the form's redirection and the user gets redirected to the form action, i.e. `/shop/payment/token`. This route requires `pm_id`, but, in this scenario, it's an empty string. This leads to another redirection to `/shop/?error=invalid_token_id` as seen here: https://github.com/odoo/odoo/blob/1b9b99dc2643910c1412b564affccf02ba1e55d9/addons/website_sale/controllers/main.py#L938-L941 Letting the error bubble up forces the backend to return a blocking error response. This makes the fronted display the Authorize.Net error underneath the provider selection, and prevents it from redirecting. opw:2419260 closes odoo/odoo#64462 X-original-commit: c7a387b93cd49e6fb2bf5d240de81f4485830f4c Signed-off-by: backspac <backspac@users.noreply.github.com>
Diffstat (limited to 'addons')
-rw-r--r--addons/payment_authorize/controllers/main.py4
1 files changed, 0 insertions, 4 deletions
diff --git a/addons/payment_authorize/controllers/main.py b/addons/payment_authorize/controllers/main.py
index 4417f0408bb..cf917adffcb 100644
--- a/addons/payment_authorize/controllers/main.py
+++ b/addons/payment_authorize/controllers/main.py
@@ -55,10 +55,6 @@ class AuthorizeController(http.Controller):
return {
'error': message
}
- except UserError as e:
- return {
- 'error': e.args[0],
- }
if not token:
res = {