贝宝智能按钮不会确认项目列表有想法吗?

问题描述

我的PayPal智能按钮界面出现问题。该文档适得其反。

沙箱中的电子邮件示例不会显示项目描述/详细信息。它只显示总数。在他们站点上的一个文档中,items块位于purchase_units块内部。失败将没有真正的错误消息。

paypal.Buttons({
    createOrder: function (data,actions) {
        // Busy indicator.
        var spinner = document.getElementById("spinner");
        var cart = document.getElementById("vysshopcart");
        spinner.style.display = "block";
        cart.style.display = "none";
        // This function sets up the details of the transaction,including the amount and line item details.
        return actions.order.create({
            purchase_units: [{
                amount: {
                    value: "10","currency-code": "USD",details: {
                        subtotal: "10",shipping: "0",tax: "0.00"
                    },total: "10"
                }
            }],links: [{
                href: "http://192.168.249.20:81/virtual-yard-sale?invoice=2020092011397C1E",rel: "approve"
            }],"items": [
                {
                    "sku": "2","name": "Harry & David Snack Disk","price": "5.00","quantity": "1","category": "PHYSICAL_GOODS","currency": "USD"
                },{
                    "sku": "10","name": "Raya Insulated Lunch Tote","currency": "USD"
                }
            ]
        });
    },onApprove: function (data,actions) {
        // This function captures the funds from the transaction.
        return actions.order.capture().then(function (details) {
            // This function shows a transaction success message to your buyer.
            window.location.replace("http://192.168.249.20:81/virtual-yard-sale?invoice=2020092011397C1E");
        });
    }
}).render('#paypal-button-container');

解决方法

看起来您在其他地方找到了答案,purchase_units内有一个items数组,但是随后还需要金额明细,例如

           amount: {
                currency_code: "EUR",value: "200.00",breakdown: {
                    item_total: {
                        currency_code: "EUR",value: "200.00"
                    }
                }
            },

关于onApprove流程,请考虑这样做,如果可能,请从您的服务器执行createOrder。这是一个演示:https://developer.paypal.com/demo/checkout/#/pattern/server

您需要在服务器上使用两条路由来调用/ v2 / checkout / orders API,一条用于“设置交易”(创建订单),另一条用于捕获该订单,记录在这里:https://developer.paypal.com/docs/checkout/reference/server-integration/ >

服务器集成更为稳健,假设您要确保客户端(浏览器)不会影响总数,并且您会立即收到成功捕获的API响应,并可以将订单标记为在服务器中已付款与客户端代码中的action.order.capture()相反,这可能会困扰您。

但是对于相对较少的事务量/简单的用例,较简单的仅客户端集成可能就足够了。

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...