Example #1
0
def paypal_setup_check(request, addon_id, addon, webapp):
    if not addon.paypal_id:
        return {"valid": False, "message": ["No PayPal email."]}

    check = Check(addon=addon)
    check.all()
    return {"valid": check.passed, "message": check.errors}
Example #2
0
def paypal_setup_check(request, addon_id, addon, webapp):
    if not addon.paypal_id:
        return {'valid': False, 'message': ['No PayPal email.']}

    check = Check(addon=addon)
    check.all()
    return {'valid': check.passed, 'message': check.errors}
Example #3
0
def paypal_setup_check(request, addon_id, addon, webapp):
    if not addon.paypal_id:
        return {'valid': False, 'message': ['No PayPal email.']}

    check = Check(addon=addon)
    check.all()
    return {'valid': check.passed, 'message': check.errors}
Example #4
0
 def test_check_paykey_fails(self, get_paykey):
     premium = self.addon.premium
     for cr in ['USD', 'NaN']:
         self.check = Check(addon=self.addon)
         premium.supported_currencies.return_value = ([cr, self.usd],)
         get_paykey.side_effect = PaypalError()
         self.check.check_currencies()
         assert not self.check.passed, self.check.state
         eq_(self.check.errors,
             ['Failed to make a test transaction in %s.' % cr])
Example #5
0
def paypal_setup_check(request, addon_id, addon, webapp):
    if waffle.flag_is_active(request, 'solitude-payments'):
        data = client.post_account_check(data={'seller': addon})
        return {'valid': data['passed'], 'message': data['errors']}
    else:
        if not addon.paypal_id:
            return {'valid': False, 'message': ['No PayPal email.']}

        check = Check(addon=addon)
        check.all()
        return {'valid': check.passed, 'message': check.errors}
Example #6
0
def paypal_setup_check(request, addon_id, addon, webapp):
    if waffle.flag_is_active(request, "solitude-payments"):
        data = client.post_account_check(data={"seller": addon})
        return {"valid": data["passed"], "message": data["errors"]}
    else:
        if not addon.paypal_id:
            return {"valid": False, "message": ["No PayPal email."]}

        check = Check(addon=addon)
        check.all()
        return {"valid": check.passed, "message": check.errors}
Example #7
0
 def setUp(self):
     self.addon = Mock()
     self.addon.paypal_id = '*****@*****.**'
     self.addon.premium.paypal_permission_token = 'foo'
     self.addon.premium.price.price = Decimal('1.00')
     self.addon.premium.price._currencies = {}
     self.usd = Mock()
     self.usd.price = Decimal('1.0')
     self.currency = Mock()
     self.currency.currency = 'EUR'
     self.currency.price = Decimal('0.5')
     self.check = Check(addon=self.addon)
Example #8
0
 def setUp(self):
     self.addon = Mock()
     self.addon.paypal_id = '*****@*****.**'
     self.addon.premium.paypal_permission_token = 'foo'
     self.addon.premium.price.price = Decimal('1.00')
     self.addon.premium.price._currencies = {}
     self.usd = Mock()
     self.usd.price = Decimal('1.0')
     self.currency = Mock()
     self.currency.currency = 'EUR'
     self.currency.price = Decimal('0.5')
     self.addon.premium.supported_currencies.return_value = (
             ['USD', self.usd], ['EUR', self.currency])
     self.check = Check(addon=self.addon)
Example #9
0
 def setUp(self):
     self.addon = Mock()
     self.addon.paypal_id = '*****@*****.**'
     self.addon.premium.paypal_permission_token = 'foo'
     self.addon.premium.price.price = Decimal('1.00')
     self.addon.premium.price._currencies = {}
     self.currency = Mock()
     self.currency.currency = 'EUR'
     self.currency.price = Decimal('0.5')
     self.check = Check(addon=self.addon)
Example #10
0
 def setUp(self):
     self.addon = Mock()
     self.addon.paypal_id = "*****@*****.**"
     self.addon.premium.paypal_permission_token = "foo"
     self.addon.premium.price.price = Decimal("1.00")
     self.addon.premium.price._currencies = {}
     self.currency = Mock()
     self.currency.currency = "EUR"
     self.currency.price = Decimal("0.5")
     self.check = Check(addon=self.addon)
