zyra / cordova-plugin-stripe

A Cordova plugin that lets you use Stripe's Native SDKs for Android and iOS.
MIT License
93 stars 57 forks source link

"TypeError: Object(...) is not a function" when importing to module #57

Open Zerokk opened 5 years ago

Zerokk commented 5 years ago

After installing Stripe and the Cordova plugin, and setting up Stripe as a provider in any module, the app won't load and will output the message:

TypeError: Object(...) is not a function

It doesn't matter if I put is as a provider to the main module, or the components module for lazyloading components, or wherever. It just will output this error and nothing more. Something's definitely not fine here.

Some data about my setup:

Node v11.8 Dependencies:

{
"dependencies": {
    "@agm/core": "^1.0.0-beta.5",
    "@angular/common": "~7.2.3",
    "@angular/core": "~7.2.3",
    "@angular/forms": "~7.2.3",
    "@angular/http": "~7.2.3",
    "@angular/platform-browser": "~7.2.3",
    "@angular/platform-browser-dynamic": "~7.2.3",
    "@angular/router": "~7.2.3",
    "@ionic-native/core": "5.0.0",
    "@ionic-native/geolocation": "^5.0.0",
    "@ionic-native/spinner-dialog": "^5.0.0",
    "@ionic-native/splash-screen": "5.0.0",
    "@ionic-native/status-bar": "5.0.0",
    "@ionic-native/stripe": "^4.20.0",
    "@ionic/angular": "4.0.0",
    "@types/parse": "^2.1.0",
    "chart.js": "^2.7.3",
    "cordova-android": "7.1.4",
    "cordova-plugin-device": "^2.0.2",
    "cordova-plugin-geolocation": "^4.0.1",
    "cordova-plugin-ionic-keyboard": "^2.1.3",
    "cordova-plugin-ionic-webview": "^3.1.2",
    "cordova-plugin-native-spinner": "^1.1.3",
    "cordova-plugin-splashscreen": "^5.0.2",
    "cordova-plugin-statusbar": "^2.4.2",
    "cordova-plugin-stripe": "1.5.3",
    "cordova-plugin-whitelist": "^1.3.3",
    "core-js": "^2.5.3",
    "crypto-js": "^3.1.9-1",
    "moment": "^2.24.0",
    "ng2-charts": "^1.6.0",
    "parse": "^2.1.0",
    "rxjs": "6.4.0",
    "typescript": "^3.1.6",
    "zone.js": "^0.8.29"
  }
}

Plugins: "plugins": { "cordova-plugin-geolocation": { "GEOLOCATION_USAGE_DESCRIPTION": "To locate you" }, "cordova-plugin-whitelist": {}, "cordova-plugin-statusbar": {}, "cordova-plugin-device": {}, "cordova-plugin-splashscreen": {}, "cordova-plugin-ionic-webview": { "ANDROID_SUPPORT_ANNOTATIONS_VERSION": "27.+" }, "cordova-plugin-ionic-keyboard": {}, "cordova-plugin-native-spinner": {}, "cordova-plugin-stripe": {} },

ihadeed commented 5 years ago

The details you shared aren't enough to know where the issue is coming from.

But looking at your package.json I do see that you installed @ionic-native/stripe@4.20.0 while the rest of your Ionic Native packages are using ^5.0.0. You need everything to be ^5.0.0 as v5 isn't reverse compatible that way.

Zerokk commented 5 years ago

But, does stripe have a version 5? I need the v5 ionic native packages if I want some of the stuff of the app to work, and I still can't be able to use this native library no matter what I do. Mind that the app breaks only when I setup it as a provider for any, literally any given module. That's not normal, especially when the error thrown makes so little sense.

noctivityinc commented 5 years ago

I have the exact same issue and I am running 5.1.0 of stripe. When I do an npm install it tells me I need to install rxjs^6.3, but other plugins require 5.X of rxjs - not sure if that makes a difference.

I also wrapped the call in a platform.ready block but that didnt make a difference.

I'd use stripe.js directly with elements but ionic appears to block stripe.js on iOS for production

levarberry commented 5 years ago

Downgrade everything in @ionic-native to 4.20.0 v5 is a pre-release .. so it will be unstable.