paypal / PayPal-Cordova-Plugin

PayPal SDK Cordova/Phonegap Plugin
Other
248 stars 131 forks source link

"problem communicating with the PayPal servers" error #195

Closed fursid closed 8 years ago

fursid commented 8 years ago

Required Information

Mode (Mock/Sandbox/Live): Sandbox

Cordova Plugin Version: 3.1.17

Platforms (iOS/Android/Both): Both

Device OS Version and Device (iOS 9.x on an iPhone 6, Android Marshmallow on Nexus 6, etc.): Tested on

PayPal-Debug-ID(s) (from any logs): not available

Issue Description: As soon as I initiate the payment by running the following code:

payPalCheckout      : function () {
                that = router.activeItem();
                self = this;
                function initPaymentUI() {
                    console.log("initPaymentUI");
                    var clientIDs = {
                        "PayPalEnvironmentProduction": app.PayPalEnvironmentProduction,
                        "PayPalEnvironmentSandbox"   : app.PayPalEnvironmentSandbox
                    };
                    PayPalMobile.init(clientIDs, onPayPalMobileInit);
                }

                function onPayPalMobileInit() {
                    // must be called
                    // use PayPalEnvironmentNoNetwork mode to get look and feel of the flow
                    if (app.PayPalEnvironment == "prod") {
                        PayPalMobile.prepareToRender("PayPalEnvironmentProduction", configuration(), onPrepareRender);
                    } else {
                        PayPalMobile.prepareToRender("PayPalEnvironmentSandbox", configuration(), onPrepareRender);
                    }
                }

                function configuration() {
                    // for more options see `paypal-mobile-js-helper.js`
                    var config = new PayPalConfiguration({
                        merchantName            : "SM",
                        merchantPrivacyPolicyURL: "http://www.example.com/mobapp/smapp/#help",
                        merchantUserAgreementURL: "http://www.example.com/mobapp/smapp/#help"
                    });
                    return config;
                }

                function onPrepareRender() {
                    // single payment
                    PayPalMobile.renderSinglePaymentUI(createPayment(), onSuccesfulPayment, onUserCanceled);
                }

                function createPayment() {

                    // for simplicity use predefined amount
                    // optional payment details for more information check [helper js file](https://github.com/paypal/PayPal-Cordova-Plugin/blob/master/www/paypal-mobile-js-helper.js)
                    var paymentDetails = new PayPalPaymentDetails("5", "0.00", "0.00");
                    var payment = new PayPalPayment("5", "GBP", "SwopMarket Cart: ", "Sale", paymentDetails);
                    console.log("payment", payment);
                    return payment;
                }

                function onSuccesfulPayment(payment) {
                    console.log('onSuccesfulPayment success ', payment);
                    console.log("payment success: " + JSON.stringify(payment, null, 2));
                    if (payment.response.state == "approved") {
                        self.addOrderToDB(payment);
                    } else {
                        uikit.notify("<div class='uk-text-center'>Cancelled by user.</div>", {status: 'warning'});
                    }

                }

                function onUserCanceled(result) {
                    uikit.notify("<div class='uk-text-center'> Payment Error! <br/> There seems to be something wrong. Please try again in a moment. </div>", {status: 'warning'});
                    console.log("result", result);
                }

                initPaymentUI();
},

and the plugin is launched the following screen with error "Try Again: There was a problem communicating with the PayPal servers. Please try again." 7_aab979c5bdc0e6702b02bddc4a34f5ac3ad89a11_o 1

Using following plugins in my phonegap build:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<widget xmlns="http://www.w3.org/ns/widgets" xmlns:gap="http://phonegap.com/ns/1.0"
 id="com.###.###"
 version="5.0.3"
 versionCode="503"
 value="503">
  <name>SwopMarket</name>
  <description>All yours in three swipes!</description>
  <author email="***@gmail.com" href="http://bizkeyonline.com/">BizkeySoft Team</author>
  <content src="index.html"/>

  <preference name="android-build-tool" value="gradle" />
  <preference name="phonegap-version" value="cli-6.3.0"/>
  <preference name="permissions" value="none"/>
  <preference name="orientation" value="portrait"/>
  <preference name="target-device" value="universal"/>
  <preference name="fullscreen" value="false"/>
  <preference name="webviewbounce" value="true"/>
  <preference name="prerendered-icon" value="true"/>
  <preference name="stay-in-webview" value="false"/>
  <preference name="ios-statusbarstyle" value="black-opaque"/>
  <preference name="detect-data-types" value="true"/>
  <preference name="exit-on-suspend" value="false"/>
  <preference name="ShowSplashScreenSpinner" value="true"/>
  <preference name="AutoHideSplashScreen" value="true" />
  <preference name="SplashScreenDelay" value="1000" />
  <preference name="FadeSplashScreen" value="false"/>
  <preference name="FadeSplashScreenDuration" value="750"/>
  <preference name="SplashMaintainAspectRatio" value="true" />

  <preference name="disable-cursor" value="false"/>
  <preference name="android-minSdkVersion" value="15"/>
  <preference name="android-installLocation" value="auto"/>

  <plugin name="cordova-plugin-whitelist" source="npm" spec="1" />
  <plugin name="cordova-plugin-camera" source="npm" spec="~2.2.0" />
  <plugin name="cordova-plugin-device" source="npm" spec="~1.1.2" />
  <plugin name="cordova-plugin-dialogs" source="npm" spec="~1.2.1" />
  <plugin name="cordova-plugin-console" source="npm" spec="~1.0.3" />
  <plugin name="cordova-plugin-splashscreen" source="npm" spec="~3.2.2" />

  <plugin name="com.paypal.cordova.mobilesdk" spec="3.1.17" source="npm"/>

  <!-- Status Bar Plugin -->
  <preference name="StatusBarOverlaysWebView" value="true" />
  <preference name="StatusBarBackgroundColor" value="#000000" />
  <preference name="StatusBarStyle" value="lightcontent" />
  <feature name="StatusBar">
    <param name="ios-package" value="CDVStatusBar" onload="true" />
  </feature>
  <plugin name="cordova-plugin-statusbar" spec="2.1.3" source="npm" />

  <!-- .Status Bar Plugin -->

  <plugin name="cordova-plugin-google-analytics" spec="~0.8.1" />

  <!-- Facebook Plugin -->
  <plugin spec="https://github.com/jeduan/cordova-plugin-facebook4#a2f6008" source="git">
    <param name="APP_ID" value="###"/>
    <param name="APP_NAME" value="SwopMarket Client"/>
  </plugin>
  <!-- /Facebook Plugin -->

  <plugin name="phonegap-plugin-push" source="npm" spec="1.6.3">
    <param name="SENDER_ID" value="###" />
  </plugin>

  <plugin name="com.testfairy.cordova-plugin" spec="2.0.4" source="npm" />

  <icon src="res/icon.png"/>
  <splash src="res/splash.png"/>
  <access origin="*"/>
  <allow-navigation href="http://*/*" />
  <allow-navigation href="https://*/*" />
  <allow-intent href="*" />
  <allow-intent href="http://*/*" />
  <allow-intent href="https://*/*" />
  <allow-intent href="tel:*" />
  <allow-intent href="sms:*" />
  <allow-intent href="mailto:*" />
  <allow-intent href="geo:*" />
  <allow-intent href="fb:*" />
  <allow-intent href="whatsapp:*" />
  <platform name="android">
    <allow-intent href="market:*"/>
    <icon src="res/android/res/drawable-ldpi/Icon.png" gap:density="ldpi"/>
    <splash src="res/splash.png" gap:density="ldpi"/>
  </platform>
  <platform name="ios">
    <config-file parent="UIStatusBarHidden">
      <true/>
    </config-file>
    <config-file parent="UIViewControllerBasedStatusBarAppearance">
      <false/>
    </config-file>
    <allow-intent href="itms:*"/>
    <allow-intent href="itms-apps:*"/>
    <icon src="res/ios/icon/Tab-bar-icon.png" width="60" height="60"/>
  </platform>
  <engine name="ios" spec="~4.2.0"/>
  <engine name="android" spec="~5.2.1"/>
</widget>
jaypatel512 commented 8 years ago

Duplicate of #194.

Lets consolidate these issues. We can track it there.