diff --git a/payment_btcpay/README.md b/payment_btcpay/README.md index 2caf65a..2c90e93 100644 --- a/payment_btcpay/README.md +++ b/payment_btcpay/README.md @@ -1,28 +1,49 @@ # payment_btcpay -# Gateway to BTCPay for Odoo 16.0 +# BTCPay Server payment gateway for Odoo 16.0 ## This is the module to connect Odoo 16.0 and BTCPay -This module allow you to create an easily way to accept cryptocurrencies. -![BTCPay](/payment_btcpay/static/description/Btcpay_com.png) +This module allows you to accept bitcoin (and other cryptocurrency) payments in your Odoo e-commerce store. +![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 +* 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 +* Go to Apps -> Update Apps List +* Remove the "Apps" filter and search for "btcpay" +* Click **Activate** button -## Configure Payment Acquirer -* Install BTCPay Module -> Website -> eCommerce -> Payment Acquirers -> BTCPay -* Put your facace. Best option is 'merchant'. -* Put the location as test or live url. Test example url: https://testnet.demo.btcpayserver.org -* Put the Confirmation URL where BTCpay will return after payment. -* Check if you want that Odoo send an email to your buyer after transaction is "Confirmed" -* Put your "Pairing Code" if you want that system get the "Token", after that "Pairing Code" will be deleted and the "Token" will appear in the corresponding field. You must safe the changes in order that this happens. NOTE: if you want to get new "Token" throw new "Pairing Code", please remove the "Token" field. Keep in mind that "Token" field must be in blank if you want to get throw the API. -* Put your "Token" if you have it and don't want to use Pairing Code to get it. Remember, if you want to get throw API please don't write anything here. -* If you have a Private Key you can write here otherwise system will get when you safe the Payment Acquirer -* Remember to Publish On Website +## Configure BTCPay as payment provider +* Go to **Website** -> **Configuration** -> **Payment Providers** +* Search for BTCPay and click on button **Activate** -![Payment Acquirer](/payment_btcpay/static/description/BTCPayPaymentAcquirer.png) +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" + * Public Key: leave empty + * Click on "Request Pairing" button, on next page click "Approve" button + * At the top copy the code next to "Server initiated pairing code", e.g. "hg7z8wN" +* Back in Odoo, paste the code into "Pairing Code" field +* Hit Tab key on your keyboard (or click on another field) and the pairing process will start automatically +* When the pairing is successful the "Token" and "Private Key" field will be filled automatically +* Field Facade, keep default 'merchant'. -## How it looks like? +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 -In payment webpage where payment methods appear, you will find new payment method called BTCPay. If you click on it you will be redirect to the server that you indicate in location field. +![Payment Provider Settings](../payment_btcpay/static/description/BTCPayPaymentSettings.png) -![Payment Acquirer](/payment_btcpay/static/description/BTCPayLooksLike.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) ## Transaction BTCPay Details @@ -31,4 +52,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_btcpay/static/description/BtcpayTxDetails.png) diff --git a/payment_btcpay/__manifest__.py b/payment_btcpay/__manifest__.py index 3572a94..5773280 100644 --- a/payment_btcpay/__manifest__.py +++ b/payment_btcpay/__manifest__.py @@ -21,25 +21,25 @@ { 'name': 'Payment Provider: BTCPay', - 'summary': 'This module integrates BTCPAY - pay with Bitcoin - with Odoo v16.0', 'author': 'Vandekul', 'website': 'https://github.com/btcpayserver/odoo', 'category': 'Accounting/Payment Providers', - 'version': '16.0', + 'version': '16.0.0', 'license': 'GPL-3', - 'price':'100', 'application': False, 'installable': True, 'auto_install': False, - 'depends': ['base', 'payment'], + 'depends': ['base', 'account', 'payment'], 'data': [ 'views/payment_btcpay_templates.xml', 'views/payment_provider_views.xml', 'views/payment_transaction_views.xml', 'data/payment_provider_data.xml', ], - + 'external_dependencies': { + 'python': ['btcpay-python'] + }, 'post_init_hook': 'post_init_hook', 'uninstall_hook': 'uninstall_hook', } \ No newline at end of file diff --git a/payment_btcpay/controllers/main.py b/payment_btcpay/controllers/main.py index d0cbb1d..7e941cc 100644 --- a/payment_btcpay/controllers/main.py +++ b/payment_btcpay/controllers/main.py @@ -41,9 +41,9 @@ _logger = logging.getLogger(__name__) class BTCPayController(http.Controller): _checkout_url = '/btcpay/checkout' - _notify_url = 'payment/btcpay/ipn' + _notify_url = '/payment/btcpay/ipn' - @http.route(_checkout_url, type='http', auth='public', csrf=False, webiste=True) + @http.route(_checkout_url, type='http', auth='public', csrf=False, website=True) def checkout(self, **data): _logger.info("CHECKOUT: notification received from BTCPay with data:\n%s", pprint.pformat(data)) @@ -69,7 +69,7 @@ class BTCPayController(http.Controller): _logger.info('Invoice %s \n NOTIFY URL: %s', invoice, notificationURL) return werkzeug.utils.redirect(invoice['url']) - @http.route('/payment/btcpay/ipn', type='json', auth='public', csrf=False) + @http.route(_notify_url, type='json', auth='public', csrf=False) def btcpay_ipn(self, **post): """ BTCPay IPN. """ _logger.info('BTCPAY IPN RECEIVED... ') @@ -95,5 +95,5 @@ class BTCPayController(http.Controller): # Handle the notification data tx_sudo._handle_notification_data('btcpay', notification_data) except ValidationError: # Acknowledge the notification to avoid getting spammed - _logger.exception("unable to handle the notification data; skipping to acknowledge") + _logger.exception("Unable to handle the notification data; skipping to acknowledge") return '' diff --git a/payment_btcpay/data/payment_provider_data.xml b/payment_btcpay/data/payment_provider_data.xml index eaccc4f..78e7bfe 100644 --- a/payment_btcpay/data/payment_provider_data.xml +++ b/payment_btcpay/data/payment_provider_data.xml @@ -1,11 +1,13 @@ + - BTCPay + BTCPay payments + Pay with Bitcoin / Lightning Network btcpay - + \ No newline at end of file diff --git a/payment_btcpay/models/payment_provider.py b/payment_btcpay/models/payment_provider.py index 1c07d2e..c5455d3 100644 --- a/payment_btcpay/models/payment_provider.py +++ b/payment_btcpay/models/payment_provider.py @@ -13,14 +13,14 @@ class PaymentProvider(models.Model): code = fields.Selection( selection_add=[('btcpay', "BTCPay")], ondelete={'btcpay': 'set default'}) - btcpay_location = fields.Char(string='Location', size=64, 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_token = fields.Char(string='Token', help='Access Token to BTCPay') - btcpay_privateKey = fields.Text(string='Private Key', help='Private Key for BTCPay Client') - btcpay_facade = fields.Char(string='Facade', help='Token facade type: merchant/pos/payroll', default='merchant') #merchant + 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.') + btcpay_privateKey = fields.Text(string='Private Key', help='Private Key for BTCPay Client. Leave empty, will be autogenerated during pairing.') + 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': values_list['btcpay_privateKey'] = crypto.generate_privakey() diff --git a/payment_btcpay/models/payment_transaction.py b/payment_btcpay/models/payment_transaction.py index 76aea38..45074a9 100644 --- a/payment_btcpay/models/payment_transaction.py +++ b/payment_btcpay/models/payment_transaction.py @@ -105,7 +105,7 @@ class PaymentTransaction(models.Model): if self.provider_code != 'btcpay': return - #_logger.info("_process_notification_data %s", pprint.pformat(notification_data)) + _logger.info("_process_notification_data %s", pprint.pformat(notification_data)) txn_id = notification_data.get('reference') if not all(txn_id): raise ValidationError( diff --git a/payment_btcpay/requirements.txt b/payment_btcpay/requirements.txt new file mode 100644 index 0000000..eeda1dc --- /dev/null +++ b/payment_btcpay/requirements.txt @@ -0,0 +1 @@ +btcpay-python \ No newline at end of file diff --git a/payment_btcpay/static/description/BTCPayPaymentAcquirer.png b/payment_btcpay/static/description/BTCPayPaymentAcquirer.png deleted file mode 100644 index 96f4be8..0000000 Binary files a/payment_btcpay/static/description/BTCPayPaymentAcquirer.png and /dev/null differ diff --git a/payment_btcpay/static/description/BTCPayPaymentSettings.png b/payment_btcpay/static/description/BTCPayPaymentSettings.png new file mode 100644 index 0000000..8a2dfcc Binary files /dev/null and b/payment_btcpay/static/description/BTCPayPaymentSettings.png differ diff --git a/payment_btcpay/static/description/Btcpay_com.png b/payment_btcpay/static/description/BTCPayServer_org.png similarity index 100% rename from payment_btcpay/static/description/Btcpay_com.png rename to payment_btcpay/static/description/BTCPayServer_org.png diff --git a/payment_btcpay/static/description/index.html b/payment_btcpay/static/description/index.html index 5a91406..cb97259 100644 --- a/payment_btcpay/static/description/index.html +++ b/payment_btcpay/static/description/index.html @@ -7,7 +7,7 @@

This is the module to connect Odoo 16.0 and Btcpay

- +
@@ -37,7 +37,7 @@
- +
diff --git a/payment_btcpay/views/payment_provider_views.xml b/payment_btcpay/views/payment_provider_views.xml index 2b6c966..d2c3646 100644 --- a/payment_btcpay/views/payment_provider_views.xml +++ b/payment_btcpay/views/payment_provider_views.xml @@ -10,11 +10,12 @@ - + + + -