在PayPal Express Checkout中删除送货地址选项 [英] Remove shipping address option in PayPal Express Checkout

查看:238
本文介绍了在PayPal Express Checkout中删除送货地址选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用JS 脚本由贝宝(PayPal)推荐.它运作良好,但是显示的是买家的运送至" 地址.

I am using the JS script recommended by PayPal. It's working well, however it is showing a "Ship to" address of the buyers.

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

I am trying to search the internet and found that https://api.sandbox.paypal.com/v1/payment-experience/web-profiles/ requested with "no_shipping": 1, can do the trick. But for that we need to make a curl request before the payment.create, so that we can pass it returned id in the function.

在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的答案,下面是一个完整的示例:

To expand on Bluepnume's answer, here is a complete example:

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

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

这篇关于在PayPal Express Checkout中删除送货地址选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