def get_payment_request(self, cart, request):
        """
        From the given request, redirect onto the checkout view, hosted by PayPal.
        """
        shop_ns = resolve(request.path).namespace
        return_url = reverse('{}:{}:return'.format(shop_ns, self.namespace))
        cancel_url = reverse('{}:{}:cancel'.format(shop_ns, self.namespace))
        cart = CartModel.objects.get_from_request(request)
        cart.update(request)  # to calculate the total
        auth_token_hash = self.get_auth_token()
        payload = {
            'url': '{API_ENDPOINT}/v1/payments/payment'.format(**settings.SHOP_PAYPAL),
            'method': 'POST',
            'headers': {
                'Content-Type': 'application/json',
                'Authorization': '{token_type} {access_token}'.format(**auth_token_hash),
            },
            'data': {
                'intent': 'sale',
                'redirect_urls': {
                    'return_url': request.build_absolute_uri(return_url),
                    'cancel_url': request.build_absolute_uri(cancel_url),
                },
                'payer': {
                    'payment_method': 'paypal',
                },
                'transactions': [{
                    'amount': {
                        'total': cart.total.as_decimal(),
                        'currency': cart.total.currency,
                    }
                }]
            }
        }
        config = json.dumps(payload, cls=DjangoJSONEncoder)
        success_handler = """
            function successCallback(r) {
                console.log(r);
                $window.location.href=r.data.links.filter(function(e){
                    return e.rel==='approval_url';
                })[0].href;
            }""".replace('  ', '').replace('\n', '')
        error_handler = """
            function errorCallback(r) {
                console.error(r);
            }""".replace('  ', '').replace('\n', '')
        js_expression = '$http({0}).then({1},{2})'.format(config, success_handler, error_handler)
        return js_expression