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, '', [])
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, "", [])
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 })
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)
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 })
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} )
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})
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 })
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 })
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} )
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})
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"])
def test_get_permissions_url_error(self, _call): _call.side_effect = paypal.PaypalError with self.assertRaises(paypal.PaypalError): paypal.get_permission_url(self.addon, "", [])
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, "", [])
def test_get_permissions_url_settings(self, _call): settings.PAYPAL_PERMISSIONS_URL = "" assert not paypal.get_permission_url(self.addon, "", [])
def test_get_permissions_url_settings(self, _call): settings.PAYPAL_PERMISSIONS_URL = '' assert not paypal.get_permission_url(self.addon, '', [])
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, '', [])
def test_get_permissions_url_error(self, _call): _call.side_effect = paypal.PaypalError with self.assertRaises(paypal.PaypalError): paypal.get_permission_url(self.addon, '', [])
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'])