【问题标题】:onShippingChange does not work with data.shipping_address.country_codeonShippingChange 不适用于 data.shipping_address.country_code
【发布时间】:2021-05-31 00:47:24
【问题描述】:

我正在尝试将其设置为拒绝除英国以外的所有送货地址。我的代码如下;

onShippingChange: function(data, actions){
    if(data.shipping_address.country_code!=="GB"){
        return actions.reject();
    }
    return actions.resolve();
},

但它不起作用。我没有收到任何错误。

我也尝试将其更改为以下也不起作用;

return actions.reject(new Error("We do not support your country."));

我可以让它稍微工作的唯一方法是如果我使用警报并抛出一个新错误而不是使用reject(),例如;

onShippingChange: function(data, actions){
    if(data.shipping_address.country_code!=="GB"){
        alert("We do not support your country.");
        throw new Error();
    }
},

但这样做并不会关闭 PayPal 弹出窗口/模式。

【问题讨论】:

    标签: javascript jquery paypal paypal-sandbox paypal-rest-sdk


    【解决方案1】:

    尝试在 else 语句中使用return actions.resolve();,无论return actions.reject(); 如何,我都可能被调用

    onShippingChange: function(data, actions){
            if(data.shipping_address.country_code!=="GB"){
                return actions.reject();
            } else {
            return actions.resolve();
            }
    },
    

    【讨论】:

      猜你喜欢
      • 2019-07-20
      • 1970-01-01
      • 2014-12-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-11-23
      • 2018-09-08
      相关资源
      最近更新 更多