In App Purchase Problems

Hello everyone,
I Have a question about the implementation of in App Purchase plugin.

when i want to put import { InAppPurchase } from '@ionic-native/in-app-purchase';
in my providers list i got this:

{
	...
	"owner": "typescript",
	"code": "2322",
	"severity": 8,
	"message": "Impossible to assignate **le type 'InAppPurchaseOriginal' au type 'Provider'**.\n  Type 'InAppPurchaseOriginal' is missing the following properties from type 'FactoryProvider': provide, useFactory",
	...
}

so i use import { InAppPurchase } from '@ionic-native/in-app-purchase/ngx';

i my app can build and run.

But when i want to use

  this.iap
 .getProducts(['app.myapp.product1'])
 .then((products) => {
   console.log(products);
   
 })
 .catch((err) => {
   console.log(err);
 });
  }

I got this error

My products are set in https://appstoreconnect.apple.com/,
I set up the bundleID in my config.xml

do you have a solution?
Thx a lot

Uninstall the plugin first then use this command to install it

npm i @ionic-native/in-app-purchase@4 --save

Then run this command after it

ionic cordova plugin add cordova-plugin-inapppurchase

That’s all

1 Like

Thx a lot for your answer.

got the same issue about the InAppPurchaseOriginal before the build.

"message": "Can not assign type 'InAppPurchaseOriginal' to type 'Provider'.\n  Type 'InAppPurchaseOriginal' is missing the following properties from type 'FactoryProvider': provide, useFactory",

so maybe is it a problem with my npm ?
got this

npm i @ionic-native/in-app-purchase@4 --save                                                                                                                                       
npm WARN @ionic-native/apple-pay@4.20.0 requires a peer of @ionic-native/core@^4.11.0 but none is installed. You must install peer dependencies yourself.
npm WARN @ionic-native/date-picker@4.13.0 requires a peer of @ionic-native/core@^4.11.0 but none is installed. You must install peer dependencies yourself.
npm WARN @ionic-native/in-app-purchase-2@5.0.0 requires a peer of @ionic-native/core@5.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @ionic-native/keyboard@4.19.0 requires a peer of @ionic-native/core@^4.11.0 but none is installed. You must install peer dependencies yourself.
npm WARN @ionic-native/market@4.19.0 requires a peer of @ionic-native/core@^4.11.0 but none is installed. You must install peer dependencies yourself.
npm WARN @ionic-native/native-audio@4.17.0 requires a peer of @ionic-native/core@^4.11.0 but none is installed. You must install peer dependencies yourself.
npm WARN @ionic-native/network@4.19.0 requires a peer of @ionic-native/core@^4.11.0 but none is installed. You must install peer dependencies yourself.
npm WARN @ionic-native/onesignal@4.18.0 requires a peer of @ionic-native/core@^4.11.0 but none is installed. You must install peer dependencies yourself.
npm WARN @ionic-native/wheel-selector@4.17.0 requires a peer of @ionic-native/core@^4.11.0 but none is installed. You must install peer dependencies yourself.
npm WARN angular2-jwt@0.2.3 requires a peer of @angular/core@^2.0.0||^4.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN angular2-jwt@0.2.3 requires a peer of @angular/http@^2.0.0||^4.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN angularfire2@5.0.0-rc.10 requires a peer of @angular/common@^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN angularfire2@5.0.0-rc.10 requires a peer of @angular/core@^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN angularfire2@5.0.0-rc.10 requires a peer of @angular/platform-browser@^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN angularfire2@5.0.0-rc.10 requires a peer of @angular/platform-browser-dynamic@^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN angularfire2@5.0.0-rc.10 requires a peer of rxjs@^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @ionic-native/in-app-purchase@4.20.0 requires a peer of @ionic-native/core@^4.11.0 but none is installed. You must install peer dependencies yourself.

+ @ionic-native/in-app-purchase@4.20.0

I had this warnings for a long time but didn’t stop the app’s build and run.
i thought about a “rights” problems, i need to sudo when i want to update ionic.

Did you run the second command?

Yes!

Plugin "cordova-plugin-inapppurchase" already installed on android.
Plugin "cordova-plugin-inapppurchase" already installed on browser.
Plugin "cordova-plugin-inapppurchase" already installed on ios.
Adding cordova-plugin-inapppurchase to package.json
Saved plugin info for "cordova-plugin-inapppurchase" to config.xml

I told you to remove the plugin you installed initially and after then go to node_modules ==> @ionic-native then delete the folder of the plugin before you run the commands i gave you.

Do this and i believe it will work

Thx, make the Import of the InAppPurchase ok!

but got this for the cordova:

> cordova plugin add cordova-plugin-inapppurchase --save
Installing "cordova-plugin-inapppurchase" for android
Android Studio project detected
Error during processing of action! Attempting to revert...
Failed to install 'cordova-plugin-inapppurchase': CordovaError: Uh oh!
".../platforms/android/src/com/android/vending/billing/IInAppBillingService.aidl" already exists!

do i need to make a google play account or something like this?

Try and remove the platform android then add it back hopefully it should solve it

1 Like

Thanks à lot dude.
It’s finally working.
:ok_hand:

You are welcome dude…I am happy it worked!!!

Already Fixed Here -> https://stackoverflow.com/a/54365080/3725226