Пример #1
0
 def test_get_permissions_url(self, _call):
     """
     `paypal_get_permission_url` returns an URL for PayPal's
     permissions request service containing the token PayPal gives
     us.
     """
     _call.return_value = {'token': 'foo'}
     assert 'foo' in paypal.get_permission_url(self.addon, '', [])
Пример #2
0
 def test_get_permissions_url(self, _call):
     """
     `paypal_get_permission_url` returns an URL for PayPal's
     permissions request service containing the token PayPal gives
     us.
     """
     _call.return_value = {"token": "foo"}
     assert "foo" in paypal.get_permission_url(self.addon, "", [])
Пример #3
0
def payments_bounce(request, addon_id, addon):
    paypal_url = paypal.get_permission_url(addon, 'submission', [
        'REFUND', 'ACCESS_BASIC_PERSONAL_DATA', 'ACCESS_ADVANCED_PERSONAL_DATA'
    ])
    return jingo.render(request, 'submit/payments-bounce.html', {
        'step': 'payments',
        'paypal_url': paypal_url,
        'addon': addon
    })
Пример #4
0
 def _show_token_msg(self, message):
     """Display warning for an invalid PayPal refund token."""
     url = paypal.get_permission_url(self.addon,
                                     self.extra.get('dest', 'payment'),
                                     ['REFUND'])
     msg = _(' <a href="%s">Visit PayPal to grant permission'
             ' for refunds on your behalf.</a>') % url
     messages.warning(self.request, '%s %s' % (message, Markup(msg)))
     raise forms.ValidationError(message)
Пример #5
0
def payments_bounce(request, addon_id, addon):
    paypal_url = paypal.get_permission_url(addon, 'submission',
                                           ['REFUND',
                                            'ACCESS_BASIC_PERSONAL_DATA',
                                            'ACCESS_ADVANCED_PERSONAL_DATA'])
    return jingo.render(request, 'submit/payments-bounce.html', {
                        'step': 'payments',
                        'paypal_url': paypal_url,
                        'addon': addon
                        })
Пример #6
0
def paypal_setup_bounce(request, addon_id, addon, webapp):
    if not addon.paypal_id:
        messages.error(request, "We need a PayPal email before continuing.")
        return redirect(addon.get_dev_url("paypal_setup"))
    paypal_url = paypal.get_permission_url(
        addon, "management", ["REFUND", "ACCESS_BASIC_PERSONAL_DATA", "ACCESS_ADVANCED_PERSONAL_DATA"]
    )

    return jingo.render(
        request, "developers/payments/paypal-details-request.html", {"paypal_url": paypal_url, "addon": addon}
    )
Пример #7
0
def paypal_setup_bounce(request, addon_id, addon, webapp):
    if not addon.paypal_id:
        messages.error(request, 'We need a PayPal email before continuing.')
        return redirect(addon.get_dev_url('paypal_setup'))
    paypal_url = paypal.get_permission_url(addon, 'management',
                                        ['REFUND',
                                         'ACCESS_BASIC_PERSONAL_DATA',
                                         'ACCESS_ADVANCED_PERSONAL_DATA'])

    return jingo.render(request,
                        'developers/payments/paypal-details-request.html',
                        {'paypal_url': paypal_url, 'addon': addon})
Пример #8
0
def paypal_setup_bounce(request, addon_id, addon, webapp):
    if not addon.paypal_id:
        messages.error(request, 'We need a PayPal email before continuing.')
        return redirect(addon.get_dev_url('paypal_setup'))
    paypal_url = paypal.get_permission_url(addon, 'management', [
        'REFUND', 'ACCESS_BASIC_PERSONAL_DATA', 'ACCESS_ADVANCED_PERSONAL_DATA'
    ])

    return jingo.render(request,
                        'developers/payments/paypal-details-request.html', {
                            'paypal_url': paypal_url,
                            'addon': addon
                        })
