Paypal Checkout - 不要求非成员(member)提供送货地址?

标签 paypal

我刚开始玩这个模块:

https://github.com/paypal/paypal-checkout

我正在研究如何关闭客户的送货地址。我知道您可以在 URL 中执行 &NOSHIPPING=1 的顺序版本,但我找不到有关 API 4 版本的任何信息。我的代码是:

paypal.Button.render({

    // Pass the client ids to use to create your transaction on sandbox and production environments
    locale: 'fr_FR',

    //env: 'production',
    env: 'sandbox',

    client: {
        sandbox: "...",
        production: "..."
    },

    // Pass the payment details for your transaction
    // See https://developer.paypal.com/docs/api/payments/#payment_create for the expected json parameters

    payment: function() {
        return paypal.rest.payment.create(this.props.env, this.props.client, {
            transactions: [
                {
                    amount: {
                        total:    window.my_config.grand_total,
                        currency: 'EUR',
                        details: {
                              "subtotal": window.my_config.price,
                              "tax": window.my_config.vat_amount
                        }
                    },
                }
            ]
        });
    },

    // Display a "Pay Now" button rather than a "Continue" button

    commit: true,

    // Pass a function to be called when the customer completes the payment

    onAuthorize: function(data, actions) {
        return actions.payment.execute().then(function() {
            console.log('The payment was completed!');
            console.log(data, actions)

            if (error === 'INSTRUMENT_DECLINED') {
                actions.restart();
            }

        });
    },

    // Pass a function to be called when the customer cancels the payment

    onCancel: function(data) {
        console.log('The payment was cancelled!');
    },
    style: {
      shape:  'rect',
      size: "medium"
    }

}, '#paypalContainerEl');

最佳答案

使用“shipping_preference:'NO_SHIPPING'。”

createOrder: function(data, actions) {
    $('#paypalmsg').html('<b>' + 'WAITING ON AUTHORIZATION TO RETURN...' + '</b>');
    $('#chkoutmsg').hide()
    return actions.order.create({
        purchase_units: [{
            description: 'GnG Order',
            amount: {
                value: cartTotal
            }
        }],
        application_context: {
          shipping_preference: 'NO_SHIPPING'
        }

    });
},

关于Paypal Checkout - 不要求非成员(member)提供送货地址?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42160816/

相关文章:

asp.net - Paypal 自适应支付返回 url 被调用两次

asp.net-mvc - Paypal REST API - 在支付过程中传递参数

php - 哪个 Paypal API/方法用于简单的 PHP 购物车支付

paypal - 我想了解 2017 年 PayPal 上的 TransactionSearch API(已弃用)

ios - Paypal IPN 模拟器和沙盒帐户

php - Paypal 专业版 : is it necessary to gather details oneself or can PayPal do that for me?

paypal - 服务器如何知道付款确实是通过 PayPal 客户端 REST API 进行的?

javascript - 使用单页应用程序(Angular)在上下文结帐中使用 PayPal

html - Paypal HTML 表单 - 即时返回 URL

asp.net - 在 ASP.NET 页面中形成 POST