feat(website_sale): capture optional Monero refund address at checkout (#4) - #25
Open
bnuckols13 wants to merge 1 commit into
Open
feat(website_sale): capture optional Monero refund address at checkout (#4)#25bnuckols13 wants to merge 1 commit into
bnuckols13 wants to merge 1 commit into
Conversation
Closes monero-integrations#4. Add an optional, validated Monero refund address to the checkout flow, for when a shopper overpays or an item is out of stock. It is captured on the order and shown to the merchant; refunds stay manual (auto-refund is out of scope and would touch wallet-spend code). - sale.order.monero_refund_address + @api.constrains validating via the already-required monero package (empty allowed, invalid rejected without crashing checkout) - POST /shop/monero/refund_address captures the input on the payment step, shown only when Monero is an available provider - surfaced on the backend sale.order form for the merchant - tests: valid stored / invalid rejected / empty allowed / whitespace tolerated - also fix a pre-existing test that assigned a mock onto a read-only record method (errored on Odoo 19); same controller this change touches
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #4.
The issue asks to let a shopper provide a refund address for when they overpay or an item is out of stock. This adds an optional, validated Monero refund address to the checkout flow, captured on the order and shown to the merchant. It does not send refunds — capturing the address is what the issue asks for, and auto-refunding would touch wallet-spend code that is out of scope here.
What changed
sale.order.monero_refund_address(models/sales_order.py): aCharfield with an@api.constrainsthat validates the value with the already-requiredmoneropackage (monero.address.address()), raising a clearValidationErroron a malformed address. An empty value is allowed, so checkout is unaffected when the shopper skips it. Validating on the model means every write path — web, backend, API — is covered.controllers/website_sale.py): a smallPOST /shop/monero/refund_addressroute writes the address onto the cart order; an invalid entry is reported back on the payment page (via a?monero_refund_error=1redirect flag) instead of crashing checkout. The input is rendered only when Monero is an available provider.views/monero_refund_address_views.xml): an optional "Refund address (Monero)" input inherited intowebsite_sale.payment, and the field surfaced on the backendsale.orderform so the merchant can see where to refund.tests/test_refund_address.py): valid address stored; invalid rejected on create and on write; empty allowed; surrounding whitespace tolerated.One extra change, called out for transparency
While adding tests I found a pre-existing test that errors on Odoo 19:
tests/test_controllers.py::test_rpc_unauthorized_raises_validation_errorassigned aMagicMockdirectly onto apayment.providerrecord'sget_walletmethod, which Odoo 19 rejects as read-only (AttributeError: ... is read-only). I fixed it to mock a provider object the way the sibling test already does. It sits in the same controller this PR touches and makes the suite green. Happy to split it into its own PR if you'd prefer.Verification
Out of scope (deliberately)
No automatic refund sending, no change to payment detection/confirmation, no new dependencies.
Known minor
The server validates a trimmed value, and the checkout route trims before storing, so addresses captured from the storefront are clean. A refund address typed directly into the backend order form is stored as entered (surrounding whitespace kept). Happy to normalize on write if you'd like the field trimmed on every path.