lingo: handle ACCEPTED payments as being paid (#19934)
This commit is contained in:
parent
9549c472a6
commit
9697bc9c7c
|
@ -56,14 +56,16 @@ class TransactionListView(ListView):
|
|||
paginate_by = 10
|
||||
|
||||
def get_queryset(self):
|
||||
return Transaction.objects.filter(status=eopayment.PAID).order_by('-start_date')
|
||||
return Transaction.objects.filter(
|
||||
status__in=(eopayment.PAID, eopayment.ACCEPTED)).order_by('-start_date')
|
||||
|
||||
|
||||
def download_transactions_csv(request):
|
||||
response = HttpResponse(content_type='text/csv')
|
||||
response['Content-Disposition'] = 'attachment; filename="transactions.csv"'
|
||||
writer = csv.writer(response)
|
||||
transactions = Transaction.objects.filter(status=eopayment.PAID).order_by('-start_date')
|
||||
transactions = Transaction.objects.filter(
|
||||
status__in=(eopayment.PAID, eopayment.ACCEPTED)).order_by('-start_date')
|
||||
for transaction in transactions:
|
||||
row = [transaction.order_id,
|
||||
transaction.bank_transaction_id,
|
||||
|
|
|
@ -236,7 +236,8 @@ class BasketItem(models.Model):
|
|||
url = self.source_url + 'jump/trigger/%s' % status
|
||||
message = {'result': 'ok'}
|
||||
if status == 'paid':
|
||||
transaction = self.transaction_set.filter(status=eopayment.PAID)[0]
|
||||
transaction = self.transaction_set.filter(
|
||||
status__in=(eopayment.ACCEPTED, eopayment.PAID))[0]
|
||||
message['transaction_id'] = transaction.id
|
||||
message['order_id'] = transaction.order_id
|
||||
message['bank_transaction_id'] = transaction.bank_transaction_id
|
||||
|
@ -322,12 +323,13 @@ class Transaction(models.Model):
|
|||
return _('Anonymous User')
|
||||
|
||||
def is_paid(self):
|
||||
return self.status == eopayment.PAID
|
||||
return self.status in (eopayment.PAID, eopayment.ACCEPTED)
|
||||
|
||||
def get_status_label(self):
|
||||
return {
|
||||
0: _('Running'),
|
||||
eopayment.PAID: _('Paid'),
|
||||
eopayment.ACCEPTED: _('Paid (accepted)'),
|
||||
eopayment.CANCELLED: _('Cancelled'),
|
||||
EXPIRED: _('Expired')
|
||||
}.get(self.status) or _('Unknown')
|
||||
|
|
|
@ -415,6 +415,11 @@ class CallbackView(View):
|
|||
logger.info(u'received known payment response with id %s',
|
||||
smart_text(payment_response.order_id), extra=extra_info)
|
||||
|
||||
if transaction.status and transaction.status != payment_response.result:
|
||||
logger.warning(u'received payment notification on existing transaction '
|
||||
'(status: %s, new status: %s)' % (
|
||||
transaction.status, payment_response.result))
|
||||
|
||||
transaction.status = payment_response.result
|
||||
transaction.bank_transaction_id = payment_response.transaction_id
|
||||
transaction.bank_data = payment_response.bank_data
|
||||
|
@ -425,7 +430,7 @@ class CallbackView(View):
|
|||
if not transaction.regie == regie:
|
||||
return HttpResponseBadRequest('Invalid payment regie')
|
||||
|
||||
if payment_response.result != eopayment.PAID:
|
||||
if payment_response.result not in (eopayment.PAID, eopayment.ACCEPTED):
|
||||
return HttpResponse()
|
||||
|
||||
transaction.items.update(payment_date=transaction.end_date)
|
||||
|
@ -476,7 +481,7 @@ class ReturnView(View):
|
|||
'failed to provide a correct answer.'))
|
||||
return HttpResponseRedirect(get_basket_url())
|
||||
|
||||
if payment_response.result == eopayment.PAID:
|
||||
if payment_response.result in (eopayment.PAID, eopayment.ACCEPTED):
|
||||
messages.info(request, regie.get_text_on_success())
|
||||
|
||||
transaction = Transaction.objects.get(order_id=payment_response.order_id)
|
||||
|
|
Loading…
Reference in New Issue