问题
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