Пример #9
0
def payments_bounce(request, addon_id, addon):
    dest = 'submission'
    perms = ['REFUND', 'ACCESS_BASIC_PERSONAL_DATA',
             'ACCESS_ADVANCED_PERSONAL_DATA']
    if waffle.flag_is_active(request, 'solitude-payments'):
        url = addon.get_dev_url('acquire_refund_permission')
        url = absolutify(urlparams(url, dest=dest))
        result = client.post_permission_url(data={'scope': perms, 'url': url})
        paypal_url = result['token']
    #TODO(solitude): remove these
    else:
        paypal_url = paypal.get_permission_url(addon, dest, perms)

    return jingo.render(request, 'submit/payments-bounce.html', {
                        'step': 'payments',
                        'paypal_url': paypal_url,
                        'addon': addon
                        })
Пример #10
0
def paypal_setup_bounce(request, addon_id, addon, webapp):
    if not addon.paypal_id:
        messages.error(request, "We need a PayPal email before continuing.")
        return redirect(addon.get_dev_url("paypal_setup"))

    dest = "developers"
    perms = ["REFUND", "ACCESS_BASIC_PERSONAL_DATA", "ACCESS_ADVANCED_PERSONAL_DATA"]
    if waffle.flag_is_active(request, "solitude-payments"):
        url = addon.get_dev_url("acquire_refund_permission")
        url = absolutify(urlparams(url, dest=dest))
        result = client.post_permission_url(data={"scope": perms, "url": url})
        paypal_url = result["token"]
    # TODO(solitude): remove this.
    else:
        paypal_url = paypal.get_permission_url(addon, dest, perms)

    return jingo.render(
        request, "developers/payments/paypal-details-request.html", {"paypal_url": paypal_url, "addon": addon}
    )
Пример #11
0
def paypal_setup_bounce(request, addon_id, addon, webapp):
    if not addon.paypal_id:
        messages.error(request, 'We need a PayPal email before continuing.')
        return redirect(addon.get_dev_url('paypal_setup'))

    dest = 'developers'
    perms = ['REFUND', 'ACCESS_BASIC_PERSONAL_DATA',
             'ACCESS_ADVANCED_PERSONAL_DATA']
    if waffle.flag_is_active(request, 'solitude-payments'):
        url = addon.get_dev_url('acquire_refund_permission')
        url = absolutify(urlparams(url, dest=dest))
        result = client.post_permission_url(data={'scope': perms, 'url': url})
        paypal_url = result['token']
    # TODO(solitude): remove this.
    else:
        paypal_url = paypal.get_permission_url(addon, dest, perms)

    return jingo.render(request,
                        'developers/payments/paypal-details-request.html',
                        {'paypal_url': paypal_url, 'addon': addon})
Пример #12
0
 def test_get_permissions_url_scope(self, _call):
     _call.return_value = {"token": "foo", "tokenSecret": "bar"}
     paypal.get_permission_url(self.addon, "", ["REFUND", "FOO"])
     eq_(_call.call_args[0][1]["scope"], ["REFUND", "FOO"])
Пример #13
0
 def test_get_permissions_url_error(self, _call):
     _call.side_effect = paypal.PaypalError
     with self.assertRaises(paypal.PaypalError):
         paypal.get_permission_url(self.addon, "", [])
Пример #14
0
 def test_get_permissions_url_malformed(self, _call):
     _call.side_effect = paypal.PaypalError(id="580028")
     assert "wont-work" in paypal.get_permission_url(self.addon, "", [])
Пример #15
0
 def test_get_permissions_url_settings(self, _call):
     settings.PAYPAL_PERMISSIONS_URL = ""
     assert not paypal.get_permission_url(self.addon, "", [])
Пример #16
0
 def test_get_permissions_url_settings(self, _call):
     settings.PAYPAL_PERMISSIONS_URL = ''
     assert not paypal.get_permission_url(self.addon, '', [])
Пример #17
0
 def test_get_permissions_url_malformed(self, _call):
     _call.side_effect = paypal.PaypalError(id='580028')
     assert 'wont-work' in paypal.get_permission_url(self.addon, '', [])
Пример #18
0
 def test_get_permissions_url_error(self, _call):
     _call.side_effect = paypal.PaypalError
     with self.assertRaises(paypal.PaypalError):
         paypal.get_permission_url(self.addon, '', [])
Пример #19
0
 def test_get_permissions_url_scope(self, _call):
     _call.return_value = {'token': 'foo', 'tokenSecret': 'bar'}
     paypal.get_permission_url(self.addon, '', ['REFUND', 'FOO'])
     eq_(_call.call_args[0][1]['scope'], ['REFUND', 'FOO'])