Example #1
0
 def test_check_refund_permission(self, _call):
     """
     `check_paypal_refund_permission` returns True if PayPal
     puts 'REFUND' in the permissions response.
     """
     _call.return_value = {'scope(0)': 'REFUND'}
     eq_(paypal.check_refund_permission('foo'), True)
Example #2
0
 def test_check_refund_permission(self, _call):
     """
     `check_paypal_refund_permission` returns True if PayPal
     puts 'REFUND' in the permissions response.
     """
     _call.return_value = {'scope(0)': 'REFUND'}
     eq_(paypal.check_refund_permission('foo'), True)
Example #3
0
 def test_check_refund_permission_fail(self, _call):
     """
     `check_paypal_refund_permission` returns False if PayPal
     doesn't put 'REFUND' in the permissions response.
     """
     _call.return_value = {'scope(0)': 'HAM_SANDWICH'}
     assert not paypal.check_refund_permission('foo')
Example #4
0
 def test_check_refund_permission_fail(self, _call):
     """
     `check_paypal_refund_permission` returns False if PayPal
     doesn't put 'REFUND' in the permissions response.
     """
     _call.return_value = {'scope(0)': 'HAM_SANDWICH'}
     assert not paypal.check_refund_permission('foo')
Example #5
0
 def has_valid_permissions_token(self):
     """
     Have we got a valid permissions token by ping paypal. If you've got
     'should_ignore_paypal', then it will just happily return True.
     """
     token = self.paypal_permissions_token
     return bool(paypal.should_ignore_paypal() or
                 paypal.check_refund_permission(token))
Example #6
0
    def clean_paypal_id(self):
        if self.addon.premium:
            token = self.addon.premium.paypal_permissions_token
        else:
            raise forms.ValidationError(_('No third party token set up.'))

        if not paypal.check_refund_permission(token):
            raise forms.ValidationError(_('Third party refund not set up.'))
        return self.cleaned_data['paypal_id']
Example #7
0
 def has_valid_permissions_token(self):
     """
     Have we got a valid permissions token by ping paypal. If you've got
     'should_ignore_paypal', then it will just happily return True.
     """
     if paypal.should_ignore_paypal():
         return True
     if not self.paypal_permissions_token:
         return False
     return paypal.check_refund_permission(self.paypal_permissions_token)
Example #8
0
 def has_valid_permissions_token(self):
     """
     Have we got a valid permissions token by ping paypal. If you've got
     'should_ignore_paypal', then it will just happily return True.
     """
     if paypal.should_ignore_paypal():
         return True
     if not self.paypal_permissions_token:
         return False
     return paypal.check_refund_permission(self.paypal_permissions_token)
Example #9
0
 def test_check_refund_permission_settings(self, _call):
     settings.PAYPAL_PERMISSIONS_URL = ''
     assert not paypal.check_refund_permission('oh-noes')
Example #10
0
 def test_check_refund_permission_fail(self, _call):
     _call.side_effect = paypal.PaypalError
     assert not paypal.check_refund_permission('oh-noes')
Example #11
0
 def test_check_refund_permission_settings(self, _call):
     settings.PAYPAL_PERMISSIONS_URL = ''
     assert not paypal.check_refund_permission('oh-noes')
Example #12
0
 def test_check_refund_permission_fail(self, _call):
     _call.side_effect = paypal.PaypalError
     assert not paypal.check_refund_permission('oh-noes')