j3k0 / cordova-plugin-purchase

In-App Purchase for Cordova on iOS, Android and Windows
https://purchase.cordova.fovea.cc
1.29k stars 529 forks source link

[Android] Cannot Register Existing Products in V13 #1389

Closed aesculus closed 7 months ago

aesculus commented 1 year ago

I have a V9 application that I have converted to V13.3.4. Got all the bugs worked out in iOS and moved to Android. I cannot get past registering the products as they all come up empty after the register call. I have checked in Google Play and I have 3 legacy subscriptions and each has one and only one offer labeled Backwards Compatible. I used the same product IDs in Google as I do Apple, which I understand to be OK as long as I do a registration for each separately.

Attached is the log where you can see that the register includes the platform but the products list is empty afterwards. Also I get the error 6777012 when the plugin looks to see if there are any purchases for those products.

Why are my products not registering in Android?

LOG:

12:22:12.244 I "[CdvPurchase] INFO: initialize()" 12:22:12.245 I "[CdvPurchase.Adapters] INFO: Adding platforms: [{"platform":"android-playstore"}]" 12:22:12.245 I "[CdvPurchase.Adapters] INFO: " 12:22:12.245 I "[CdvPurchase.Adapters] INFO: GooglePlay initializing..." 12:22:12.245 I "[CdvPurchase.GooglePlay] INFO: Initialize" 12:22:12.245 I "[CdvPurchase.GooglePlay.Bridge] INFO: setup ok" 12:22:12.270 I "[CdvPurchase.GooglePlay.Bridge] INFO: listener: {"type":"ready","data":{}}" 12:22:12.277 I "[CdvPurchase.GooglePlay] DEBUG: Ready" 12:22:12.278 I "[CdvPurchase.Adapters] INFO: GooglePlay initialized. " 12:22:12.278 I "[CdvPurchase.Adapters] INFO: GooglePlay products: [{"id":"product_yearly","platform":"android-playstore"},{"id":"product_monthly","platform":"android-playstore"},{"id":"product_annual","platform":"android-playstore"}]" 12:22:12.279 I "[CdvPurchase.GooglePlay] DEBUG: Load: [{"id":"product_yearly","platform":"android-playstore"},{"id":"product_monthly","platform":"android-playstore"},{"id":"product_annual","platform":"android-playstore"}]" 12:22:12.279 I "[CdvPurchase.GooglePlay] DEBUG: getAvailableProducts: ["product_yearly","product_monthly","product_annual"] | []" 12:22:12.279 I "[CdvPurchase.GooglePlay.Bridge] INFO: getAvailableProducts()" 12:22:12.326 I "[CdvPurchase.GooglePlay] DEBUG: Loaded: []" 12:22:12.326 I "[CdvPurchase.GooglePlay] DEBUG: getPurchases" 12:22:12.326 I "[CdvPurchase.GooglePlay.Bridge] INFO: getPurchases()" 12:22:12.326 I "[CdvPurchase.Adapters] INFO: GooglePlay loaded: [{"isError":true,"code":6777012,"message":"Product with id product_yearly not found."},{"isError":true,"code":6777012,"message":"Product with id product_monthly not found."},{"isError":true,"code":6777012,"message":"Product with id product_annual not found."}]" 12:22:12.488 I "[CdvPurchase.GooglePlay.Bridge] INFO: listener: {"type":"setPurchases","data":{"purchases":[]}}" 12:22:12.488 I "[CdvPurchase.GooglePlay] DEBUG: onSetPurchases: []" 12:22:12.488 I "[CdvPurchase.GooglePlay] DEBUG: onPurchaseUpdated: " 12:22:12.489 I "[CdvPurchase.GooglePlay] DEBUG: getPurchases success"

j3k0 commented 1 year ago

Based on those logs, the native side reports that your products cannot be found. This is most probably a setup issue. Is the app running on a real device? Is the application ID correct? Is the Google account connected to the device listed as a tester?

aesculus commented 1 year ago
Here is the current Google SW installed. Updating it now just in case. Available Updates: ID Installed Available
emulator 31.3.12 32.1.11
platform-tools 33.0.3 34.0.0
system-images;android-25;google_apis;x86 16 18
aesculus commented 1 year ago

Updated the SW and it made no difference. Still not getting the products registered.

The app was compiled as debug vs release as an APK. But it had failed here before as release too and that is why I went to debug so I could capture the log.

Here is my Android section of the config.xml. Anything stand out that is a problem?

<platform name="android">
        <preference name="AndroidPersistentFileLocation" value="Internal" />
        <preference name="hostname" value="localhost" />
        <preference name="AndroidInsecureFileModeEnabled" value="true" />
        <preference name="android-minSdkVersion" value="19" />
        <preference name="android-targetSdkVersion" value="31" />
        <preference name="android-build-tool" value="gradle" />
</platform>

