diff --git a/payment_paypal/indico_payment_paypal/controllers.py b/payment_paypal/indico_payment_paypal/controllers.py index 82cfdbc..df6c21a 100644 --- a/payment_paypal/indico_payment_paypal/controllers.py +++ b/payment_paypal/indico_payment_paypal/controllers.py @@ -73,10 +73,10 @@ class RHPaypalIPN(RH): data=request.form) def _verify_business(self): - expected = current_plugin.event_settings.get(self.registration.registration_form.event, 'business') - candidates = {request.form.get('business'), - request.form.get('receiver_id'), - request.form.get('receiver_email')} + expected = current_plugin.event_settings.get(self.registration.registration_form.event, 'business').lower() + candidates = {request.form.get('business', '').lower(), + request.form.get('receiver_id', '').lower(), + request.form.get('receiver_email', '').lower()} if expected in candidates: return True current_plugin.logger.warning("Unexpected business: %s not in %r (request data: %r)", expected, candidates, diff --git a/payment_paypal/tests/controllers_test.py b/payment_paypal/tests/controllers_test.py index d011825..5990717 100644 --- a/payment_paypal/tests/controllers_test.py +++ b/payment_paypal/tests/controllers_test.py @@ -28,7 +28,7 @@ def test_ipn_verify_business(formdata, expected, dummy_event): rh = RHPaypalIPN() rh.registration = MagicMock() rh.registration.registration_form.event = dummy_event - PaypalPaymentPlugin.event_settings.set(dummy_event, 'business', 'test') + PaypalPaymentPlugin.event_settings.set(dummy_event, 'business', 'TeST') request.form = formdata with PaypalPaymentPlugin.instance.plugin_context(): assert rh._verify_business() == expected @@ -88,6 +88,7 @@ def test_ipn_process(mocker, fail): mocker.patch('indico_payment_paypal.controllers.notify_amount_inconsistency') post.return_value.text = 'INVALID' if fail == 'verify' else 'VERIFIED' rh = RHPaypalIPN() + rh._verify_business = MagicMock() rh._is_transaction_duplicated = lambda: fail == 'dup_txn' rh.event = MagicMock(id=1) rh.registration = MagicMock()