Skip to content

Commit

Permalink
Prepare for marketplace submission, rename module; new release. (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
ndeet authored Aug 21, 2024
1 parent 1421168 commit 95c6cd5
Show file tree
Hide file tree
Showing 25 changed files with 228 additions and 119 deletions.
87 changes: 0 additions & 87 deletions payment_btcpay/static/description/index.html

This file was deleted.

File renamed without changes.
12 changes: 6 additions & 6 deletions payment_btcpay/README.md → payment_btcpayserver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

## This is the module to connect Odoo 16 and BTCPay Server
This module allows you to accept bitcoin (and other cryptocurrency) payments in your Odoo e-commerce store.
![BTCPay Server Banner](../payment_btcpay/static/description/BTCPay-Odoo-16-featured.png)
![BTCPay Server Banner](../payment_btcpayserver/static/description/BTCPay-Odoo-16-featured.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)
* Make sure you are on branch `16.0` or downloaded a release tagged with version v16.x
* 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)
* Place the `payment_btcpayserver` directory in your Odoo addons directory
* Install dependencies by running `pip install -r requirements.txt` (from inside the `payment_btcpayserver` directory)
* Restart Odoo
* Go to Apps -> Update Apps List
* Remove the "Apps" filter and search for "btcpay"
Expand Down Expand Up @@ -36,13 +36,13 @@ On the tab "Configuration":
* Set field "Payment Journal" to "Bank", you can click the dropdown and click on the suggestion "Bank"
* Now you can **save** the settings

![Payment Provider Settings](../payment_btcpay/static/description/BTCPayPaymentSettings.png)
![Payment Provider Settings](../payment_btcpayserver/static/description/BTCPayPaymentSettings.png)

## How does the payment page look?

During the checkout the customers will have the option to select the payment method "Pay with Bitcoin / Lightning Network". After selecting they will be redirected to the BTCPay checkout page as shown below.

![Payment Provider](../payment_btcpay/static/description/BTCPayLooksLike.png)
![Payment Provider](../payment_btcpayserver/static/description/BTCPayLooksLike.png)


## Transaction BTCPay Details
Expand All @@ -51,4 +51,4 @@ In transaction object, you will find more technical information about this metho
* Invoice Id: the id of the invoice for which you want to fetch an event token
* Transaction Status: That indicates state of transaction

![Transaction Btcpay Details](../payment_btcpay/static/description/BtcpayTxDetails.png)
![Transaction Btcpay Details](../payment_btcpayserver/static/description/BtcpayTxDetails.png)
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@


def post_init_hook(cr, registry):
setup_provider(cr, registry, 'btcpay')
setup_provider(cr, registry, 'btcpayserver')


def uninstall_hook(cr, registry):
reset_payment_provider(cr, registry, 'btcpay')
reset_payment_provider(cr, registry, 'btcpayserver')
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#******************************************************************************
# PAYMENT BTCPAY FOR ODOO
# PAYMENT BTCPAY SERVER FOR ODOO
#
# Copyright (C) 2023 Susanna Fort <[email protected]>
# Copyright (C) 2023 Susanna Fort <[email protected]>, ndeet
#
#******************************************************************************
#
Expand All @@ -20,23 +20,25 @@
#******************************************************************************

{
'name': 'Payment Provider: BTCPay',
'name': 'Payment Provider: BTCPay Server',
'summary': 'This module integrates BTCPAY - pay with Bitcoin - with Odoo v16.0',
'author': 'Vandekul',
'author': 'BTCPay Server team and contributors',
'website': 'https://github.com/btcpayserver/odoo',
'category': 'Accounting/Payment Providers',
'version': '16.0.1.1',
'version': '16.0.2.0',
'license': 'GPL-3',
'currency': 'USD',
'application': False,
'installable': True,
'auto_install': False,
'depends': ['base', 'account', 'payment'],
'data': [
'views/payment_btcpay_templates.xml',
'views/payment_btcpayserver_templates.xml',
'views/payment_provider_views.xml',
'views/payment_transaction_views.xml',
'data/payment_provider_data.xml',
],
'images': ['static/description/BTCPay-Odoo-16-featured.png'],
'external_dependencies': {
'python': ['btcpay-python']
},
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class BTCPayController(http.Controller):
def checkout(self, **data):

_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)
tx_sudo = request.env['payment.transaction'].sudo()._get_tx_from_notification_data('btcpayserver', data)
provider = tx_sudo.provider_id
notification_url = str(data.get('notify_url')).replace("http://", "https://")
base_url = request.env['ir.config_parameter'].sudo().get_param('web.base.url')
Expand Down Expand Up @@ -82,7 +82,7 @@ def btcpay_ipn(self, **post):
notification_data = {"reference": data['data']['orderId'],
"invoiceID": data['data']['id']}
# Check the origin and integrity of the notification
tx_sudo = request.env['payment.transaction'].sudo()._get_tx_from_notification_data('btcpay', notification_data)
tx_sudo = request.env['payment.transaction'].sudo()._get_tx_from_notification_data('btcpayserver', notification_data)
provider = tx_sudo.provider_id
client = BTCPayClient(host=provider.btcpay_location, pem=provider.btcpay_privateKey,
tokens={provider.btcpay_facade: provider.btcpay_token})
Expand All @@ -96,7 +96,7 @@ def btcpay_ipn(self, **post):
"txid": fetched_invoice['url']}

# Handle the notification data
tx_sudo._handle_notification_data('btcpay', notification_data)
tx_sudo._handle_notification_data('btcpayserver', notification_data)
except ValidationError: # Acknowledge the notification to avoid getting spammed
_logger.exception("Unable to handle the notification data; skipping to acknowledge")
return ''
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo noupdate="1">

<record id="payment_provider_btcpay" model="payment.provider">
<record id="payment_provider_btcpayserver" model="payment.provider">
<field name="name">BTCPay payments</field>
<field name="display_as">Pay with Bitcoin / Lightning Network</field>
<field name="code">btcpay</field>
<field name="image_128" type="base64" file="payment_btcpay/static/description/icon.png"/>
<field name="module_id" ref="base.module_payment_btcpay"/>
<field name="code">btcpayserver</field>
<field name="image_128" type="base64" file="payment_btcpayserver/static/description/icon.png"/>
<field name="module_id" ref="base.module_payment_btcpayserver"/>
<field name="redirect_form_view_id" ref="redirect_form"/>
</record>

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class PaymentProvider(models.Model):
_inherit = 'payment.provider'

code = fields.Selection(
selection_add=[('btcpay', "BTCPay")], ondelete={'btcpay': 'set default'})
selection_add=[('btcpayserver', "BTCPay")], ondelete={'btcpayserver': '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_pairingCode = fields.Char(string='Pairing Code', help='Create paring Code in your BTCPay server and put here')
Expand All @@ -21,14 +21,14 @@ class PaymentProvider(models.Model):
btcpay_facade = fields.Char(string='Facade', help='Token facade type: merchant/pos/payroll. Keep merchant', default='merchant')

def create(self, values_list):
if self.code == 'btcpay':
if self.code == 'btcpayserver':
values_list['btcpay_privateKey'] = crypto.generate_privakey()

return super(PaymentProvider, self).create(values_list)

@api.onchange('btcpay_pairingCode')
def _onchange_pairingCode(self):
if not self.btcpay_token and self.code == 'btcpay' and not self.btcpay_pairingCode == '':
if not self.btcpay_token and self.code == 'btcpayserver' and not self.btcpay_pairingCode == '':
#_logger.info("ONCHANGE PAIRING CODE***SELF: %s %s %s", self.btcpay_location, self.btcpay_privateKey, self.btcpay_pairingCode)
self.btcpay_privateKey = crypto.generate_privkey()
client = BTCPayClient(host=self.btcpay_location, pem=self.btcpay_privateKey)
Expand All @@ -37,14 +37,14 @@ def _onchange_pairingCode(self):

@api.onchange('btcpay_token')
def _onchange_token(self):
if self.code == 'btcpay':
if self.code == 'btcpayserver':
self.btcpay_pairingCode = ''
#_logger.info("ONCHANGE TOKEN")


@api.onchange('btcpay_location')
def _onchange_location(self):
if self.code == 'btcpay':
if self.code == 'btcpayserver':
self.btcpay_token = ''
#_logger.info("ONCHANGE LOCATION ***SELF: %s %s %s", self.btcpay_location, self.btcpay_privateKey, self.btcpay_pairingCode)
self.btcpay_privateKey = ''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def _get_specific_rendering_values(self, processing_values):

res = super()._get_specific_rendering_values(processing_values)

if self.provider_code != 'btcpay':
if self.provider_code != 'btcpayserver':
return res

base_url = self.provider_id.get_base_url()
Expand Down Expand Up @@ -68,11 +68,11 @@ def _get_tx_from_notification_data(self, provider_code, notification_data):
"""
tx = super()._get_tx_from_notification_data(provider_code, notification_data)
_logger.info('GET TX FROM NOTIFICATION Notification_data %s', pprint.pformat(notification_data))
if provider_code != 'btcpay' or len(tx) == 1:
if provider_code != 'btcpayserver' or len(tx) == 1:
return tx

reference = notification_data.get('reference')
tx = self.search([('reference', '=', reference), ('provider_code', '=', 'btcpay')])
tx = self.search([('reference', '=', reference), ('provider_code', '=', 'btcpayserver')])
if not tx:
raise ValidationError(
"BTCPay: " + _("No transaction found matching reference %s.", reference)
Expand Down Expand Up @@ -102,7 +102,7 @@ def _process_notification_data(self, notification_data):
:raise: ValidationError if inconsistent data were received
"""
super()._process_notification_data(notification_data)
if self.provider_code != 'btcpay':
if self.provider_code != 'btcpayserver':
return

_logger.info("_process_notification_data %s", pprint.pformat(notification_data))
Expand Down
File renamed without changes.
File renamed without changes
Loading

0 comments on commit 95c6cd5

Please sign in to comment.