j3k0 / cordova-plugin-purchase

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

ios v13 store.findInVerifiedReceipts does not show updates #1402

Closed bartushak007 closed 6 months ago

bartushak007 commented 1 year ago

hey!

After a successful call to the order method for subscription and validation of the receipt, the findInVerifiedReceipts method displays the previous information state like { isExpired: true,...} but the subscription was ordered successfully. To retrieve the updated information, the app needs to be closed and reopened, after which the findInVerifiedReceipts method returns the updated information where { isExpired: false,...}.
How after purchase I can know that subscription is purchased?

method call example: CdvPurchase.store.findInVerifiedReceipts(CdvPurchase.store.get(one_month_premium_ios))

also, this method always returns undefined on Android even if the subscription is active

j3k0 commented 1 year ago

It should work.

Can you share some source code and more context? Do you have your own custom receipt validator? If so, can you share logs including what is sent and received from the validator?

bartushak007 commented 1 year ago

thanks for your answer. I am trying to update the plugin from 11v to 13v

I have auto-renewal subscriptions ios: The order method is working but the findInVerifiedReceipts method does not return the updated state right after a successful order. To get it updated I need to refresh the app

android: findInVerifiedReceipts - always returns undefined - I tried to call it after 5-second delay but it also returned undefined

initialization

document.addEventListener("deviceready", () => {
    let registerList = [];
    const store = CdvPurchase.store;
    const ProductType = CdvPurchase.ProductType;
    const Platform = CdvPurchase.Platform;
    if (window.device.platform === "iOS") {
        registerList = [
            {
                id: one_month_premium_ios,
                type: ProductType.PAID_SUBSCRIPTION,
                platform: Platform.APPLE_APPSTORE,
            },
            {
                id: three_months_premium_ios,
                type: ProductType.PAID_SUBSCRIPTION,
                platform: Platform.APPLE_APPSTORE,
            },
            {
                id: one_year_premium_ios,
                type: ProductType.PAID_SUBSCRIPTION,
                platform: Platform.APPLE_APPSTORE,
            },
        ];
    }
    if (window.device.platform === "Android") {
        registerList = [
            {
                id: premium_android,
                type: ProductType.PAID_SUBSCRIPTION,
                platform: Platform.GOOGLE_PLAY,
            },
        ];
    }
    store.register(registerList);
    store.validator = "https://validator.fovea.cc/v1/validate?appName=****&apiKey=*****";

    store
        .when()
        .approved((transaction) => {
            transaction.verify();
        })
        .verified((receipt) => {
            receipt.finish();
        })
        .finished(() => {
            // after purchase it returns previous value but when refresh app then purchase information is updated
            store.findInVerifiedReceipts(store.get(one_month_premium_ios)); 
        })
        .receiptUpdated(() => {})
        .productUpdated((p) => self.updateSubscriptionsData(p));

    store.error((err) =>
        self.updatePurchaseStateAction({
            failedMessage: err.message,
            pending: false,
            id: null,
        })
    );
    store.initialize([Platform.APPLE_APPSTORE, Platform.GOOGLE_PLAY]).then(() => {});
});

order:

const offer = window.CdvPurchase.store.get(one_month_premium_ios).offers[0]
window.CdvPurchase.store.order(offer)

@j3k0

bartushak007 commented 1 year ago

Have you ever encountered a similar problem? Or maybe you know what could be causing it @j3k0

j3k0 commented 1 year ago

@bartushak007 I know it's a late answer. Did you solved it? Maybe you should try using validator.iaptic.com instead of validator.fovea.cc?

bartushak007 commented 1 year ago

Thanks for your answer. We have an app in production and the reason I was testing it with FOVEA was because I don't know what happens with new purchases if I change FOVEA to IAPTIC in google cloud. I mean there will be some users who will use the old version of the app

the app with those users will validate receipts with fovea but all transactions will go to iaptic

@j3k0

j3k0 commented 1 year ago

@bartushak007 traffic for your app can be re-routed so all requests end-up in iaptic.com - Please contact support@iaptic.com to set this up.

michaelbutler1998 commented 9 months ago

@bartushak007 did you find a solution to this, or did you have to move to Iaptic?

I have two versions of my app, one that works fine with Iaptic, and one that does not seem to work with Fovea. I was wondering before setting up Iaptic for the one I use with Fovea, if you found a resolution?

Diex commented 7 months ago

I'm using no validation. on android I still get: receiptsVerified: undefined at this.myStore.ready() callback.

bartushak007 commented 7 months ago

@bartushak007 did you find a solution to this, or did you have to move to Iaptic?

I have two versions of my app, one that works fine with Iaptic, and one that does not seem to work with Fovea. I was wondering before setting up Iaptic for the one I use with Fovea, if you found a resolution?

I moved to iaptick and the problem got resolved.

MarcelSchuermann commented 6 months ago

my subscription on apple iOS iaptic (v3) with store (v13) does not work. :( See my post in issue #1363 - any ideas?