Example #11
0
class TestCheck(amo.tests.TestCase):

    def setUp(self):
        self.addon = Mock()
        self.addon.paypal_id = '*****@*****.**'
        self.addon.premium.paypal_permission_token = 'foo'
        self.addon.premium.price.price = Decimal('1.00')
        self.addon.premium.price._currencies = {}
        self.usd = Mock()
        self.usd.price = Decimal('1.0')
        self.currency = Mock()
        self.currency.currency = 'EUR'
        self.currency.price = Decimal('0.5')
        self.check = Check(addon=self.addon)

    def test_uses_addon(self):
        self.check = Check(addon=self.addon)
        eq_(self.check.paypal_id, self.addon.paypal_id)
        self.check = Check(addon=self.addon, paypal_id='*****@*****.**')
        eq_(self.check.paypal_id, '*****@*****.**')

    @patch('paypal.check_paypal_id')
    def test_check_id_pass(self, check_paypal_id):
        check_paypal_id.return_value = True, ''
        self.check.check_id()
        assert self.check.passed, self.check.state

    @patch('paypal.check_paypal_id')
    def test_check_id_fail(self, check_paypal_id):
        check_paypal_id.return_value = False, ''
        self.check.check_id()
        assert not self.check.passed, self.check.state

    def test_check_id_none(self):
        self.check.paypal_id = None
        self.check.check_id()
        assert not self.check.passed, self.check.state
Example #12
0
class TestCheck(amo.tests.TestCase):
    def setUp(self):
        self.addon = Mock()
        self.addon.paypal_id = '*****@*****.**'
        self.addon.premium.paypal_permission_token = 'foo'
        self.addon.premium.price.price = Decimal('1.00')
        self.addon.premium.price._currencies = {}
        self.usd = Mock()
        self.usd.price = Decimal('1.0')
        self.currency = Mock()
        self.currency.currency = 'EUR'
        self.currency.price = Decimal('0.5')
        self.check = Check(addon=self.addon)

    def test_uses_addon(self):
        self.check = Check(addon=self.addon)
        eq_(self.check.paypal_id, self.addon.paypal_id)
        self.check = Check(addon=self.addon, paypal_id='*****@*****.**')
        eq_(self.check.paypal_id, '*****@*****.**')

    @patch('paypal.check_paypal_id')
    def test_check_id_pass(self, check_paypal_id):
        check_paypal_id.return_value = True, ''
        self.check.check_id()
        assert self.check.passed, self.check.state

    @patch('paypal.check_paypal_id')
    def test_check_id_fail(self, check_paypal_id):
        check_paypal_id.return_value = False, ''
        self.check.check_id()
        assert not self.check.passed, self.check.state

    def test_check_id_none(self):
        self.check.paypal_id = None
        self.check.check_id()
        assert not self.check.passed, self.check.state
Example #13
0
 def test_uses_addon(self):
     self.check = Check(addon=self.addon)
     eq_(self.check.paypal_id, self.addon.paypal_id)
     self.check = Check(addon=self.addon, paypal_id='*****@*****.**')
     eq_(self.check.paypal_id, '*****@*****.**')
Example #14
0
class TestCheck(amo.tests.TestCase):

    def setUp(self):
        self.addon = Mock()
        self.addon.paypal_id = '*****@*****.**'
        self.addon.premium.paypal_permission_token = 'foo'
        self.addon.premium.price.price = Decimal('1.00')
        self.addon.premium.price._currencies = {}
        self.usd = Mock()
        self.usd.price = Decimal('1.0')
        self.currency = Mock()
        self.currency.currency = 'EUR'
        self.currency.price = Decimal('0.5')
        self.addon.premium.supported_currencies.return_value = (
                ['USD', self.usd], ['EUR', self.currency])
        self.check = Check(addon=self.addon)

    def test_uses_addon(self):
        self.check = Check(addon=self.addon)
        eq_(self.check.paypal_id, self.addon.paypal_id)
        self.check = Check(addon=self.addon, paypal_id='*****@*****.**')
        eq_(self.check.paypal_id, '*****@*****.**')

    @patch('paypal.check_paypal_id')
    def test_check_id_pass(self, check_paypal_id):
        check_paypal_id.return_value = True, ''
        self.check.check_id()
        assert self.check.passed, self.check.state

    @patch('paypal.check_paypal_id')
    def test_check_id_fail(self, check_paypal_id):
        check_paypal_id.return_value = False, ''
        self.check.check_id()
        assert not self.check.passed, self.check.state

    def test_check_id_none(self):
        self.check.paypal_id = None
        self.check.check_id()
        assert not self.check.passed, self.check.state

    @patch('paypal.get_paykey')
    def test_check_paykey(self, get_paykey):
        self.check.check_currencies()
        eq_(get_paykey.call_args_list[0][0][0]['currency'], 'USD')
        eq_(get_paykey.call_args_list[1][0][0]['currency'], 'EUR')
        assert self.check.passed, self.check.state

    @patch('paypal.get_paykey')
    def test_check_paykey_no_premium(self, get_paykey):
        self.addon.premium = None
        self.check.check_currencies()
        eq_(len(get_paykey.call_args_list), 1)
        assert self.check.passed, self.check.state

    @patch('paypal.get_paykey')
    def test_check_paykey_currencies(self, get_paykey):
        self.check.check_currencies()
        eq_(len(get_paykey.call_args_list), 2)
        eq_([c[0][0]['currency'] for c in get_paykey.call_args_list],
            ['USD', 'EUR'])
        assert self.check.passed, self.check.state

    @patch('paypal.get_paykey')
    def test_check_price_none(self, get_paykey):
        self.addon.premium.price = None
        self.check.check_currencies()
        eq_(len(get_paykey.call_args_list), 1)
        eq_(get_paykey.call_args[0][0]['amount'], '1.00')

    @patch('paypal.get_paykey')
    def test_check_paykey_fails(self, get_paykey):
        premium = self.addon.premium
        for cr in ['USD', 'NaN']:
            self.check = Check(addon=self.addon)
            premium.supported_currencies.return_value = ([cr, self.usd],)
            get_paykey.side_effect = PaypalError()
            self.check.check_currencies()
            assert not self.check.passed, self.check.state
            eq_(self.check.errors,
                ['Failed to make a test transaction in %s.' % cr])
