Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions payment_bitcoin/models/payment_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,20 @@ class BitcoinPaymentProvider(models.Model):
)
bitcoin_send_email = fields.Boolean(default=False)

def _get_redirect_form_view(self, is_validation=False):
"""Override to always return the bitcoin redirect form view.

The base implementation simply returns self.redirect_form_view_id, which
may not be set on existing installations because the provider data record
is wrapped in noupdate="1" and the field was added later. By returning
the view via env.ref() we make the redirect flow work regardless of
whether the database field has been populated.
"""
self.ensure_one()
if self.code != "bitcoin":
return super()._get_redirect_form_view(is_validation=is_validation)
return self.env.ref("payment_bitcoin.bitcoin_form")

def _get_default_payment_method_id(self):
self.ensure_one()
if self.provider == "bitcoin":
Expand Down
6 changes: 3 additions & 3 deletions payment_bitcoin/models/payment_transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,10 @@ def _get_specific_rendering_values(self, processing_values):

if self.provider_code != "bitcoin":
return res
self.provider_id.get_base_url()
# Only return the values actually used by the bitcoin_form template.
# The /payment/bitcoin/feedback controller resolves the transaction via
# `reference` alone, so no other fields are required in the POST body.
return {
"currency_code": self.currency_id.name,
"return_url": BitcoinController.accept_url,
"reference": self.reference,
"tx_url": "/shop/payment/validate",
}
14 changes: 7 additions & 7 deletions payment_bitcoin/views/payment_bitcoin_templates.xml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<template id="bitcoin_form">
<!-- Redirect form submitted by Odoo's JS payment flow (_processRedirectFlow).
The /payment/bitcoin/feedback controller only needs `reference` to look
up the transaction; all other fields that were here previously
(amount, currency_code, csrf_token) are unused by that controller and
`amount` would cause a QWeb NameError because it is not passed in the
rendering values. -->
<form t-att-action="return_url" method="post">
<input type="hidden" name="csrf_token" t-att-value="request.csrf_token()" />
<t t-if="tx_url">
<input type='hidden' name='tx_url' t-att-value='tx_url' />
</t>
<input type='hidden' name='reference' t-att-value='reference' />
<input type='hidden' name='amount' t-att-value='amount' />
<input type='hidden' name='currency_code' t-att-value='currency_code' />
<input type="hidden" name="reference" t-att-value="reference" />
</form>
</template>

Expand Down
Loading