Improvements (#6)
* Add external dependencies to manifest to avoid error on module activation; add requirements.txt. * Readme * Fix errors, restructure settings form, update installation steps, streamline overall. * Change version
This commit is contained in:
+39
-18
@@ -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.
|
||||

|
||||
This module allows you to accept bitcoin (and other cryptocurrency) payments in your Odoo e-commerce store.
|
||||

|
||||
|
||||
## 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**
|
||||
|
||||

|
||||
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.
|
||||

|
||||
|
||||

|
||||
## 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.
|
||||
|
||||

|
||||
|
||||
|
||||
## 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
|
||||
|
||||

|
||||

|
||||
|
||||
@@ -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',
|
||||
}
|
||||
@@ -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 ''
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo noupdate="1">
|
||||
|
||||
<record id="payment_provider_btcpay" model="payment.provider">
|
||||
<field name="name">BTCPay</field>
|
||||
<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="redirect_form_view_id" ref="redirect_form"/>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
@@ -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()
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
btcpay-python
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 740 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 107 KiB |
@@ -7,7 +7,7 @@
|
||||
<h3 class="oe_slogan">This is the module to connect Odoo 16.0 and Btcpay</h3>
|
||||
<div class="oe_span6">
|
||||
<div class="oe_bg_img">
|
||||
<img src="Btcpay_com.png" class="oe_picture oe_screenshot">
|
||||
<img src="BTCPayServer_org.png" class="oe_picture oe_screenshot">
|
||||
</div>
|
||||
</div>
|
||||
<div class="oe_span6">
|
||||
@@ -37,7 +37,7 @@
|
||||
</div>
|
||||
<div class="oe_span6">
|
||||
<div class="oe_bg_img">
|
||||
<img src="BTCPayPaymentAcquirer.png" class="oe_picture oe_screenshot">
|
||||
<img src="BTCPayPaymentSettings.png" class="oe_picture oe_screenshot">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -10,11 +10,12 @@
|
||||
<group attrs="{'invisible': [('code', '!=', 'btcpay')]}">
|
||||
<field name="btcpay_location"/>
|
||||
<field name="btcpay_confirmationURL"/>
|
||||
|
||||
<field name="btcpay_pairingCode"/>
|
||||
</group>
|
||||
<group attrs="{'invisible': [('code', '!=', 'btcpay')]}">
|
||||
<field name="btcpay_token"/>
|
||||
<field name="btcpay_privateKey"/>
|
||||
<field name="btcpay_facade"/>
|
||||
<field name="btcpay_pairingCode"/>
|
||||
</group>
|
||||
</group>
|
||||
</field>
|
||||
|
||||
Reference in New Issue
Block a user