Modify IPN error
This commit is contained in:
@@ -45,22 +45,23 @@ _logger = logging.getLogger(__name__)
|
|||||||
class BtcpayController(http.Controller):
|
class BtcpayController(http.Controller):
|
||||||
_notify_url = '/payment/btcpay/ipn'
|
_notify_url = '/payment/btcpay/ipn'
|
||||||
|
|
||||||
|
@http.route('/payment/btcpay/ipn', type='json', auth='public', methods=['POST'], csrf=False)
|
||||||
@http.route('/payment/btcpay/ipn', type='json', auth='none')
|
|
||||||
def btcpay_ipn(self, **post):
|
def btcpay_ipn(self, **post):
|
||||||
""" BTCPay IPN. """
|
""" BTCPay IPN. """
|
||||||
|
_logger.info('IPN!!!')
|
||||||
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 = request.env['payment.acquirer'].search([('provider', '=', 'btcpay')])
|
acquirer = env['payment.acquirer'].search([('provider', '=', 'btcpay')])
|
||||||
try:
|
try:
|
||||||
#_logger.info('REQUEST JSONREQUEST %s',pprint.pformat(request.jsonrequest))
|
#_logger.info('IPN3!!!%s',pprint.pformat(request.jsonrequest['data']['id']))
|
||||||
invoiceId = request.jsonrequest['data']['id']
|
invoiceId = request.jsonrequest['data']['id']
|
||||||
client = BTCPayClient(host=acquirer.location, pem=acquirer.privateKey, tokens=acquirer.token)
|
_logger.info('Invoice ID: %s', invoiceId)
|
||||||
|
client = BTCPayClient(host=acquirer.location, pem=acquirer.privateKey, tokens=acquirer.token)
|
||||||
self.invoice = client.get_invoice(invoiceId)
|
self.invoice = client.get_invoice(invoiceId)
|
||||||
#_logger.info('SELF INVOICE IPN %s',pprint.pformat(self.invoice))
|
#_logger.info('SELF INVOICE IPN %s',pprint.pformat(self.invoice))
|
||||||
|
|
||||||
tx = None
|
tx = None
|
||||||
if self.invoice['orderId']:
|
if self.invoice['orderId']:
|
||||||
tx_ids = request.registry['payment.transaction'].search(cr, uid, [('reference', '=', self.invoice['orderId'])], context=context)
|
tx_ids = request.registry['payment.transaction'].search(cr, uid, [('reference', '=', self.invoice['orderId'])], context=contex
|
||||||
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)
|
||||||
|
|
||||||
|
|||||||
@@ -58,4 +58,4 @@ fetched_invoice = client.get_invoice(new_invoice['id'])
|
|||||||
print("FETCHED INVOICE: ", new_invoice['id'])
|
print("FETCHED INVOICE: ", new_invoice['id'])
|
||||||
|
|
||||||
|
|
||||||
curl --no-keepalive --raw --show-error --verbose --connect-timeout 10 --insecure --max-redirs 1 -H "Content-Type: application/json" -d '{"data": "{"id":"P38S4ewSvvLoRrBSoEiMTz"}"}" http://odoo-dev.zynthian.org/payment/btcpay/ipn
|
curl --no-keepalive --raw --show-error --verbose --connect-timeout 10 --insecure --max-redirs 1 -H "Content-Type: application/json" -d '{"data": "{"id":"8vQMp1C6gB1DxUyJB9gcBp"}"}" http://odoo-dev.zynthian.org/payment/btcpay/ipn
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
import requests
|
||||||
|
import json
|
||||||
|
|
||||||
|
url = 'https://odoo-dev.zynthian.org/payment/btcpay/ipn'
|
||||||
|
headers = {'Content-Type': 'application/json'}
|
||||||
|
data = {
|
||||||
|
"data": {
|
||||||
|
"id":"8vQMp1C6gB1DxUyJB9gcBp",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
data_json = json.dumps(data)
|
||||||
|
r = requests.post(url=url, data=data_json, headers=headers)
|
||||||
Reference in New Issue
Block a user