Skip to content

[18.0][ADD] payment_amazon_pay: Add new module for Amazon Pay - #934

Open
pilarvargas-tecnativa wants to merge 2 commits into
OCA:18.0from
Tecnativa:18.0-add-payment_amazon_pay
Open

[18.0][ADD] payment_amazon_pay: Add new module for Amazon Pay#934
pilarvargas-tecnativa wants to merge 2 commits into
OCA:18.0from
Tecnativa:18.0-add-payment_amazon_pay

Conversation

@pilarvargas-tecnativa

Copy link
Copy Markdown
Contributor

@Tecnativa TT61807

@OCA-git-bot OCA-git-bot added series:18.0 mod:payment_amazon_pay Module payment_amazon_pay mod:payment_sequra Module payment_sequra labels Apr 20, 2026
@OCA-git-bot OCA-git-bot removed the mod:payment_sequra Module payment_sequra label Apr 27, 2026
@pedrobaeza pedrobaeza added this to the 18.0 milestone Apr 27, 2026
@cristina-hidalgo-tecnativa
cristina-hidalgo-tecnativa force-pushed the 18.0-add-payment_amazon_pay branch 3 times, most recently from 345982b to 21d0186 Compare April 27, 2026 11:54
@juancarlosonate-tecnativa

Copy link
Copy Markdown
Contributor

ping @carlos-lopez-tecnativa

@cristina-hidalgo-tecnativa
cristina-hidalgo-tecnativa force-pushed the 18.0-add-payment_amazon_pay branch 2 times, most recently from e9f870a to d1042dd Compare April 29, 2026 19:10

@carlos-lopez-tecnativa carlos-lopez-tecnativa left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review

Comment thread payment_amazon_pay/controllers/main.py Outdated
Comment thread payment_amazon_pay/controllers/main.py Outdated
Comment thread payment_amazon_pay/controllers/main.py Outdated

@carlos-lopez-tecnativa carlos-lopez-tecnativa left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a minor comment on the technical side: please review my comment about displaying errors if something occurs. I imagine that if the credentials are incorrect, the API should return some errors which can be displayed to the user. What do you think about the user experience?

Comment thread payment_amazon_pay/__manifest__.py Outdated
"name": "Amazon Pay",
"version": "18.0.1.0.0",
"category": "Accounting/Payment Providers",
"summary": "Amazon Pay payment provider for Odoo 18",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is not recommended to include the Odoo version here, especially if this module is migrated to v19+ in the future.

Suggested change
"summary": "Amazon Pay payment provider for Odoo 18",
"summary": "Amazon Pay payment provider for Odoo",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

):
self.ensure_one()
if not self.amazon_pay_private_key:
raise ValidationError(_("Amazon Pay private key is missing."))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check all occurrences, please.

Suggested change
raise ValidationError(_("Amazon Pay private key is missing."))
raise ValidationError(self.env._("Amazon Pay private key is missing."))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, updated all occurrences in both model files.

Comment on lines +52 to +56
payment_method = self.env["payment.method"].search(
[("code", "=", "amazon_pay")], limit=1
)
if payment_method:
self.payment_method_id = payment_method

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need to fill the payment_method_id here?
The Odoo base should populate this field in https://github.com/odoo/odoo/blob/678f2a48f66ef0bfbf4fdbbaf65fdf11fd499f05/addons/payment/controllers/portal.py#L358.
This value should come from the option selected by the user. Imagine if the payment provider has more than one payment method (this may not be the case here), but theoretically, a payment provider can have more than one payment method.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, removed. The base already sets it when creating the transaction.

Comment thread payment_amazon_pay/controllers/main.py Outdated
Comment on lines +39 to +45
try:
btn = tx.provider_id._amazon_pay_get_button_payload(tx)
except Exception:
_logger.exception(
"Amazon Pay: failed to build button payload for %s", reference
)
return request.redirect("/payment/status")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if simply redirecting to /payment/status is OK. If I have an error, it is not displayed to the user, and they may think everything is fine when it is not.