Example #15
0
class TestCheck(amo.tests.TestCase):
    def setUp(self):
        self.addon = Mock()
        self.addon.paypal_id = "*****@*****.**"
        self.addon.premium.paypal_permission_token = "foo"
        self.addon.premium.price.price = Decimal("1.00")
        self.addon.premium.price._currencies = {}
        self.currency = Mock()
        self.currency.currency = "EUR"
        self.currency.price = Decimal("0.5")
        self.check = Check(addon=self.addon)

    def test_uses_addon(self):
        self.check = Check(addon=self.addon)
        eq_(self.check.paypal_id, self.addon.paypal_id)
        self.check = Check(addon=self.addon, paypal_id="*****@*****.**")
        eq_(self.check.paypal_id, "*****@*****.**")

    @patch("paypal.check_paypal_id")
    def test_check_id_pass(self, check_paypal_id):
        check_paypal_id.return_value = True, ""
        self.check.check_id()
        assert self.check.passed, self.check.state

    @patch("paypal.check_paypal_id")
    def test_check_id_fail(self, check_paypal_id):
        check_paypal_id.return_value = False, ""
        self.check.check_id()
        assert not self.check.passed, self.check.state

    def test_check_id_none(self):
        self.check.paypal_id = None
        self.check.check_id()
        assert not self.check.passed, self.check.state

    @patch("paypal.check_permission")
    def test_check_refund(self, check_permission):
        check_permission.return_value = True
        self.check.check_refund()
        assert self.check.passed, self.check.state

    @patch("paypal.check_permission")
    def test_check_refund_fails(self, check_permission):
        check_permission.return_value = False
        self.check.check_refund()
        assert not self.check.passed, self.check.state

    def test_check_refund_no_token(self):
        self.addon.premium.paypal_permission_token = ""
        self.check.check_refund()
        assert not self.check.passed, self.check.state

    def test_check_refund_no_premium(self):
        self.addon.premium = None
        self.check.check_refund()
        assert not self.check.passed, self.check.state

    @patch("paypal.get_paykey")
    def test_check_paykey(self, get_paykey):
        self.check.check_currencies()
        eq_(get_paykey.call_args[0][0]["currency"], "USD")
        assert self.check.passed, self.check.state

    @patch("paypal.get_paykey")
    def test_check_paykey_no_premium(self, get_paykey):
        self.addon.premium = None
        self.check.check_currencies()
        eq_(len(get_paykey.call_args_list), 1)
        assert self.check.passed, self.check.state

    @patch("paypal.get_paykey")
    def test_check_paykey_currencies(self, get_paykey):
        self.addon.premium.price._currencies = {(u"EUR", self.addon.premium.price.id): self.currency}
        self.check.check_currencies()
        eq_(len(get_paykey.call_args_list), 2)
        eq_([c[0][0]["currency"] for c in get_paykey.call_args_list], ["USD", "EUR"])
        assert self.check.passed, self.check.state

    @patch("paypal.get_paykey")
    def test_check_price_none(self, get_paykey):
        self.addon.premium.price = None
        self.check.check_currencies()
        eq_(len(get_paykey.call_args_list), 1)
        eq_(get_paykey.call_args[0][0]["amount"], "1.00")

    @patch("paypal.get_paykey")
    def test_check_paykey_fails(self, get_paykey):
        get_paykey.side_effect = PaypalError()
        self.check.check_currencies()
        assert not self.check.passed, self.check.state
        eq_(self.check.errors, ["Failed to make a test transaction in USD."])