Merge branch '9.0' of github.com:zynthian/addons-vandekul into 9.0
This commit is contained in:
@@ -48,37 +48,42 @@ class BtcpayController(http.Controller):
|
|||||||
@http.route('/payment/btcpay/ipn', type='json', auth='public', methods=['POST'], csrf=False)
|
@http.route('/payment/btcpay/ipn', type='json', auth='public', methods=['POST'], csrf=False)
|
||||||
def btcpay_ipn(self, **post):
|
def btcpay_ipn(self, **post):
|
||||||
""" BTCPay IPN. """
|
""" BTCPay IPN. """
|
||||||
_logger.info('IPN!!!')
|
|
||||||
|
_logger.info('BTCPAY IPN RECEIVED...')
|
||||||
cr, uid, context, env = request.cr, SUPERUSER_ID, request.context, request.env
|
cr, uid, context, env = request.cr, SUPERUSER_ID, request.context, request.env
|
||||||
acquirer = env['payment.acquirer'].search([('provider', '=', 'btcpay')])
|
acquirer = env['payment.acquirer'].search([('provider', '=', 'btcpay')])
|
||||||
try:
|
try:
|
||||||
#_logger.info('IPN3!!!%s',pprint.pformat(request.jsonrequest['data']['id']))
|
#for k in request.jsonrequest['data']:
|
||||||
|
# _logger.info('\t%s => %s', k, request.jsonrequest['data'][k])
|
||||||
invoiceId = request.jsonrequest['data']['id']
|
invoiceId = request.jsonrequest['data']['id']
|
||||||
_logger.info('Invoice ID: %s', invoiceId)
|
invoiceStatus = request.jsonrequest['data']['status']
|
||||||
client = BTCPayClient(host=acquirer.location, pem=acquirer.privateKey, tokens=acquirer.token)
|
orderId = request.jsonrequest['data']['orderId']
|
||||||
self.invoice = client.get_invoice(invoiceId)
|
_logger.info('Invoice ID %s => %s (Order ID %s)', invoiceId, invoiceStatus, orderId)
|
||||||
#_logger.info('SELF INVOICE IPN %s',pprint.pformat(self.invoice))
|
|
||||||
|
|
||||||
tx = None
|
#client = BTCPayClient(host=acquirer.location, pem=acquirer.privateKey, tokens=acquirer.token)
|
||||||
if self.invoice['orderId']:
|
#self.invoice = client.get_invoice(invoiceId)
|
||||||
tx_ids = request.registry['payment.transaction'].search(cr, uid, [('reference', '=', self.invoice['orderId'])], context=context)
|
#_logger.info('SELF INVOICE IPN %s',self.invoice)
|
||||||
|
|
||||||
|
if invoiceId and orderId:
|
||||||
|
tx_ids = request.registry['payment.transaction'].search(cr, uid, [('reference', '=', orderId)], context=context)
|
||||||
if tx_ids:
|
if tx_ids:
|
||||||
tx = request.registry['payment.transaction'].browse(cr, uid, tx_ids[0], context=context)
|
tx = request.registry['payment.transaction'].browse(cr, uid, tx_ids[0], context=context)
|
||||||
|
|
||||||
tx.btcpay_status = self.invoice['status']
|
tx.btcpay_status = invoiceStatus
|
||||||
if self.invoice['status'] in ['confirmed']:
|
if invoiceStatus in ['confirmed']:
|
||||||
tx.state = 'done'
|
tx.state = 'done'
|
||||||
tx.sale_order_id.state = 'sale'
|
tx.sale_order_id.state = 'sale'
|
||||||
if not tx.btcpay_buyerMailNotification and acquirer.buyerNotification:
|
if not tx.btcpay_buyerMailNotification and acquirer.buyerNotification:
|
||||||
tx.sale_order_id.force_quotation_send()
|
tx.sale_order_id.force_quotation_send()
|
||||||
tx.btcpay_buyerMailNotification = "Send"
|
tx.btcpay_buyerMailNotification = "Send"
|
||||||
tx.sale_order_id.order_line._action_procurement_create()
|
tx.sale_order_id.order_line._action_procurement_create()
|
||||||
elif self.invoice['status'] in ['paid']:
|
elif invoiceStatus in ['paid']:
|
||||||
tx.state = 'pending'
|
tx.state = 'pending'
|
||||||
tx.btcpay_invoiceId =self.invoice['id']
|
tx.btcpay_invoiceId = invoiceId
|
||||||
tx.btcpay_txid =((((self.invoice['cryptoInfo'])[0])['payments'])[0])['id']
|
tx.btcpay_txid = request.jsonrequest['data']['url']
|
||||||
except:
|
|
||||||
pass
|
except Exception as e:
|
||||||
|
_logger.error(e)
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
|
|
||||||
@@ -110,3 +115,4 @@ class BtcpayController(http.Controller):
|
|||||||
invoiceId = dict(acquirer.invoice)['id']
|
invoiceId = dict(acquirer.invoice)['id']
|
||||||
self.invoice = client.get_invoice(invoiceId)
|
self.invoice = client.get_invoice(invoiceId)
|
||||||
return werkzeug.utils.redirect(self.invoice['url'])
|
return werkzeug.utils.redirect(self.invoice['url'])
|
||||||
|
|
||||||
|
|||||||
@@ -23,14 +23,14 @@
|
|||||||
<openerp>
|
<openerp>
|
||||||
<data noupdate="1">
|
<data noupdate="1">
|
||||||
<record id="payment_acquirer_btcpay" model="payment.acquirer">
|
<record id="payment_acquirer_btcpay" model="payment.acquirer">
|
||||||
<field name="name">Btcpay</field>
|
<field name="name">BTCPay</field>
|
||||||
<field name="image" type="base64" file="payment_btcpay/static/description/icon.png"/>
|
<field name="image" type="base64" file="payment_btcpay/static/description/icon.png"/>
|
||||||
<field name="provider">btcpay</field>
|
<field name="provider">BTCPay</field>
|
||||||
<field name="company_id" ref="base.main_company"/>
|
<field name="company_id" ref="base.main_company"/>
|
||||||
<field name="view_template_id" ref="btcpay_acquirer_form"/>
|
<field name="view_template_id" ref="btcpay_acquirer_form"/>
|
||||||
<field name="environment">test</field>
|
<field name="environment">test</field>
|
||||||
<field name="pre_msg"><![CDATA[
|
<field name="pre_msg"><![CDATA[
|
||||||
<p>You will be redirected to BTCPay website after clicking on the payment button.</p>]]></field>
|
<p><br>You will be redirected to BTCPay website after clicking on the payment button.</p>]]></field>
|
||||||
</record>
|
</record>
|
||||||
</data>
|
</data>
|
||||||
</openerp>
|
</openerp>
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 9.5 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 23 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 10 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 4.7 KiB |
@@ -0,0 +1 @@
|
|||||||
|
Bitcoin-Lightning-Network.png
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 4.7 KiB |
@@ -44,3 +44,4 @@
|
|||||||
</template>
|
</template>
|
||||||
</data>
|
</data>
|
||||||
</openerp>
|
</openerp>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user