In my case, I don't have the credentials to test this module functionally, but I entered dummy credentials, and when I pay on the website, no error is displayed; it is just redirected to /payment/status, and the user can end up waiting there without any message describing what really happened.

Image

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. When building the button payload fails, _set_error is now called on the transaction before redirecting, so the status page reflects the actual error state.

@cristina-hidalgo-tecnativa
cristina-hidalgo-tecnativa force-pushed the 18.0-add-payment_amazon_pay branch 2 times, most recently from 54a26dd to 881eee3 Compare May 4, 2026 07:29
@cristina-hidalgo-tecnativa

Copy link
Copy Markdown
Contributor

Just a minor comment on the technical side: please review my comment about displaying errors if something occurs. I imagine that if the credentials are incorrect, the API should return some errors which can be displayed to the user. What do you think about the user experience?

Good point. I've updated the error handling so that API errors are now displayed to the user on the status page instead of being silently swallowed.

@carlos-lopez-tecnativa carlos-lopez-tecnativa left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review LGTM

Comment thread payment_amazon_pay/controllers/main.py Outdated
Comment on lines +45 to +49
except Exception:
_logger.exception(
"Amazon Pay: failed to build button payload for %s", reference
)
tx._set_error("Amazon Pay: failed to prepare the payment button.")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m not sure if you intentionally didn’t add an exception message here to avoid displaying technical information to the user, but since you do it in the ValidationError, it could be added here as well. Anyway, just a comment.

Suggested change
except Exception:
_logger.exception(
"Amazon Pay: failed to build button payload for %s", reference
)
tx._set_error("Amazon Pay: failed to prepare the payment button.")
except Exception as ex:
_logger.exception(
"Amazon Pay: failed to build button payload for %s", reference
)
tx._set_error(f"Amazon Pay: failed to prepare the payment button. {str(ex)}")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. The exception message is now included in both the ValidationError and generic Exception handlers.

@cristina-hidalgo-tecnativa
cristina-hidalgo-tecnativa force-pushed the 18.0-add-payment_amazon_pay branch 2 times, most recently from 71b8aa3 to ec7a6b3 Compare May 7, 2026 20:24
Comment thread payment_amazon_pay/data/payment_provider_data.xml Outdated
Comment thread payment_amazon_pay/data/payment_provider_data.xml Outdated
Comment on lines +10 to +35
<template id="amazon_pay_checkout_page" name="Amazon Pay Checkout">
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Amazon Pay</title>
<link
rel="stylesheet"
href="/payment_amazon_pay/static/src/css/amazon_pay_checkout.css"
/>
</head>
<body>
<div class="o_amazon_pay_box">
<p>Click the button to complete your payment with Amazon Pay.</p>
<div id="o_amazon_pay_button" />
</div>
<script id="o_amazon_pay_sdk" t-att-src="checkout_js_url" />
<script type="application/json" id="amazon-pay-cfg">
<t t-out="amazon_pay_cfg" />
</script>
<script
src="/payment_amazon_pay/static/src/js/amazon_pay_checkout.js"
/>
</body>
</html>
</template>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really necessary

@cristina-hidalgo-tecnativa
cristina-hidalgo-tecnativa force-pushed the 18.0-add-payment_amazon_pay branch 4 times, most recently from d640709 to d8b5687 Compare May 11, 2026 19:50
Comment thread payment_amazon_pay/data/payment_provider_data.xml
@cristina-hidalgo-tecnativa
cristina-hidalgo-tecnativa force-pushed the 18.0-add-payment_amazon_pay branch 7 times, most recently from 69bb7e0 to 82c4cbe Compare May 21, 2026 13:07

@juancarlosonate-tecnativa juancarlosonate-tecnativa left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Button flow needs review, it shouldn't preload in start() or mutate the shared paymentContext. It should be set up only when the option is selected instead of globally. See payment_paypal for the pattern:

https://github.com/odoo/odoo/blob/18.0/addons/payment_paypal/static/src/js/payment_form.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mod:payment_amazon_pay Module payment_amazon_pay series:18.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants