Telerik-Verified-Plugins / PayPal

PayPal SDK Cordova/Phonegap Plugin
Other
4 stars 0 forks source link

Problem communicating with PayPal servers. #4

Open novernholder opened 8 years ago

novernholder commented 8 years ago

Getting the following error when trying to make a payment in sandbox environment.

"Problem communicating with PayPal servers, Please try again"

var clientIDs = {
        "PayPalEnvironmentProduction": "YOUR_PRODUCTION_CLIENT_ID",
        "PayPalEnvironmentSandbox": "YOUR_SANDBOX_CLIENT_ID"
};

var payPalConfiguration = {
        // for more options see js/paypal-mobile-js-helper.js
        merchantName: "Test Shop",
        acceptCreditCards: true,
        merchantPrivacyPolicyURL: "https://mytestshop.com/policy",
        merchantUserAgreementURL: "https://mytestshop.com/agreement"
};

var onPayPalMobileInit = function () {
        window.PayPalMobile.prepareToRender(
              "PayPalEnvironmentSandbox", // or "PayPalEnvironmentProduction" for production mode
               new PayPalConfiguration(payPalConfiguration),
              function() { console.log("OK, ready to accept payments!") }
        );
}

window.PayPalMobile.init(clientIDs, onPayPalMobileInit);

var paymentDetails = new PayPalPaymentDetails("15.00", "3.00", "2.00");
var payment = new PayPalPayment("20.00", "USD", "Telerik T-Shirt", "Sale", paymentDetails);

window.PayPalMobile.renderSinglePaymentUI(
              payment,
              function(payment) {
                    alert("payment success: " + JSON.stringify(payment, null, 2));
              },
              function (result) {
                  alert(result);
               }
);

Any ideas on what I'm doing wrong?

EddyVerbruggen commented 8 years ago

Can you share your project with me perhaps? Also, on which platform (iOS/Android/both) is this?

novernholder commented 8 years ago

PaymentGatewayApp.zip The current platform is Android, but it will be running on both iOS and Android eventually.

EddyVerbruggen commented 8 years ago

@novernholder Thanks for the link, but can you please check it? The link is broken.

novernholder commented 8 years ago

Sorry about that, I've attached the file in my previous comment

[Uploading PaymentGatewayApp.zip…]()

EddyVerbruggen commented 8 years ago

Thanks, but this can't be the code you're actually trying this with, right? For instance, there's no active value for PayPalEnvironmentSandbox and the include of js/paypal-mobile-js-helper.js in index.html is not value because of a typo. This way I can only guess what the problem is.

novernholder commented 8 years ago

Hi, the value of the PayPalEnvironmentSandbox is set in the angular config via the provider i wrote. I did check that the value is set and it was.

The "js/paypal-mobile-js-helper.js" script file is not a spelling mistake, the file is not included in the solution it's automatically generated like the cordova.js file. I checked this in the debugger and the file was there, i just made a copy of the file and included it as reference in the solution.

The plugin worked on init on a testing device (Samsung S3 mini) and the PayPal Ui actually popsup but it give the error "Problem communicating with PayPal servers". Thus if the "js/paypal-mobile-js-helper.js" isnt included correctly how is this possible, just a thought.

novernholder commented 8 years ago

This is the example i followed

http://plugins.telerik.com/cordova/plugin/paypal

EddyVerbruggen commented 8 years ago

Makes sense.

It seems to be a pretty common issue btw (google search.

The PayPal guys often advise to try again later as their sandbox servers can be a bit unreliable. But it could also be an issue in your sandbox config.

Can you try again tomorrow and let me know if it persists? I think I'll update our fork this week anyway because we're a bit behind.