Skip to content

Commit

Permalink
Rename the module for publish on odoo marketplace. (#12)
Browse files Browse the repository at this point in the history
* Rename the module for publish on odoo marketplace.

* More renaming needed.
  • Loading branch information
ndeet authored Aug 12, 2024
1 parent 25b06ab commit 706860e
Show file tree
Hide file tree
Showing 26 changed files with 58 additions and 58 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

## Accept bitcoin payments on Odoo 16 and 17
This odoo addon allows you to accept bitcoin and Lightning Network (and other cryptocurrency) payments in your Odoo e-commerce store.
![BTCPay Server Banner](https://raw.githubusercontent.com/btcpayserver/odoo/17.0/payment_btcpay/static/description/BTCPay-Odoo-17-featured.png)
![BTCPay Server Banner](https://raw.githubusercontent.com/btcpayserver/odoo/17.0/payment_btcpayserver/static/description/BTCPay-Odoo-17-featured.png)

## How to install

Please find the installation instructions here:
- [Odoo 17 documentation](https://github.com/btcpayserver/odoo/blob/17.0/payment_btcpay/README.md)
- [Odoo 16 documentation](https://github.com/btcpayserver/odoo/blob/16.0/payment_btcpay/README.md)
- [Odoo 17 documentation](https://github.com/btcpayserver/odoo/blob/17.0/payment_btcpayserver/README.md)
- [Odoo 16 documentation](https://github.com/btcpayserver/odoo/blob/16.0/payment_btcpayserver/README.md)
26 changes: 0 additions & 26 deletions payment_btcpay/data/payment_provider_data.xml

This file was deleted.

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

## This is the module to connect Odoo 17 and BTCPay Server
This module allows you to accept bitcoin (and other cryptocurrency) payments in your Odoo e-commerce store.
![BTCPay Server Banner](https://raw.githubusercontent.com/btcpayserver/odoo/17.0/payment_btcpay/static/description/BTCPay-Odoo-17-featured.png)
![BTCPay Server Banner](https://raw.githubusercontent.com/btcpayserver/odoo/17.0/payment_btcpayserver/static/description/BTCPay-Odoo-17-featured.png)

:::tip
If you use Odoo 16 you can find the documentation [here](https://github.com/btcpayserver/odoo/blob/16.0/payment_btcpay/README.md).
If you use Odoo 16 you can find the documentation [here](https://github.com/btcpayserver/odoo/blob/16.0/payment_btcpayserver/README.md).
:::

## 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 `17.0` or downloaded a release tagged with version v17.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 @@ -46,13 +46,13 @@ Check the payment method is enabled:

Congrats, all done. Do some testing to be sure all works.

![Payment Provider Settings](https://raw.githubusercontent.com/btcpayserver/odoo/17.0/payment_btcpay/static/description/BTCPayPaymentSettings.png)
![Payment Provider Settings](https://raw.githubusercontent.com/btcpayserver/odoo/17.0/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.

![Checkout page example](https://raw.githubusercontent.com/btcpayserver/odoo/17.0/payment_btcpay/static/description/BTCPayLooksLike.png)
![Checkout page example](https://raw.githubusercontent.com/btcpayserver/odoo/17.0/payment_btcpayserver/static/description/BTCPayLooksLike.png)


## Transaction BTCPay Details
Expand All @@ -61,4 +61,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 details of BTCPay](https://raw.githubusercontent.com/btcpayserver/odoo/17.0/payment_btcpay/static/description/BtcpayTxDetails.png)
![Transaction details of BTCPay](https://raw.githubusercontent.com/btcpayserver/odoo/17.0/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(env):
setup_provider(env, 'btcpay')
setup_provider(env, 'btcpayserver')


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

{
'name': 'Payment Provider: BTCPay',
'name': 'Payment Provider: BTCPay Server',
'summary': 'This module integrates BTCPAY - pay with Bitcoin - with Odoo v17.0',
'author': 'Vandekul, ndeet',
'website': 'https://github.com/btcpayserver/odoo',
'category': 'Accounting/Payment Providers',
'version': '17.0.1.1',
'version': '17.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',
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
26 changes: 26 additions & 0 deletions payment_btcpayserver/data/payment_provider_data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo noupdate="1">

<record id="payment_method_btcpayserver" model="payment.method">
<field name="name">Pay with Bitcoin / Lightning Network</field>
<field name="code">btcpayserver</field>
<field name="active">True</field>
<field name="image" type="base64" file="payment_btcpayserver/static/description/icon.png"/>
<field name="support_tokenization">False</field>
<field name="support_express_checkout">False</field>
</record>

<record id="payment_provider_btcpayserver" model="payment.provider">
<field name="name">BTCPay Server payments</field>
<field name="code">btcpayserver</field>
<field name="image_128" type="base64" file="payment_btcpayserver/static/description/icon.png"/>
<field name="redirect_form_view_id" ref="redirect_form"/>
<field name="module_id" ref="base.module_payment_btcpayserver"/>
<field name="payment_method_ids"
eval="[Command.set([
ref('payment_btcpayserver.payment_method_btcpayserver'),
])]"
/>
</record>

</odoo>
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
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ <h2 class="oe_slogan">Install the module</h2>
<ul>
<li>Clone our [repository](https://github.com/btcpayserver/odoo) or download the .zip from the [releases page](https://github.com/btcpayserver/odoo/releases)
<li>Make sure you are on branch `17.0` or downloaded a release tagged with version v17.x
<li>Place the `payment_btcpay` directory in your Odoo addons directory
<li>Install dependencies by running `pip install -r requirements.txt` (from inside the `payment_btcpay` directory)
<li>Place the `payment_btcpayserver` directory in your Odoo addons directory
<li>Install dependencies by running `pip install -r requirements.txt` (from inside the `payment_btcpayserver` directory)
<li>Restart Odoo
<li>Go to Apps -> Update Apps List
<li>Remove the "Apps" filter and search for "btcpay"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
<field name="inherit_id" ref="payment.payment_provider_form"/>
<field name="arch" type="xml">
<group name="provider_credentials" position='inside'>
<group invisible="code != 'btcpay'">
<group invisible="code != 'btcpayserver'">
<field name="btcpay_location"/>
<field name="btcpay_pairingCode"/>
</group>
<group invisible="code != 'btcpay'">
<group invisible="code != 'btcpayserver'">
<field name="btcpay_token"/>
<field name="btcpay_privateKey"/>
<field name="btcpay_facade"/>
Expand Down

0 comments on commit 706860e

Please sign in to comment.