5 Commits
Author SHA1 Message Date
ndeet 9e2475f415 Update docs to latest changes. 2024-07-09 10:26:02 +02:00
ndeet 488aea8771 Remove customizable return url and redirect the user to order confirmation / payment status page as it would be expected.
(cherry picked from commit 6a22f82a73)
2024-07-08 16:40:27 +02:00
ndeet 0f31982616 Fix IPN processing to cover additional invoice states.
(cherry picked from commit 17cb4f7814)
2024-07-08 11:13:03 +02:00
ndeet c32776ba60 Change version to match 17.0 branch scheme. 2024-07-08 09:22:04 +02:00
ndeet 43636e52e3 Fix typo. 2024-07-08 09:19:18 +02:00
7 changed files with 22 additions and 12 deletions
+1 -2
View File
@@ -6,7 +6,7 @@ This module allows you to accept bitcoin (and other cryptocurrency) payments in
![BTCPay Server Website](../payment_btcpay/static/description/BTCPayServer_org.png)
## Install the module
* Clone our [repository](https://github.com/btcpayserver/odoo) or download the .zip from the [releases page](https://github.com/btcpayserver/odoo/releases
* Clone our [repository](https://github.com/btcpayserver/odoo) or download the .zip from the [releases page](https://github.com/btcpayserver/odoo/releases)
* Place the `payment_btcpay` directory in your Odoo addons directory
* Install dependencies by running `pip install -r requirements.txt` (from inside the `payment_btcpay` directory)
* Restart Odoo
@@ -21,7 +21,6 @@ This module allows you to accept bitcoin (and other cryptocurrency) payments in
In the BTCPay settings form, tab "Credentials":
* Set field "State" to enabled
* Set field "BTCPay Server URL" as test or live URL including https://. Example URL: https://testnet.demo.btcpayserver.org
* Set field "Confirmation URL" where the customer will return after payment
* Get a pairing code from your BTCPay Server store: Settings -> Access Tokens
* Click on "Create Token" button
* Label: enter e.g. "My odoo store"
+1 -1
View File
@@ -25,7 +25,7 @@
'author': 'Vandekul',
'website': 'https://github.com/btcpayserver/odoo',
'category': 'Accounting/Payment Providers',
'version': '16.0.0',
'version': '16.0.1.0',
'license': 'GPL-3',
'application': False,
'installable': True,
+17 -4
View File
@@ -42,6 +42,7 @@ _logger = logging.getLogger(__name__)
class BTCPayController(http.Controller):
_checkout_url = '/btcpay/checkout'
_notify_url = '/payment/btcpay/ipn'
_return_url = '/payment/btcpay/return'
@http.route(_checkout_url, type='http', auth='public', csrf=False, website=True)
def checkout(self, **data):
@@ -49,15 +50,17 @@ class BTCPayController(http.Controller):
_logger.info("CHECKOUT: notification received from BTCPay with data:\n%s", pprint.pformat(data))
tx_sudo = request.env['payment.transaction'].sudo()._get_tx_from_notification_data('btcpay', data)
provider = tx_sudo.provider_id
notificationURL = str(data.get('notify_url')).replace("http://", "https://")
notification_url = str(data.get('notify_url')).replace("http://", "https://")
base_url = request.env['ir.config_parameter'].sudo().get_param('web.base.url')
redirect_url = urls.url_join(base_url, self._return_url)
client = BTCPayClient(host=provider.btcpay_location, pem=provider.btcpay_privateKey, tokens={provider.btcpay_facade: provider.btcpay_token})
invoice = client.create_invoice(
{"price": data.get('amount'),
"currency": data.get('currency_id'),
"orderId": data.get('reference'),
"token": provider.btcpay_token,
"redirectURL": provider.btcpay_confirmationURL,
"notificationURL": notificationURL,
"redirectURL": redirect_url,
"notificationURL": notification_url,
"extendedNotifications": True,
"buyer": {"email": data.get('email'),
"name": data.get('name'),
@@ -66,7 +69,7 @@ class BTCPayController(http.Controller):
"postalCode": data.get('zip'),
"country": data.get('country'),
"notify": False}})
_logger.info('Invoice %s \n NOTIFY URL: %s', invoice, notificationURL)
_logger.info('Invoice %s \n NOTIFY URL: %s', invoice, notification_url)
return werkzeug.utils.redirect(invoice['url'])
@http.route(_notify_url, type='json', auth='public', csrf=False)
@@ -97,3 +100,13 @@ class BTCPayController(http.Controller):
except ValidationError: # Acknowledge the notification to avoid getting spammed
_logger.exception("Unable to handle the notification data; skipping to acknowledge")
return ''
@http.route(_return_url, type='http', auth="public", methods=['GET'], crsf=False, save_session=False)
def btcpay_return_from_redirect(self, **data):
""" BTCPay return
We could process and check the invoice status here but there is no need to as the status get's updated via
IPN anyway, so just show the user the order confirmation / payment status page.
"""
_logger.info("BTCPay: user returned to shop after payment")
return request.redirect('/payment/status')
@@ -14,7 +14,6 @@ class PaymentProvider(models.Model):
selection_add=[('btcpay', "BTCPay")], ondelete={'btcpay': 'set default'})
btcpay_location = fields.Char(string='BTCPay Server URL', size=64, help='URL where your BTCPay Server instance is reachable (where you log into your BTCPay Server).', default='https://testnet.demo.btcpayserver.org')
btcpay_confirmationURL = fields.Char(string='Confirmation URL', help='Confirmation URL to return after BTCPay payment', default='http://yourdomain/shop/confirmation')
btcpay_pairingCode = fields.Char(string='Pairing Code', help='Create paring Code in your BTCPay server and put here')
btcpay_token = fields.Char(string='Token', help='Access Token to BTCPay. Leave empty, will be autogenerated during pairing.')
+3 -3
View File
@@ -115,15 +115,15 @@ class PaymentTransaction(models.Model):
self.btcpay_txid = notification_data.get('txid')
self.btcpay_status = notification_data.get('status')
if self.btcpay_status in ['paid']:
if self.btcpay_status in ['paid','processing']:
self._set_pending(state_message=notification_data.get('pending_reason'))
elif self.btcpay_status in ['confirmed']:
elif self.btcpay_status in ['confirmed', 'complete']:
self._set_done()
confirmed_orders = self._check_amount_and_confirm_order()
confirmed_orders._send_order_confirmation_mail()
elif self.btcpay_status in ['new']:
self.btcpay_invoiceId = notification_data.get('invoiceID')
elif self.btcpay_status in ['cancel']:
elif self.btcpay_status in ['cancel','cancelled']:
self._set_canceled()
elif self.btcpay_status in ['invalid']:
_logger.info(
Binary file not shown.

Before

Width:  |  Height:  |  Size: 107 KiB

After

Width:  |  Height:  |  Size: 109 KiB

@@ -9,7 +9,6 @@
<group name="provider_credentials" position='inside'>
<group attrs="{'invisible': [('code', '!=', 'btcpay')]}">
<field name="btcpay_location"/>
<field name="btcpay_confirmationURL"/>
<field name="btcpay_pairingCode"/>
</group>
<group attrs="{'invisible': [('code', '!=', 'btcpay')]}">