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)
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')
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))
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']
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)
def test_check_refund_permission_settings(self, _call): settings.PAYPAL_PERMISSIONS_URL = '' assert not paypal.check_refund_permission('oh-noes')
def test_check_refund_permission_fail(self, _call): _call.side_effect = paypal.PaypalError assert not paypal.check_refund_permission('oh-noes')