fix coinify callbacks by passing request argument to order.mark_as_paid()

This commit is contained in:
Thomas Steen Rasmussen 2018-07-13 14:38:01 +02:00
parent 9bfdc714f0
commit d3ba04b6f2
2 changed files with 5 additions and 4 deletions

View file

@ -8,7 +8,7 @@ import requests
logger = logging.getLogger("bornhack.%s" % __name__) logger = logging.getLogger("bornhack.%s" % __name__)
def process_coinify_invoice_json(invoicejson, order): def process_coinify_invoice_json(invoicejson, order, request):
# create or update the invoice object in our database # create or update the invoice object in our database
coinifyinvoice, created = CoinifyAPIInvoice.objects.update_or_create( coinifyinvoice, created = CoinifyAPIInvoice.objects.update_or_create(
coinify_id=invoicejson['id'], coinify_id=invoicejson['id'],
@ -20,7 +20,7 @@ def process_coinify_invoice_json(invoicejson, order):
# if the order is paid in full call the mark as paid method now # if the order is paid in full call the mark as paid method now
if invoicejson['state'] == 'complete' and not coinifyinvoice.order.paid: if invoicejson['state'] == 'complete' and not coinifyinvoice.order.paid:
coinifyinvoice.order.mark_as_paid() coinifyinvoice.order.mark_as_paid(request=request)
return coinifyinvoice return coinifyinvoice

View file

@ -562,8 +562,9 @@ class CoinifyCallbackView(SingleObjectMixin, View):
if callbackobject.payload['event'] == 'invoice_state_change' or callbackobject.payload['event'] == 'invoice_manual_resend': if callbackobject.payload['event'] == 'invoice_state_change' or callbackobject.payload['event'] == 'invoice_manual_resend':
process_coinify_invoice_json( process_coinify_invoice_json(
callbackobject.payload['data'], invoicejson=callbackobject.payload['data'],
self.get_object() order=self.get_object(),
request=request,
) )
return HttpResponse('OK') return HttpResponse('OK')
else: else: