Paypal Checkout - 不询问非会员的送货地址吗?

And*_*wby 3 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');
Run Code Online (Sandbox Code Playgroud)

Pau*_*nes 5

使用“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'
        }

    });
},
Run Code Online (Sandbox Code Playgroud)