Projet

Général

Profil

0001-lingo-check-response-signature-later-36876.patch

Emmanuel Cazenave, 14 janvier 2020 18:58

Télécharger (2,4 ko)

Voir les différences:

Subject: [PATCH 1/2] lingo: check response signature later (#36876)

 combo/apps/lingo/views.py | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)
combo/apps/lingo/views.py
455 455

  
456 456

  
457 457
class UnsignedPaymentException(PaymentException):
458
    pass
458

  
459
    def __init__(self, transaction, *args, **kwargs):
460
        super(UnsignedPaymentException, self).__init__(*args, **kwargs)
461
        self.transaction = transaction
459 462

  
460 463

  
461 464
class UnknownPaymentException(PaymentException):
......
487 490
        }
488 491
        for k, v in payment_response.bank_data.items():
489 492
            extra_info['eopayment_bank_data_' + k] = smart_text(v)
490
        if not payment_response.signed and not payment_response.result == eopayment.CANCELLED:
491
            # we accept unsigned cancellation requests as some platforms do
492
            # that :/
493
            logger.warning(u'received unsigned payment response with id %s',
494
                           smart_text(payment_response.order_id), extra=extra_info)
495
            raise UnsignedPaymentException('Received unsigned payment response')
496

  
497 493
        try:
498 494
            transaction = Transaction.objects.get(order_id=payment_response.order_id)
499 495
        except Transaction.DoesNotExist:
......
526 522
                                transaction.regie.payment_backend, payment_backend))
527 523
            raise PaymentException('Invalid payment regie')
528 524

  
525
        if not payment_response.signed and not payment_response.result == eopayment.CANCELLED:
526
            # we accept unsigned cancellation requests as some platforms do
527
            # that :/
528
            logger.warning(u'received unsigned payment response with id %s',
529
                           smart_text(payment_response.order_id), extra=extra_info)
530
            raise UnsignedPaymentException(transaction, 'Received unsigned payment response')
531

  
529 532
        transaction.status = payment_response.result
530 533
        transaction.bank_transaction_id = payment_response.transaction_id
531 534
        transaction.bank_data = payment_response.bank_data
532
-