【问题标题】:Paypal Checkout (javascript) Create Order - How to fill the shipping name and email?Paypal Checkout (javascript) 创建订单 - 如何填写送货名称和电子邮件?
【发布时间】:2020-11-16 20:31:58
【问题描述】:

我正在尝试如何在 paypal 中填写送货信息,尤其是客户的电子邮件地址和姓名。

这是我的代码:

 paypal.Buttons({
      createOrder: function(data, actions) {
            return actions.order.create({
                purchase_units: [{
                    reference_id: "PUHF",
                description: "Some description",

                custom_id: "Something7364",
                soft_descriptor: "Great description 1",
                amount: {
                    currency_code: "EUR",
                    value: "234.00",
                    breakdown: {
                        item_total: {
                            currency_code: "EUR",
                            value: "200.00"
                        },
                        tax_total: {
                            currency_code: "EUR",
                            value: "20.00"
                        },
                        discount: { 
                            currency_code: "EUR",
                            value: "5.00"
                        },
                        shipping: {
                            currency_code: "EUR",
                            value: "20.00"
                        },
                        insurance: {
                            currency_code: "EUR",
                            value: "1.00"
                        },
                        shipping_discount: {
                            currency_code: "EUR",
                            value: "2.00"
                        }
                    }
                },
                items: [
                    {
                        name: "Item 1",
                        description: "The best item ever",
                        sku: "xyz-2654",
                        unit_amount: {
                            currency_code: "EUR",
                            value: "100.00"
                        },
                        quantity: "1"
                    },
                    {
                        name: "Item 2",
                        description: "Not bad too",
                        sku: "zdc-3942",
                        unit_amount: {
                            currency_code: "EUR",
                            value: "50.00"
                        },
                        quantity: "2"
                    }
                ],
                shipping: {
                    address: {
                        name: {
                            given_name: 'Jean',
                            surname: 'Martin'
                        },
                        email_address: 'jeanmartin[at]email.com',
                        address_line_1: "218 rue de la liberté",
                        address_line_2: "",
                        admin_area_2: "Paris",
                        admin_area_1: "",
                        postal_code: "75000",
                        country_code: "FR",
                    }
                }
                }]
            });
        },

        onApprove: function(data, actions) {
            return actions.order.capture().then(function(details) {
                // Show a success message to the buyer
                alert('Transaction completed by ' + details.payer.name.given_name + '!');
            });
        }


    }).render('#paypal-button-container');

收货地址填写好,但paypal页面没有填写姓名和电子邮件地址。

有人可以帮我将正确的参数传递给贝宝吗?

【问题讨论】:

    标签: javascript paypal


    【解决方案1】:
    paypal.Buttons({
        createOrder: function(data, actions) {
            return actions.order.create({
                payer: {
                    name: {
                        given_name: 'Jean',
                        surname: 'Martin'
                    },
                    email_address: 'jeanmartin@email.com'
                },
                purchase_units: [{
                    ...
                }]
            });
        },
    

    【讨论】:

    • 它有效,谢谢!但是,如果付款人在贝宝页面上更改了他的姓名,则运输名称也会以相同的方式更改。即使付款人更改姓名,有没有办法保留运输名称?
    猜你喜欢
    • 2011-09-05
    • 2020-09-14
    • 2011-12-11
    • 1970-01-01
    • 2010-12-15
    • 1970-01-01
    • 1970-01-01
    • 2021-07-14
    • 2016-11-23
    相关资源
    最近更新 更多