Projet

Général

Profil

0001-lingo-handle-ACCEPTED-payments-as-being-paid-19934.patch

Frédéric Péters, 15 novembre 2017 07:46

Télécharger (4,45 ko)

Voir les différences:

Subject: [PATCH] lingo: handle ACCEPTED payments as being paid (#19934)

 combo/apps/lingo/manager_views.py | 6 ++++--
 combo/apps/lingo/models.py        | 6 ++++--
 combo/apps/lingo/views.py         | 9 +++++++--
 3 files changed, 15 insertions(+), 6 deletions(-)
combo/apps/lingo/manager_views.py
56 56
    paginate_by = 10
57 57

  
58 58
    def get_queryset(self):
59
        return Transaction.objects.filter(status=eopayment.PAID).order_by('-start_date')
59
        return Transaction.objects.filter(
60
                status__in=(eopayment.PAID, eopayment.ACCEPTED)).order_by('-start_date')
60 61

  
61 62

  
62 63
def download_transactions_csv(request):
63 64
    response = HttpResponse(content_type='text/csv')
64 65
    response['Content-Disposition'] = 'attachment; filename="transactions.csv"'
65 66
    writer = csv.writer(response)
66
    transactions = Transaction.objects.filter(status=eopayment.PAID).order_by('-start_date')
67
    transactions = Transaction.objects.filter(
68
            status__in=(eopayment.PAID, eopayment.ACCEPTED)).order_by('-start_date')
67 69
    for transaction in transactions:
68 70
        row = [transaction.order_id,
69 71
               transaction.bank_transaction_id,
combo/apps/lingo/models.py
236 236
        url = self.source_url + 'jump/trigger/%s' % status
237 237
        message = {'result': 'ok'}
238 238
        if status == 'paid':
239
            transaction = self.transaction_set.filter(status=eopayment.PAID)[0]
239
            transaction = self.transaction_set.filter(
240
                    status__in=(eopayment.ACCEPTED, eopayment.PAID))[0]
240 241
            message['transaction_id'] = transaction.id
241 242
            message['order_id'] = transaction.order_id
242 243
            message['bank_transaction_id'] = transaction.bank_transaction_id
......
322 323
        return _('Anonymous User')
323 324

  
324 325
    def is_paid(self):
325
        return self.status == eopayment.PAID
326
        return self.status in (eopayment.PAID, eopayment.ACCEPTED)
326 327

  
327 328
    def get_status_label(self):
328 329
        return {
329 330
            0: _('Running'),
330 331
            eopayment.PAID: _('Paid'),
332
            eopayment.ACCEPTED: _('Paid'),
331 333
            eopayment.CANCELLED: _('Cancelled'),
332 334
            EXPIRED: _('Expired')
333 335
        }.get(self.status) or _('Unknown')
combo/apps/lingo/views.py
415 415
            logger.info(u'received known payment response with id %s',
416 416
                           smart_text(payment_response.order_id), extra=extra_info)
417 417

  
418
        if transaction.status and transaction.status != payment_response.result:
419
            logger.warning(u'received payment notification on existing transaction '
420
                            '(status: %s, new status: %s)' % (
421
                        transaction.status, payment_response.result))
422

  
418 423
        transaction.status = payment_response.result
419 424
        transaction.bank_transaction_id = payment_response.transaction_id
420 425
        transaction.bank_data = payment_response.bank_data
......
425 430
        if not transaction.regie == regie:
426 431
            return HttpResponseBadRequest('Invalid payment regie')
427 432

  
428
        if payment_response.result != eopayment.PAID:
433
        if payment_response.result not in (eopayment.PAID, eopayment.ACCEPTED):
429 434
            return HttpResponse()
430 435

  
431 436
        transaction.items.update(payment_date=transaction.end_date)
......
476 481
                                      'failed to provide a correct answer.'))
477 482
            return HttpResponseRedirect(get_basket_url())
478 483

  
479
        if payment_response.result == eopayment.PAID:
484
        if payment_response.result in (eopayment.PAID, eopayment.ACCEPTED):
480 485
            messages.info(request, regie.get_text_on_success())
481 486

  
482 487
        transaction = Transaction.objects.get(order_id=payment_response.order_id)
483
-