Django 和 Paypal 按钮集成

问题描述 投票:0回答:0

我正在将贝宝付款方式集成到我的网站中,该方法运行良好……直到我尝试添加描述以便我可以查看贝宝发票上的所有订单详细信息。

一旦我添加 description: {} 到下面的 createOrder 函数,paypal 加载失败:

<script>
    var total = '{{order.get_cart_total}}'
    // Render the PayPal button into #paypal-button-container
    paypal.Buttons({

        style: {
            color:  'blue',
            shape:  'rect',
        },

        // Set up the transaction
        createOrder: function(data, actions) {
            return actions.order.create({
                purchase_units: [{
                    amount: {
                        value:parseFloat(total).toFixed(2)
                    },
                    description: {
                        order_id
                    },
                }]
            });
        },

        // Finalize the transaction
        onApprove: function(data, actions) {
            return actions.order.capture().then(function(details) {
                console.log(JSON.stringify(details));
        submitFormData()
            });
        }

    }).render('#paypal-button-container');
</script>

在控制台我得到以下错误:

我已将以下设置添加到我的 settings.py 文件中:

SESSION_COOKIE_SECURE = True
CSRF_COOKIE_SECURE = True
SESSION_COOKIE_SAMESITE = 'None'
CSRF_COOKIE_SAMESITE = 'None'
javascript django paypal paypal-sandbox
© www.soinside.com 2019 - 2024. All rights reserved.