danielsogl / awesome-cordova-plugins

Native features for mobile apps built with Cordova/PhoneGap and open web technologies. Complete with TypeScript support.
https://danielsogl.gitbook.io/awesome-cordova-plugins/
Other
2.41k stars 2.42k forks source link

update in-app-purchase-2 to cordova-plugin-purchase v13 #4848

Open gxolin opened 21 hours ago

gxolin commented 21 hours ago

I'm submitting a ... (check one with "x")

Current behavior: package.json :

    "@awesome-cordova-plugins/core": "^6.9.0",
    "@awesome-cordova-plugins/in-app-purchase-2": "^6.9.0",
    "cordova-plugin-purchase": "^13.11.1",

With this configuration, the cordova-plugin-purchase is registered as a plugin, but is not discovered by awesome-cordova-plugins. Trying to interact with InAppPurchase2 will throw warnings and do nothing : Native: tried calling InAppPurchase2.register, but the InAppPurchase2 plugin is not installed.

Expected behavior: No warning, ability to use InAppPurchase2

Steps to reproduce: On a fresh angular + capacitor install, npm i @awesome-cordova-plugins/core @awesome-cordova-plugins/in-app-purchase-2 cordova-plugin-purchase

Related code: in angular app.component.ts :

import { InAppPurchase2 } from '@awesome-cordova-plugins/in-app-purchase-2/ngx';
[...]
  private store: InAppPurchase2 = inject(InAppPurchase2);
  ngOnInit(): void {
    if (Capacitor.isNativePlatform()) {
      console.log(InAppPurchase2.installed(), InAppPurchase2.getPluginInstallName(), InAppPurchase2.getPluginName(), InAppPurchase2.getPluginRef(), InAppPurchase2.getSupportedPlatforms());
      this.store.verbosity = this.store.DEBUG;
    }
  }

The first log will print : true 'cordova-plugin-purchase' 'InAppPurchase2' 'store' (3) ['iOS', 'Android', 'Windows'] the store.verbosity will do nothing but print warn : Native: tried calling InAppPurchase2.register, but the InAppPurchase2 plugin is not installed.

Other information: cordova-plugin-purchase migration guide : https://github.com/j3k0/cordova-plugin-purchase/wiki/HOWTO:-Migrate-to-v13

Note : I'm not using the plugin author recommended installation without awesome-cordova here : https://github.com/j3k0/cordova-plugin-purchase?tab=readme-ov-file#note-for-capacitor-users because it's not working on my setup. I've open an issue here : https://github.com/j3k0/cordova-plugin-purchase/issues/1610

I also don't want to use recommended workarounds : https://forum.ionicframework.com/t/how-use-in-app-puchase-with-ionic-6-capacitor-4/230472/4 because I try to introduce as little as possible of technical depts. Forcing an old version for a plugin handling my payment flow is not really a good idea in my opinion

Ionic info: (run ionic info from a terminal/cmd prompt and paste output below):

ionic info
[WARN] You are not in an Ionic project directory. Project context may be missing.

Ionic:

   Ionic CLI : 7.2.0

Utility:

   cordova-res : not installed globally
   native-run  : not installed globally

System:

   NodeJS : v20.13.1
   npm    : 10.9.0
   OS     : Linux 5.15
gxolin commented 16 hours ago

I've started a fork to update, and I see there is many breaking changes. I'm not sure if it's best to have a InAppPurchase3 or a InAppPurchase2 with massive BC with previous versions.