簡體   English   中英

刪除 PayPal Express Checkout 中的送貨地址選項

[英]Remove shipping address option in PayPal Express Checkout

我正在使用 PayPal 推薦的 JS 腳本。它運行良好,但顯示買家的收貨地址”。

我正在嘗試搜索 inte.net,發現https://api.sandbox.paypal.com/v1/payment-experience/web-profiles/ requested with "no_shipping": 1,可以解決問題。 但是為此我們需要在payment.create之前發出一個 curl 請求,這樣我們就可以傳遞它在 function 中返回的 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.rest.payment.create({
    // payment options here
}, {
    // experience options here
});

這是在 ngx-paypal 版本 11 中需要完成的方式

application_context:
{
  shipping_preference: "NO_SHIPPING"
}

ngx-paypal:“^11.0.0”

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM