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

Not found error for PAID_SUBSCRIPTION, CONSUMABLE works fine (Google Play) #1499

Closed graemian closed 6 months ago

graemian commented 6 months ago

Observed behavior

Logs show CONSUMABLE is loaded:

[CdvPurchase.GooglePlay] DEBUG: Loaded: [{"productId":"test2","title":"Test (Bomad kids money tracker)","name":"Test","description":"Test","product_type":"inapp","product_format":"v11.0","formatted_price":"$0.99","price_amount_micros":990000,"price_currency_code":"USD"}]

But PAID_SUBSCRIPTION not found:

[CdvPurchase.Adapters] INFO: GooglePlay products loaded: [{"isError":true,"code":6777012,"message":"Product with id supporter_1m not found.","platform":"android-playstore","productId":"supporter_1m"}

Code to load PAID_SUBSCRIPTION looks like this:

store.register([{

        type: CdvPurchase.PAID_SUBSCRIPTION,
        id: "supporter_1m",
        platform: Platform.GOOGLE_PLAY

    } ...

It definitely exists in Google Play. I don't think there's any problem with the config since RevenueCat manages to successfully import it:

image

Full logs:

Create CdvPurchase...
[CdvPurchase] INFO: initialize()
[CdvPurchase.Adapters] INFO: Adding platforms: [{"platform":"android-playstore"}]
[CdvPurchase.Adapters] INFO: 
[CdvPurchase.Adapters] INFO: GooglePlay initializing...
[CdvPurchase.GooglePlay] INFO: Initialize
[CdvPurchase.GooglePlay.Bridge] INFO: setup ok
[CdvPurchase.GooglePlay.Bridge] INFO: listener: {"type":"ready","data":{}}
[CdvPurchase.GooglePlay] DEBUG: Ready
[CdvPurchase.Adapters] INFO: GooglePlay initialized. 
[CdvPurchase.Adapters] INFO: GooglePlay products: [{"id":"supporter_1m","platform":"android-playstore"},{"id":"supporter-1m","platform":"android-playstore"},{"id":"test","platform":"android-playstore"},{"id":"test2","platform":"android-playstore"},{"id":"test3","platform":"android-playstore"}]
[CdvPurchase.GooglePlay] DEBUG: Load: [{"id":"supporter_1m","platform":"android-playstore"},{"id":"supporter-1m","platform":"android-playstore"},{"id":"test","platform":"android-playstore"},{"id":"test2","platform":"android-playstore"},{"id":"test3","platform":"android-playstore"}]
[CdvPurchase.GooglePlay] DEBUG: getAvailableProducts: ["supporter_1m","supporter-1m","test","test2","test3"] | []
[CdvPurchase.GooglePlay.Bridge] INFO: getAvailableProducts()
[CdvPurchase.GooglePlay] DEBUG: Loaded: [{"productId":"test2","title":"Test (Bomad kids money tracker)","name":"Test","description":"Test","product_type":"inapp","product_format":"v11.0","formatted_price":"$0.99","price_amount_micros":990000,"price_currency_code":"USD"}]
[CdvPurchase.GooglePlay] DEBUG: getPurchases
[CdvPurchase.GooglePlay.Bridge] INFO: getPurchases()
[CdvPurchase.GooglePlay.Bridge] INFO: listener: {"type":"setPurchases","data":{"purchases":[]}}
[CdvPurchase.GooglePlay] DEBUG: onSetPurchases: []
[CdvPurchase.GooglePlay] DEBUG: onPurchaseUpdated: 
[CdvPurchase.AdapterListener] DEBUG: receiptsReady: android-playstore (1/0)
[CdvPurchase.GooglePlay] DEBUG: getPurchases success
[CdvPurchase.Adapters] INFO: GooglePlay products loaded: [{"isError":true,"code":6777012,"message":"Product with id supporter_1m not found.","platform":"android-playstore","productId":"supporter_1m"},{"isError":true,"code":6777012,"message":"Product with id supporter-1m not found.","platform":"android-playstore","productId":"supporter-1m"},{"isError":true,"code":6777012,"message":"Product with id test not found.","platform":"android-playstore","productId":"test"},{"className":"Product","title":"Test","description":"Test","platform":"android-playstore","id":"test2","offers":[{"className":"Offer","id":"test2","pricingPhases":[{"price":"$0.99","priceMicros":990000,"currency":"USD","recurrenceMode":"NON_RECURRING"}],"productId":"test2","platform":"android-playstore","type":"inapp"}]},{"isError":true,"code":6777012,"message":"Product with id test3 not found.","platform":"android-playstore","productId":"test3"}]
[CdvPurchase.Adapters] INFO: GooglePlay receipts loaded: []
[CdvPurchase.AdapterListener] DEBUG: setSupportedPlatforms: android-playstore (1 have their receipts ready)
[CdvPurchase.AdapterListener] DEBUG: triggering receiptsReady()
[CdvPurchase] DEBUG: Calling callback: type=receiptsReady() name=#15659ee54654cd3de0a0225d90426d46
[CdvPurchase.ReceiptsMonitor] DEBUG: receiptsReady...
[CdvPurchase.ReceiptsMonitor] DEBUG: check(0/0)
[CdvPurchase.ReceiptsMonitor] INFO: receiptsVerified()

Expected behavior

The PAID_SUBSCRIPTION should load successfully, just like the CONSUMABLE

System Info

I'm using Meteor (https://guide.meteor.com/cordova), so I can't run cordova info directly. I will try to find a way. In the meantime, here's the contents of .meteor/cordova-plugins:

cordova-plugin-camera@https://github.com/felicienfrancois/cordova-plugin-camera.git#e6e49b85b59263fc5782e835160d01a8932e3690
cordova-plugin-device@2.1.0
cordova-plugin-file@7.0.0
cordova-plugin-inappbrowser@5.0.0
cordova-plugin-network-information@3.0.0
cordova-plugin-purchase@13.9.0
cordova-plugin-qrscanner-11@3.0.5
onesignal-cordova-plugin@3.3.1
cordova-plugin-advanced-http@3.3.1

Any help would be very much appreciated. I've got subscriptions working for Apple, but I'm really struggling with Android.

graemian commented 6 months ago

Aaaaargh, the problem was caused by

type: CdvPurchase.PAID_SUBSCRIPTION

instead of

type: CdvPurchase.ProductType.PAID_SUBSCRIPTION

Geez, this one really had me pulling my hair out

graemian commented 6 months ago

What really misled me was that CdvPurchase.PAID_SUBSCRIPTION works for Apple, but not for Google 😂

graemian commented 6 months ago

Aaaargh, maybe I picked up the wrong syntax from https://purchase.cordova.fovea.cc/discover/micro-example. It uses CdvPurchase.CONSUMABLE instead of CdvPurchase. ProductType .CONSUMABLE

j3k0 commented 5 months ago

What really misled me was that CdvPurchase.PAID_SUBSCRIPTION works for Apple, but not for Google 😂

Loading subscriptions info is a different low-level API on Android, so this needs to be correctly defined. On iOS it's the same API calls for subscriptions and other in-app purchase products. I will fix the guide.