EDIT: Well I forced the minSdkVersion to 31 (after updating the code base to 32 to be sure) and that made no difference. All it did was break my splash screen plugin. :-(

So I am at a loss unless someone can come up with some other tests or a fix I will drop back to V12 of the plugin and rewrite the code back to the pre V13 architecture.

paulstelzer commented 1 year ago

I can confirm that version 13 is working. I also upgraded my app from the old to the new version. Are you try to adding a subscription? Please check your code to register the subscription with the correct type. The id has to be identical with Google Play (just take a look at the subscription page in google play)

      {
        platform: 'android-playstore',
        id: 'exact_id_like_in_googleplay,
        type: 'paid subscription',
      }

Without any sourcecode and screenshots from Google Play its hard to say whats wrong. I can just confirm subscriptions and in-app-purchases work like a charm in v13.

aesculus commented 1 year ago

Thank you for validating your subscription product works. I verified that my product IDs were exact and here is this source for registering. Still a mystery.

CdvPurchase.store.register({ id: 'dag_tesla_to_yearly', type: CdvPurchase.PAID_SUBSCRIPTION, platform: CdvPurchase.Platform.GOOGLE_PLAY, });

aesculus commented 1 year ago

@paulstelzer would you mind telling me what version of Cordova, Android Cordova you are using and also what version of the Google Android dev too? I have tried Cordova Android 11 and the Google Android 32 tools and sdk. Still cannot get this to work.

j3k0 commented 1 year ago

@aesculus Notice that v13 doesn't require legacy subscriptions, it's compatible with the new subscription model. I'm not sure about this, but maybe try adding a non-legacy subscription product see if it appears?

aesculus commented 1 year ago

I ended up dropping back to version 11.0.0 as I could never get this to work for 13x.

Cordova Android 11 also caused issues with the splash plugin and who knows what else was in store for me.

Version 11.0.0 of this plugin works just flawless for my app and until Google forces V5 of billing on me, I am going to coast and monitor this thread as well as other reports of the environment that got V13 apps working.

paulstelzer commented 1 year ago

@paulstelzer would you mind telling me what version of Cordova, Android Cordova you are using and also what version of the Google Android dev too? I have tried Cordova Android 11 and the Google Android 32 tools and sdk. Still cannot get this to work.

I am using capacitor 4 for my app and currently compile sdk 33 (but 32 was working, too)

Lemon-King commented 1 year ago

I'm having similar issues with registering an array of products using Cordova-Plugin-Purchase v13, with v11 I did not have any issues with registration.

Cordova-Plugin-Purchase@13.3.8 Cordova-Android@^11.0.0

My current codebase does work with v13 on iOS devices.

aesculus commented 1 year ago

I updated my app to cli: 11.1.0, Android 11 and the plugin to 13.3.11. Android SDK is at 33. I made sure that

Still not getting product ids (that are working in billing api v4) to load and return pricing.

Date/Time: 16:12:49; Log Type: log; Data: [CdvPurchase.Adapters] INFO: GooglePlay products: [{"id":"xxx_yearly","platform":"android-playstore"},{"id":"xxx_monthly","platform":"android-playstore"},{"id":"xxx_annual","platform":"android-playstore"}] Date/Time: 16:12:49; Log Type: log; Data: [CdvPurchase.GooglePlay] DEBUG: Load: [{"id":"xxx_yearly","platform":"android-playstore"},{"id":"xxx_monthly","platform":"android-playstore"},{"id":"xxx_annual","platform":"android-playstore"}] Date/Time: 16:12:49; Log Type: log; Data: [CdvPurchase.GooglePlay] DEBUG: getAvailableProducts: ["xxx_yearly","xxx_monthly","xxx_annual"] | [] Date/Time: 16:12:49; Log Type: log; Data: [CdvPurchase.GooglePlay.Bridge] INFO: getAvailableProducts() Date/Time: 16:12:49; Log Type: log; Data: [CdvPurchase.GooglePlay] DEBUG: Loaded: []

Note that this a javascript/cordova program.

RodriSanchez1 commented 1 year ago

Hello! I'm facing the same problem. I was using v13.3.11 with no issues with a product that has two base plans. This was always returned by the plugin. The strange thing is that I added tags for each one and then disabled one. Suddenly the plugin never retrieves the product again.

I have an older product that was not registering when starting the plugin. After the problem, I added the id of this product in the register function to check if it was returned. And surprisingly yes, it was returned GooglePlay loaded: [{"isError":true,"code":6777012,"message":"Product with id premium.. not found."},{"className":"Product","title":"One Year Subscriptions ","description":"".....

I'm sure it broke after the changes in the basic plans. I found the error using the same build of the app

On Cordova-Plugin-Purchase@13.3.11 Cordova-Android@^11.0.0

sean118 commented 1 year ago

Updating to version 13.4.0 of this plugin seems to have fixed the same issue for me.

Probably setting the product's group attribute to "default" in the register() function would do the same trick, like this:

store.register([
  {
      id: PRODUCT_ID,
      type: ProductType.PAID_SUBSCRIPTION,
      platform: Platform.GOOGLE_PLAY,
      group: 'default'
  }
])
aesculus commented 1 year ago

@sean118 : Thank you for posting your success. I tried adding the group" 'default' and it made no difference for 13.3.11.

For some reason I cannot update the plugin to 13.4.0. I removed the plugin, and then tried adding without a version and with @13.4.0 and in all cases I still install 13.3.11. Not sure why. :-(

aesculus commented 1 year ago

I finally got version 13.4 loaded and also added the group" 'default'. No change in the app.

My three legacy subscriptions are still showing:

"[CdvPurchase.Adapters] INFO: GooglePlay loaded: [{"isError":true,"code":6777012,"message":"Product with id product_yearly not found."},{"isError":true,"code":6777012,"message":"Product with id product_monthly not found."},{"isError":true,"code":6777012,"message":"Product with id product_annual not found."}]"

mley commented 11 months ago

I'm having the same problem in my Ionic7/capacitor5 app.

Here's my code:

  private storePlatform = this.platform.is('ios')
    ? CdvPurchase.Platform.APPLE_APPSTORE
    : CdvPurchase.Platform.GOOGLE_PLAY;

 public async init(): Promise<void> {
    await this.platform.ready();

    const paymentProvider = this.platform.is('ios') ? 'APPLE' : 'ANDROID';
    const plans = await firstValueFrom(
      this.http.get<MembershipPlan[]>(SERVER_API_URL + `/membership/available-plans?paymentProvider=${paymentProvider}`)
    ); //this will get the product ids used in Play-Store

    CdvPurchase.store.verbosity = CdvPurchase.LogLevel.DEBUG;

    const products = plans.map(plan => ({
      id: plan.productId,
      type: CdvPurchase.ProductType.PAID_SUBSCRIPTION,
      platform: this.storePlatform,
      group: 'default',
    }));
    CdvPurchase.store.register(products);

    CdvPurchase.store
      .when()
      .approved(p => this.productApproved(p))
      .verified(p => this.productVerified(p))
      .unverified(p => this.productUnverified(p))
      .finished(p => this.productFinished(p));
    CdvPurchase.store.error(err => {
      this.loggingService.error(err);
    });

    CdvPurchase.store.ready(() => {
      console.log('store ready');
      plans.forEach(plan => {
        const product = CdvPurchase.store.get(plan.productId, this.storePlatform);
        console.log('product', product); // this is always undefined
      });

      this.membershipPlans = plans;
    });

    await CdvPurchase.store.initialize([this.storePlatform]);
    await CdvPurchase.store.update();
  }

Running a debug version on an android phone results in store.get() returning undefined, although the subscription products exist in Playstore Screenshot 2023-06-14 at 15 45 57

JS-Console logs:

home:9445 Create CdvPurchase...
home:8432 [CdvPurchase] INFO: initialize()
home:8432 [CdvPurchase.Adapters] INFO: Adding platforms: [{"platform":"android-playstore"}]
home:8432 [CdvPurchase.Adapters] INFO: 
home:8432 [CdvPurchase.Adapters] INFO: GooglePlay initializing...
home:8432 [CdvPurchase.GooglePlay] INFO: Initialize
home:8432 [CdvPurchase.GooglePlay.Bridge] INFO: setup ok
home:8432 [CdvPurchase.GooglePlay.Bridge] INFO: listener: {"type":"ready","data":{}}
home:8432 [CdvPurchase.GooglePlay] DEBUG: Ready
home:8432 [CdvPurchase.Adapters] INFO: GooglePlay initialized. 
home:8432 [CdvPurchase.Adapters] INFO: GooglePlay products: [{"id":"nutrition-monthly","type":"paid subscription","platform":"android-playstore","group":"default"},{"id":"nutrition-annually","type":"paid subscription","platform":"android-playstore","group":"default"},{"id":"fitness-monthly","type":"paid subscription","platform":"android-playstore","group":"default"},{"id":"fitness-annually","type":"paid subscription","platform":"android-playstore","group":"default"}]
home:8432 [CdvPurchase.GooglePlay] DEBUG: Load: [{"id":"nutrition-monthly","type":"paid subscription","platform":"android-playstore","group":"default"},{"id":"nutrition-annually","type":"paid subscription","platform":"android-playstore","group":"default"},{"id":"fitness-monthly","type":"paid subscription","platform":"android-playstore","group":"default"},{"id":"fitness-annually","type":"paid subscription","platform":"android-playstore","group":"default"}]
home:8432 [CdvPurchase.GooglePlay] DEBUG: getAvailableProducts: [] | ["nutrition-monthly","nutrition-annually","fitness-monthly","fitness-annually"]
home:8432 [CdvPurchase.GooglePlay.Bridge] INFO: getAvailableProducts()
home:8432 [CdvPurchase.GooglePlay] DEBUG: Loaded: []
home:8432 [CdvPurchase.GooglePlay] DEBUG: getPurchases
home:8432 [CdvPurchase.GooglePlay.Bridge] INFO: getPurchases()
home:8432 [CdvPurchase.Adapters] INFO: GooglePlay loaded: [{"isError":true,"code":6777012,"message":"Product with id nutrition-monthly not found."},{"isError":true,"code":6777012,"message":"Product with id nutrition-annually not found."},{"isError":true,"code":6777012,"message":"Product with id fitness-monthly not found."},{"isError":true,"code":6777012,"message":"Product with id fitness-annually not found."}]
home:8432 [CdvPurchase] INFO: update()
home:8432 [CdvPurchase.GooglePlay] DEBUG: Load: [{"id":"nutrition-monthly","type":"paid subscription","platform":"android-playstore","group":"default"},{"id":"nutrition-annually","type":"paid subscription","platform":"android-playstore","group":"default"},{"id":"fitness-monthly","type":"paid subscription","platform":"android-playstore","group":"default"},{"id":"fitness-annually","type":"paid subscription","platform":"android-playstore","group":"default"}]
home:8432 [CdvPurchase.GooglePlay] DEBUG: getAvailableProducts: [] | ["nutrition-monthly","nutrition-annually","fitness-monthly","fitness-annually"]
home:8432 [CdvPurchase.GooglePlay.Bridge] INFO: getAvailableProducts()
purchase.service.ts:50 store ready
4purchase.service.ts:53 plan.product undefined
home:8432 [CdvPurchase.GooglePlay.Bridge] INFO: listener: {"type":"setPurchases","data":{"purchases":[]}}
home:8432 [CdvPurchase.GooglePlay] DEBUG: onSetPurchases: []
home:8432 [CdvPurchase.GooglePlay] DEBUG: onPurchaseUpdated: 
home:8432 [CdvPurchase.GooglePlay] DEBUG: getPurchases success
home:8432 [CdvPurchase.GooglePlay] DEBUG: Loaded: []
home:8432 [CdvPurchase.GooglePlay] DEBUG: getPurchases
home:8432 [CdvPurchase.GooglePlay.Bridge] INFO: getPurchases()
home:8432 [CdvPurchase.GooglePlay.Bridge] INFO: listener: {"type":"setPurchases","data":{"purchases":[]}}
home:8432 [CdvPurchase.GooglePlay] DEBUG: onSetPurchases: []
home:8432 [CdvPurchase.GooglePlay] DEBUG: onPurchaseUpdated: 
home:8432 [CdvPurchase.GooglePlay] DEBUG: getPurchases success

Logcat logs adb logcat | grep -B 5 -A 2 -i purchase

06-14 15:40:07.783  5912  5912 I Capacitor/Console: File: http://192.168.1.41:8100/tabs/home - Line 2639 - Msg: onscript loading complete
06-14 15:40:07.785  1690  2824 D PackageManager: setEnabledSetting : userId = 0 packageName = com.Slack cmp = androidx.work.impl.background.systemalarm.RescheduleReceiver newState = 1 callingPackage = 10350/com.Slack
06-14 15:40:07.786  1690  2824 D ApplicationPolicy: getApplicationStateEnabled : pkg = com.Slack userId : 0
06-14 15:40:07.787  1690  2824 D ApplicationPolicy: getApplicationComponentState : pkg = com.Slack userId : 0
06-14 15:40:07.800  5912  5912 V Capacitor/Plugin: To native (Cordova plugin): callbackId: Device882590609, service: Device, action: getDeviceInfo, actionArgs: []
06-14 15:40:07.801  5912  5912 I Capacitor/Console: File: http://192.168.1.41:8100/tabs/home - Line 9445 - Msg: Create CdvPurchase...
06-14 15:40:07.803  5912  5912 V Capacitor/Plugin: To native (Cordova plugin): callbackId: StatusBar882590610, service: StatusBar, action: _ready, actionArgs: []
06-14 15:40:07.804 21943 21999 D ConnectivityManager: StackLog: [android.net.ConnectivityManager.sendRequestForNetwork(ConnectivityManager.java:4300)] [android.net.ConnectivityManager.registerDefaultNetworkCallbackForUid(ConnectivityManager.java:4864)] [android.net.ConnectivityManager.registerDefaultNetworkCallback(ConnectivityManager.java:4831)] [android.net.ConnectivityManager.registerDefaultNetworkCallback(ConnectivityManager.java:4805)] [androidx.work.impl.utils.NetworkApi24.registerDefaultNetworkCallbackCompat(Unknown Source:11)] [androidx.work.impl.constraints.trackers.NetworkStateTracker24.startTracking(Unknown Source:15)] [androidx.work.impl.constraints.controllers.ConstraintController.replace(Unknown Source:130)] [androidx.work.impl.constraints.WorkConstraintsTrackerImpl.replace(Unknown Source:41)] [androidx.work.impl.background.greedy.GreedyScheduler.schedule(Unknown Source:302)] [androidx.work.impl.Schedulers.schedule(Unknown Source:149)] [androidx.work.impl.utils.EnqueueRunnable.run(Unknown Source:53)] [androidx.work.Worker$2.run$androidx$work$impl$utils$SerialExecutorImpl$Task(Unknown Source:4)] [androidx.work.Worker$2.run(Unknown Source:868)] [java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137)] [java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637)] [java.lang.Thread.run(Thread.java:1012)]
--
06-14 15:40:14.962  1690  2080 I SemWifiLinkQualityMonitor: Link Qos query: inf. ms / 0 Mbps
06-14 15:40:15.133  1138  1138 I BufferQueueProducer: [com.xxx/com.xxx.MainActivity$_5912#2399](this:0xb400007942334838,id:-1,api:0,p:-1,c:1138) queueBuffer: fps=3.68 dur=1087.71 max=555.70 min=94.43
06-14 15:40:15.135  1108 31858 I hwcomposer: [HWCDisplay] [Display_0 (type:1)] fps:3.674002,dur:1088.73,max:555.96,min:94.30
06-14 15:40:15.236  1098 16721 E Netd    : To use pid in case SEC_PRODUCT_FEATURE_KNOX_SUPPORT_NPA is false, to remove build error (unused variable)
06-14 15:40:15.258  1098 16724 E Netd    : To use pid in case SEC_PRODUCT_FEATURE_KNOX_SUPPORT_NPA is false, to remove build error (unused variable)
06-14 15:40:15.460  5912  5912 I Capacitor/Console: File: http://192.168.1.41:8100/tabs/home - Line 8432 - Msg: [CdvPurchase] INFO: initialize()
06-14 15:40:15.462  5912  5912 I Capacitor/Console: File: http://192.168.1.41:8100/tabs/home - Line 8432 - Msg: [CdvPurchase.Adapters] INFO: Adding platforms: [{"platform":"android-playstore"}]
06-14 15:40:15.463  5912  5912 I Capacitor/Console: File: http://192.168.1.41:8100/tabs/home - Line 8432 - Msg: [CdvPurchase.Adapters] INFO:
06-14 15:40:15.465  5912  5912 I Capacitor/Console: File: http://192.168.1.41:8100/tabs/home - Line 8432 - Msg: [CdvPurchase.Adapters] INFO: GooglePlay initializing...
06-14 15:40:15.466  5912  5912 I Capacitor/Console: File: http://192.168.1.41:8100/tabs/home - Line 8432 - Msg: [CdvPurchase.GooglePlay] INFO: Initialize
06-14 15:40:15.467  5912  5912 I Capacitor/Console: File: http://192.168.1.41:8100/tabs/home - Line 8432 - Msg: [CdvPurchase.GooglePlay.Bridge] INFO: setup ok
06-14 15:40:15.470  5912  5912 V Capacitor/Plugin: To native (Cordova plugin): callbackId: InAppBillingPlugin882590626, service: InAppBillingPlugin, action: setListener, actionArgs: []
06-14 15:40:15.470  5912  6130 D CdvPurchase: sendToListener() -> ready
06-14 15:40:15.470  5912  6130 D CdvPurchase:             data -> {}
06-14 15:40:15.471  5912  5912 V Capacitor/Plugin: To native (Cordova plugin): callbackId: InAppBillingPlugin882590627, service: InAppBillingPlugin, action: init, actionArgs: []
06-14 15:40:15.471  5912  6130 D CdvPurchase: init()
06-14 15:40:15.473  5912  6130 D CdvPurchase: startServiceConnection()
06-14 15:40:15.484  5324  5337 I Finsky  : [37] kjm.a(19): com.xxx: Account from first account - [HMWDHW2ITCIxagSk8m4LfTeK2fQ2F3fgSQfcLHchkYE]
06-14 15:40:15.485  5324  5337 I Finsky  : [37] kjm.a(67): Billing preferred account via installer for com.xxx: [HMWDHW2ITCIxagSk8m4LfTeK2fQ2F3fgSQfcLHchkYE]
06-14 15:40:15.488  5912  5912 I Capacitor/Console: File: http://192.168.1.41:8100/tabs/home - Line 8432 - Msg: [CdvPurchase.GooglePlay.Bridge] INFO: listener: {"type":"ready","data":{}}
06-14 15:40:15.488  5324  5337 I Finsky  : [37] kjm.a(19): com.xxx: Account from first account - [HMWDHW2ITCIxagSk8m4LfTeK2fQ2F3fgSQfcLHchkYE]
06-14 15:40:15.489  5324  5337 I Finsky  : [37] kjm.a(67): Billing preferred account via installer for com.xxx: [HMWDHW2ITCIxagSk8m4LfTeK2fQ2F3fgSQfcLHchkYE]
06-14 15:40:15.490  5912 16725 D CdvPurchase: startServiceConnection() -> Success
06-14 15:40:15.490  5912 16725 D CdvPurchase: init() -> Success
06-14 15:40:15.493  5912  5912 I Capacitor/Console: File: http://192.168.1.41:8100/tabs/home - Line 8432 - Msg: [CdvPurchase.GooglePlay] DEBUG: Ready
06-14 15:40:15.495  5912  5912 I Capacitor/Console: File: http://192.168.1.41:8100/tabs/home - Line 8432 - Msg: [CdvPurchase.Adapters] INFO: GooglePlay initialized.
06-14 15:40:15.496  5912  5912 I Capacitor/Console: File: http://192.168.1.41:8100/tabs/home - Line 8432 - Msg: [CdvPurchase.Adapters] INFO: GooglePlay products: [{"id":"nutrition-monthly","type":"paid subscription","platform":"android-playstore","group":"default"},{"id":"nutrition-annually","type":"paid subscription","platform":"android-playstore","group":"default"},{"id":"fitness-monthly","type":"paid subscription","platform":"android-playstore","group":"default"},{"id":"fitness-annually","type":"paid subscription","platform":"android-playstore","group":"default"}]
06-14 15:40:15.497  5912  5912 I Capacitor/Console: File: http://192.168.1.41:8100/tabs/home - Line 8432 - Msg: [CdvPurchase.GooglePlay] DEBUG: Load: [{"id":"nutrition-monthly","type":"paid subscription","platform":"android-playstore","group":"default"},{"id":"nutrition-annually","type":"paid subscription","platform":"android-playstore","group":"default"},{"id":"fitness-monthly","type":"paid subscription","platform":"android-playstore","group":"default"},{"id":"fitness-annually","type":"paid subscription","platform":"android-playstore","group":"default"}]
06-14 15:40:15.498  5912  5912 I Capacitor/Console: File: http://192.168.1.41:8100/tabs/home - Line 8432 - Msg: [CdvPurchase.GooglePlay] DEBUG: getAvailableProducts: [] | ["nutrition-monthly","nutrition-annually","fitness-monthly","fitness-annually"]
06-14 15:40:15.498  5912  5912 I Capacitor/Console: File: http://192.168.1.41:8100/tabs/home - Line 8432 - Msg: [CdvPurchase.GooglePlay.Bridge] INFO: getAvailableProducts()
06-14 15:40:15.500  5912  5912 V Capacitor/Plugin: To native (Cordova plugin): callbackId: InAppBillingPlugin882590628, service: InAppBillingPlugin, action: getAvailableProducts, actionArgs: [[],["nutrition-monthly","nutrition-annually","fitness-monthly","fitness-annually"]]
06-14 15:40:15.500  5912  6130 D CdvPurchase: getAvailableProducts()
06-14 15:40:15.501  5912  6130 D CdvPurchase: queryAllProductDetails()
06-14 15:40:15.501  5912  6130 D CdvPurchase: queryAllProductDetails() -> Query SUBS.
06-14 15:40:15.501  5912  6130 D CdvPurchase: queryProductDetailsAsync()
06-14 15:40:15.501  5912  6130 D CdvPurchase: executeServiceRequest() -> OK
06-14 15:40:15.501  5912  6130 D CdvPurchase: queryProductDetailsAsync() -> Success
06-14 15:40:15.504  5324  5337 I Finsky  : [37] kjm.a(19): com.xxx: Account from first account - [HMWDHW2ITCIxagSk8m4LfTeK2fQ2F3fgSQfcLHchkYE]
06-14 15:40:15.504  5324  5337 I Finsky  : [37] kjm.a(67): Billing preferred account via installer for com.xxx: [HMWDHW2ITCIxagSk8m4LfTeK2fQ2F3fgSQfcLHchkYE]
06-14 15:40:15.511  5912 16726 W CdvPurchase: queryAllProductDetails() -> Query returned nothing.
06-14 15:40:15.511  5912 16726 D CdvPurchase: queryAllProductDetails() -> Calling listener.
06-14 15:40:15.511  5912 16726 D CdvPurchase: getAvailableProducts() -> Success
06-14 15:40:15.514  5912  5912 I Capacitor/Console: File: http://192.168.1.41:8100/tabs/home - Line 8432 - Msg: [CdvPurchase.GooglePlay] DEBUG: Loaded: []
06-14 15:40:15.515  5912  5912 I Capacitor/Console: File: http://192.168.1.41:8100/tabs/home - Line 8432 - Msg: [CdvPurchase.GooglePlay] DEBUG: getPurchases
06-14 15:40:15.516  5912  5912 I Capacitor/Console: File: http://192.168.1.41:8100/tabs/home - Line 8432 - Msg: [CdvPurchase.GooglePlay.Bridge] INFO: getPurchases()
06-14 15:40:15.518  5912  5912 V Capacitor/Plugin: To native (Cordova plugin): callbackId: InAppBillingPlugin882590629, service: InAppBillingPlugin, action: getPurchases, actionArgs: ["null"]
06-14 15:40:15.518  5912  6130 D CdvPurchase: getPurchases()
06-14 15:40:15.518  5912  6130 D CdvPurchase: queryPurchases()
06-14 15:40:15.518  5912  6130 D CdvPurchase: executeServiceRequest() -> OK
06-14 15:40:15.519  5912  5912 I Capacitor/Console: File: http://192.168.1.41:8100/tabs/home - Line 8432 - Msg: [CdvPurchase.Adapters] INFO: GooglePlay loaded: [{"isError":true,"code":6777012,"message":"Product with id fitup-nutrition-monthly not found."},{"isError":true,"code":6777012,"message":"Product with id fitup-nutrition-annually not found."},{"isError":true,"code":6777012,"message":"Product with id fitness-monthly not found."},{"isError":true,"code":6777012,"message":"Product with id fitness-annually not found."}]
06-14 15:40:15.521  5912  5912 I Capacitor/Console: File: http://192.168.1.41:8100/tabs/home - Line 8432 - Msg: [CdvPurchase] INFO: update()
06-14 15:40:15.521  5324  5969 I Finsky  : [133] kjm.a(19): com.xxx: Account from first account - [xxx]
06-14 15:40:15.521  5324  5337 I Finsky  : [37] kjm.a(19): com.xxx: Account from first account - [xxx]
06-14 15:40:15.522  5324  5337 I Finsky  : [37] kjm.a(67): Billing preferred account via installer for com.xxx: [xxx]
06-14 15:40:15.522  5324  5969 I Finsky  : [133] kjm.a(67): Billing preferred account via installer for com.xxx: [xxx]
06-14 15:40:15.522  5912  5912 I Capacitor/Console: File: http://192.168.1.41:8100/tabs/home - Line 8432 - Msg: [CdvPurchase.GooglePlay] DEBUG: Load: [{"id":"nutrition-monthly","type":"paid subscription","platform":"android-playstore","group":"default"},{"id":"nutrition-annually","type":"paid subscription","platform":"android-playstore","group":"default"},{"id":"fitness-monthly","type":"paid subscription","platform":"android-playstore","group":"default"},{"id":"fitness-annually","type":"paid subscription","platform":"android-playstore","group":"default"}]
06-14 15:40:15.523  5912  5912 I Capacitor/Console: File: http://192.168.1.41:8100/tabs/home - Line 8432 - Msg: [CdvPurchase.GooglePlay] DEBUG: getAvailableProducts: [] | ["nutrition-monthly","nutrition-annually","fitness-monthly","fitness-annually"]
06-14 15:40:15.523  5912 16727 I CdvPurchase: queryPurchases(INAPP) -> Elapsed time: 4ms
06-14 15:40:15.524  5912  5912 I Capacitor/Console: File: http://192.168.1.41:8100/tabs/home - Line 8432 - Msg: [CdvPurchase.GooglePlay.Bridge] INFO: getAvailableProducts()
06-14 15:40:15.525  5912 16728 I CdvPurchase: queryPurchases(SUBS) -> Elapsed time: 6ms
06-14 15:40:15.525  5912 16728 D CdvPurchase: sendToListener() -> setPurchases
06-14 15:40:15.525  5912 16728 D CdvPurchase:             data -> {"purchases":[]}
06-14 15:40:15.526  5912  5912 V Capacitor/Plugin: To native (Cordova plugin): callbackId: InAppBillingPlugin882590630, service: InAppBillingPlugin, action: getAvailableProducts, actionArgs: [[],["nutrition-monthly","nutrition-annually","fitness-monthly","fitness-annually"]]
06-14 15:40:15.526  5912  6130 D CdvPurchase: getAvailableProducts()
06-14 15:40:15.526  5912  6130 D CdvPurchase: queryAllProductDetails()
06-14 15:40:15.526  5912  6130 D CdvPurchase: queryAllProductDetails() -> Query SUBS.
06-14 15:40:15.526  5912  6130 D CdvPurchase: queryProductDetailsAsync()
06-14 15:40:15.526  5912  6130 D CdvPurchase: executeServiceRequest() -> OK
06-14 15:40:15.526  5912  6130 D CdvPurchase: queryProductDetailsAsync() -> Success
06-14 15:40:15.527  5912  5912 I Capacitor/Console: File: http://192.168.1.41:8100/main.js - Line 9017 - Msg: store ready
06-14 15:40:15.528  5912  5912 I Capacitor/Console: File: http://192.168.1.41:8100/main.js - Line 9020 - Msg: plan.product undefined
06-14 15:40:15.529  5912  5912 I Capacitor/Console: File: http://192.168.1.41:8100/main.js - Line 9020 - Msg: plan.product undefined
06-14 15:40:15.529  5912  5912 I Capacitor/Console: File: http://192.168.1.41:8100/main.js - Line 9020 - Msg: plan.product undefined
06-14 15:40:15.530  5912  5912 I Capacitor/Console: File: http://192.168.1.41:8100/main.js - Line 9020 - Msg: plan.product undefined
06-14 15:40:15.530  5324  5969 I Finsky  : [133] kjm.a(67): Billing preferred account via installer for com.xxx: [xxx]
06-14 15:40:15.531  5912  5912 I Capacitor/Console: File: http://192.168.1.41:8100/tabs/home - Line 8432 - Msg: [CdvPurchase.GooglePlay.Bridge] INFO: listener: {"type":"setPurchases","data":{"purchases":[]}}
06-14 15:40:15.531  5912  5912 I Capacitor/Console: File: http://192.168.1.41:8100/tabs/home - Line 8432 - Msg: [CdvPurchase.GooglePlay] DEBUG: onSetPurchases: []
06-14 15:40:15.532  5912  5912 I Capacitor/Console: File: http://192.168.1.41:8100/tabs/home - Line 8432 - Msg: [CdvPurchase.GooglePlay] DEBUG: onPurchaseUpdated:
06-14 15:40:15.533  5912  5912 I Capacitor/Console: File: http://192.168.1.41:8100/tabs/home - Line 8432 - Msg: [CdvPurchase.GooglePlay] DEBUG: getPurchases success
06-14 15:40:15.535  5912 16729 W CdvPurchase: queryAllProductDetails() -> Query returned nothing.
06-14 15:40:15.535  5912 16729 D CdvPurchase: queryAllProductDetails() -> Calling listener.
06-14 15:40:15.535  5912 16729 D CdvPurchase: getAvailableProducts() -> Success
06-14 15:40:15.538  5912  5912 I Capacitor/Console: File: http://192.168.1.41:8100/tabs/home - Line 8432 - Msg: [CdvPurchase.GooglePlay] DEBUG: Loaded: []
06-14 15:40:15.539  5912  5912 I Capacitor/Console: File: http://192.168.1.41:8100/tabs/home - Line 8432 - Msg: [CdvPurchase.GooglePlay] DEBUG: getPurchases
06-14 15:40:15.539  5912  5912 I Capacitor/Console: File: http://192.168.1.41:8100/tabs/home - Line 8432 - Msg: [CdvPurchase.GooglePlay.Bridge] INFO: getPurchases()
06-14 15:40:15.540  5912  5912 V Capacitor/Plugin: To native (Cordova plugin): callbackId: InAppBillingPlugin882590631, service: InAppBillingPlugin, action: getPurchases, actionArgs: ["null"]
06-14 15:40:15.540  5912  6130 D CdvPurchase: getPurchases()
06-14 15:40:15.540  5912  6130 D CdvPurchase: queryPurchases()
06-14 15:40:15.540  5912  6130 D CdvPurchase: executeServiceRequest() -> OK
06-14 15:40:15.542  5324  5969 I Finsky  : [133] kjm.a(19): com.xxx: Account from first account - [xxx]
06-14 15:40:15.543  5324  5337 I Finsky  : [37] kjm.a(19): com.xxx: Account from first account - [xxx]
06-14 15:40:15.543  5324  5969 I Finsky  : [133] kjm.a(67): Billing preferred account via installer for com.xxx: [xxx]
06-14 15:40:15.544  5324  5337 I Finsky  : [37] kjm.a(67): Billing preferred account via installer for com.xxx: [xxx]
06-14 15:40:15.544  5912 16730 I CdvPurchase: queryPurchases(INAPP) -> Elapsed time: 4ms
06-14 15:40:15.545  5912 16731 I CdvPurchase: queryPurchases(SUBS) -> Elapsed time: 5ms
06-14 15:40:15.545  5912 16731 D CdvPurchase: sendToListener() -> setPurchases
06-14 15:40:15.545  5912 16731 D CdvPurchase:             data -> {"purchases":[]}
06-14 15:40:15.547  5912  5912 I Capacitor/Console: File: http://192.168.1.41:8100/tabs/home - Line 8432 - Msg: [CdvPurchase.GooglePlay.Bridge] INFO: listener: {"type":"setPurchases","data":{"purchases":[]}}
06-14 15:40:15.547  5912  5912 I Capacitor/Console: File: http://192.168.1.41:8100/tabs/home - Line 8432 - Msg: [CdvPurchase.GooglePlay] DEBUG: onSetPurchases: []
06-14 15:40:15.547  5912  5912 I Capacitor/Console: File: http://192.168.1.41:8100/tabs/home - Line 8432 - Msg: [CdvPurchase.GooglePlay] DEBUG: onPurchaseUpdated:
06-14 15:40:15.548  5912  5912 I Capacitor/Console: File: http://192.168.1.41:8100/tabs/home - Line 8432 - Msg: [CdvPurchase.GooglePlay] DEBUG: getPurchases success
06-14 15:40:15.556  1690  2115 D NetdEventListenerService: DNS Requested by : 120, 10399
06-14 15:40:15.640  1690  2115 D NetdEventListenerService: DNS Requested by : 120, 10399

Does anyone have clue what I'm doing wrong?

UPDATE: Looks like the app needs to be build with a release-certificate. I did that, and even released it to a closed testing channel on play-store and used that for testing, but I still don't get any products. There's still queryAllProductDetails() -> Query returned nothing. in the logs.

fyxtc commented 10 months ago

@mley Same problem, did you solve it?

aesculus commented 10 months ago

No solution for me and I will probably be suspending my app because of it.

mley commented 10 months ago

@fyxtc I haven't found a solution yet. The same code works fine with the Apple AppStore 🀷 It might still be an issue my product and subscription config in PlayStore, but I really don't know what else to check...

I'm now looking into other solutions. Since we're using Capacitor, I'm trying the in-app-purchase-capacitor plugin. That comes with the draw-back, that you need to use a 3rd party service. I think there's also a plain cordova plugin. If everything else fails, we'll use it. https://capgo.app/blog/in-app-purchases-capacitor/

fyxtc commented 10 months ago

@mley "The same code works fine with the Apple AppStore 🀷 It might still be an issue my product and subscription config in PlayStore, but I really don't know what else to check..." Exactly the same situation as me😞

I also found capgo and glassfy ([https://glassfy.io/]). Maybe I'll have to choose one of them in the end

fyxtc commented 10 months ago

@aesculus Maybe we need to look for other libraries

fyxtc commented 10 months ago

@mley @aesculus Guys, I solved it, you have to set backward compatibility https://www.revenuecat.com/docs/google-subscriptions-and-backwards-compatibility

mley commented 10 months ago

@fyxtc I don't get it. Did you get it work with RevenueCat or this cordova-plugin-purchase? I have both backwards-compatible and non-backwards-compatible subscriptions in Google Play. This plugins uses billing client v5.0. Shouldn't at least the backwards-compatible subscriptions be returned?

fyxtc commented 10 months ago

@mley Yes, I get it work with cordova-plugin-purchase and glassfy. Here is glassfy document: https://docs.glassfy.io/docs/play-store-skus-not-returned-to-your-application There must be something wrong with our configuration, maybe you forgot to add a test account?

aesculus commented 10 months ago

I verified everything as stated was set. Still not working.

Can I ask what your Android SW level is and also what you have set in config?

v-trishyn commented 10 months ago

@fyxtc All of my products are backward compatible. And presumably, they must be like this to use the previous version of the cordova-plugin-purchase

image
mley commented 10 months ago

Strangely enough, when I tried it with the RevenueCat / capacitor-purchase SDK, I could get products/subscriptions and test-purchase them.

FeFB commented 9 months ago

I faced the same problem in an Ionic application project. For some reason, it wasn't installing correctly.

Here's what I did to fix:

1. npm uninstall cordova-plugin-purchase --save
2. ionic cordova rm cordova-plugin-purchase // make sure that it was removed from the plugins folder
3. npm install cordova-plugin-purchase --save
4. ionic cordova add cordova-plugin-purchase
ionic5
<preference name="android-targetSdkVersion" value="32" />
<preference name="android-compileSdkVersion" value="32" />
waxerdima commented 9 months ago

Same problem @j3k0 have idea?

waxerdima commented 9 months ago

@j3k0 I apologize, everything is working now. The issue was with my account; paid content is not available in the Google Play Store for my country.

AlexandrDegteari commented 7 months ago

Someone tried to use it with Vue 3? In version 13 I could't understand how to import it in Vue component, it throw error b.register is not a function

import * as CdvPurchase from '../../src-capacitor/node_modules/cordova-plugin-purchase';

initialize() { const InAppPurchase = CdvPurchase const {ProductType, Platform, LogLevel} = CdvPurchase

  InAppPurchase.register([
    {
      id: this.product_id,
      type: ProductType.PAID_SUBSCRIPTION,
      platform: Platform.GOOGLE_PLAY,
    },
  ])
},

any ideas?

j3k0 commented 7 months ago

This will not work as CdvPurchase is a global object:

import * as CdvPurchase from '../../src-capacitor/node_modules/cordova-plugin-purchase';

You should just do:

import "cordova-plugin-purchase";

You can find examples using the plugin with cordova in typescript here: https://github.com/j3k0/cordova-subscription-example

grogan197 commented 6 months ago

I was struggling for ages with this and found this bit of code to use instead of store.order which was coming back with not registered errors (even though it was actually registering the product) Try this: store.get("Your_subscription_id")?.getOffer()?.order();

lj64 commented 6 months ago

I have the same problem. Everything worked fine with v11.

Updated to v13.8.6 and:

Using cordova version: 11.0.0 (cordova-lib@11.1.0) and cordova-android@^11.0.0

And also:

    <preference name="android-targetSdkVersion" value="33" />
    <preference name="android-compileSdkVersion" value="33" />

Testing the app on a closed test track, the same way I did it for the past few years.

Already tried few things mentioned here like:

What am I missing?

giuseeFG commented 6 months ago

Any news here? I'm dealing with the same problem.

j3k0 commented 6 months ago

Please provide logs of what happens at startup, I cannot help you without more information. Notice that this version of the plugin has now been fairly well tested and deployed live by a large number of apps, so there's probably something going on with your code or setup.

giuseeFG commented 6 months ago

Please provide logs of what happens at startup, I cannot help you without more information. Notice that this version of the plugin has now been fairly well tested and deployed live by a large number of apps, so there's probably something going on with your code or setup.

Hi, sorry. My fault. I had a bad version in my package.json file. It works fine 😁

graemian commented 6 months ago

Thank you for validating your subscription product works. I verified that my product IDs were exact and here is this source for registering. Still a mystery.

CdvPurchase.store.register({ id: 'dag_tesla_to_yearly', type: CdvPurchase.PAID_SUBSCRIPTION, platform: CdvPurchase.Platform.GOOGLE_PLAY, });

@aesculus Your problem is almost certainly caused by you setting the type to CdvPurchase.PAID_SUBSCRIPTION instead of CdvPurchase.ProductType.PAID_SUBSCRIPTION

rtkoni commented 1 week ago

i work now on a app using V13.10.1 of cordova-plugin-purchase and facing the same issue. https://github.com/j3k0/cordova-plugin-purchase/issues/1389#issuecomment-1814639865 here is my code to register the subscriptions: store.register({ id, platform: CdvPurchase.Platform.GOOGLE_PLAY, type: CdvPurchase.ProductType.PAID_SUBSCRIPTION, group: 'default' }); In the log i have this: "[CdvPurchase.Adapters] INFO: GooglePlay loaded: [{"isError":true,"code":6777012,"message":"Product with id one-month-abo not found."},{"isError":true,"code":6777012,"message":"Product with id three-month-abo not found."},{"isError":true,"code":6777012,"message":"Product with id six-month-abo not found."}]"

i contacted google and they found no error on our google play console and sent me to the forum. I will be happy for any help Thank you