Paypal Express Checkout - You are calling paypal.checkout.setup() more than once

有些话、适合烂在心里 提交于 2019-12-10 18:14:50

问题


We are using the PayPal express checkout JavaScript API (http://www.paypalobjects.com/api/checkout.js).

We have the PayPal checkout button being loaded in a step of a wizard.

When the user enters that step the setupPaypal function is called.

function setupPaypal(){
    paypal.checkout.setup('${cfg.paypalCfg.merchantId}', getPaypalConfig());
}

function getPaypalConfig(){

    var paypalConfig = {
      environment: '${cfg.paypalCfg.environment}',
      container: ['paypalCheckoutContainer'],
      click: onPaypalButtonClick
    };

    return paypalConfig;

}

Everything is working fine until here.

The wizard has a back option.

If the user selects back and then goes forward again the PayPal API sends the following message:

Error: You are calling paypal.checkout.setup() more than once. This function can only be called once per page load. Any further calls will be ignored.

By looking at the code I understand why the message is sent to the console.

But when this happens the PayPal Checkout button is no longer on the screen and the container (container: ['paypalCheckoutContainer']) is empty.

Is there any solution for this?

Thanks in advance.

来源:https://stackoverflow.com/questions/35209304/paypal-express-checkout-you-are-calling-paypal-checkout-setup-more-than-once

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!