paypal - 删除 PayPal Express Checkout 中的送货地址选项

标签 paypal express-checkout

我正在使用 JS script Paypal 推荐。它运作良好,但显示的是买家的“收货地址”地址。

我正在尝试搜索互联网,发现 https://api.sandbox.paypal.com/v1/payment-experience/web-profiles/ 请求 "no_shipping": 1, 可以解决问题。但是为此我们需要在 payment.create 之前发出一个 curl 请求,以便我们可以在函数中传递它返回的 id。

这在 JS 中可行吗?

或者是否有更好更简单的方法使用以下 JS 删除它?

<script src="https://www.paypalobjects.com/api/checkout.js" data-version-4></script>
<script>

    paypal.Button.render({
        env: 'sandbox', // Optional: specify 'sandbox' or 'production'
        client: {
            sandbox:    '{{$data['SandboxId']}}',
            production: '{{$data['ProductionId']}}'
        },

        payment: function() {
            var amount = document.getElementById("amount").value;
            var env    = this.props.env;
            var client = this.props.client;

            return paypal.rest.payment.create(env, client, {
                transactions: [
                    {
                        amount: {
                            total: amount,
                            currency: "USD",
                            details: {
                                subtotal: amount,
                                tax: "0.00",
                                shipping: "0.00"
                            }
                        },
                        description: "This is payment description.",
                        item_list: { 
                            items:[
                                {
                                    quantity:"1", 
                                    name:"Orders", 
                                    price:amount,  
                                    sku:"product12345", 
                                    currency:"USD"
                                }
                            ],
                        },

                    }],

            });
        },

        commit: false, // Optional: show a 'Pay Now' button in the checkout flow

        onAuthorize: function(data, actions) {
                console.log(data);
                 alert('confirmation here');
                // Optional: display a confirmation page here

            return actions.payment.execute().then(function() {
                alert('Success here');
                // Show a success page to the buyer
            });
        },
    }, '#paypal-button');
</script><div id="paypal-button" ></div>

最佳答案

为了扩展 Bluepnume 的回答,这里有一个完整的例子:

  payment: function(data, actions) {
        return actions.payment.create({
            payment: {
                transactions: [
                    {
                        amount: { total: '1.00', currency: 'USD' }
                    }
                ]
            },

            experience: {
                input_fields: {
                    no_shipping: 1
                }
            }
        });
    },

关于paypal - 删除 PayPal Express Checkout 中的送货地址选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40940800/

相关文章:

vb.net - PayPal - 10001 内部错误 : timeout processing request Express Checkout

PayPal Plus : Sorry, 目前由于技术原因无法处理付款

c# - Express PayPal 结账,无法创建 SSL/TLS 安全通道

paypal - 自适应付款没有送货信息

javascript - 如何修复响应 : {type: "cors"} when trying to create payment through paypal api

iframe - iframe 中的 Paypal 结帐 express url

paypal - 如何从 PayPal IPN 获取多个收件人的电子邮件地址?

多次 try catch 时出现 Paypal 错误消息 'Buyer cannot pay.'

payment-gateway - 禁用 Paypal Express Checkout 中的地址字段

c# - 'PayPal.Manager.ConfigManager' 的类型初始值设定项抛出异常 -->Paypal SetExpressCheckout