j3k0 / cordova-plugin-purchase

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

[iOS] Cancelled and refunded callbacks not invoked #1305

Open sshravag opened 2 years ago

sshravag commented 2 years ago

Observed behavior

Hello, We are trying to incorporate in app purchase and we are not getting proper callbacks.

  1. Cancelled
  2. Refunded

Overview: We are developing in app purchase in our hybrid application using IONIC. We have incorporated the plugin for In App Purchase:

• Device version iPhone 6s Plus • iOS version : iOS 15.5

Steps:

  1. Registered In app subscriptions on App Store Connect
  2. In mobile app I

    1. Call OS ready function

    2. Register the Product this.store.register({ id: this.PRODUCT_IOS_MONTHLY_RECURRING_ID, type: this.store.NON_CONSUMABLE });

    3. Register the callbacks this.store.when(this.PRODUCT_IOS_MONTHLY_RECURRING_ID) .cancelled(this.purchaseCancelled) .updated(this.purchaseMonthlyUpdated) .approved(this.purchaseApproved) .verified(this.purchaseVerified) .refunded(this.purchaseRefunded) .owned(this.purchaseOwned);

    4. Call Refresh

Now after this I am getting the data for this Product and I can call purchase.

{"id":"2022-06-21T04:42:53.592Z","value":"updated { id : 1MonthRecurring , alias : 1MonthRecurring , type : non consumable , group : 20959546 , state : registered , title : 1-Month Recurring Subscription , description : Monthly Recurring Subscription , priceMicros :9990000, price : $9.99 , currency : USD , countryCode : US , loaded :false, canPurchase :false, owned :false, introPrice :null, introPriceMicros :null, introPricePeriod :null, introPricePeriodUnit :null, introPricePaymentMode :null, ineligibleForIntroPrice :null, discounts :[], downloading :false, downloaded :false, additionalData :null, transaction :null, billingPeriod :1, billingPeriodUnit : Month }"}

After purchase it gives me owned state.

{"id":"2022-06-21T04:42:57.198Z","value":"updated { id : 1MonthRecurring , alias : 1MonthRecurring , type : non consumable , group : 20959546 , state : owned , title : 1-Month Recurring Subscription , description : Monthly Recurring Subscription , priceMicros :9990000, price : $9.99 , currency : USD , countryCode : US , loaded :true, canPurchase :false, owned :true, introPrice :null, introPriceMicros :null, introPricePeriod :null, introPricePeriodUnit :null, introPricePaymentMode :null, ineligibleForIntroPrice :null, discounts :[], downloading :false, downloaded :false, additionalData :null, transaction :{ type : ios-appstore , id : 2000000084829744 , appStoreReceipt : ....

Now when I go to settings and sandbox account and cancel subscription I am not getting the cancelled callback.

Also I should get the refund callback. Although in settings screen I see that the subscription is not in owned state still the application shows OWNED.

I would want to know how can I get the cancelled and refunded callbacks

Code: Include logs with store.verbosity = store.DEBUG

Expected behavior

Should get the callbacks for refund and cancel but not getting them.

System Info

Output of cordova info.

Cordova Packages:

cli: 10.0.0
    common: 4.0.2
    create: 3.0.0
    lib: 10.1.0
        common: 4.0.2
        fetch: 3.0.1
        serve: 4.0.0

Project Installed Platforms:

android: 9.1.0
browser: 6.0.0
ios: 6.2.0

Project Installed Plugins:

cordova-plugin-add-swift-support: 2.0.2
cordova-plugin-android-permissions: 1.0.2
cordova-plugin-app-version: 0.1.9
cordova-plugin-device: 2.0.2
cordova-plugin-file: 6.0.2
cordova-plugin-fingerprint-aio: 3.0.1
cordova-plugin-google-analytics: 1.8.6
cordova-plugin-inappbrowser: 4.1.0
cordova-plugin-ionic-keyboard: 2.2.0
cordova-plugin-ionic-webview: 5.0.0
cordova-plugin-market: 1.2.0
cordova-plugin-nativestorage: 2.3.2
cordova-plugin-network-information: 2.0.2
cordova-plugin-purchase: 11.0.0
cordova-plugin-splashscreen: 6.0.0
cordova-plugin-statusbar: 2.4.3
cordova-plugin-whitelist: 1.3.3
cordova-plugin-wkwebview-engine: 1.2.2
cordova-sqlite-storage: 6.0.0

Environment:

OS: macOS 12.4 (21F79) (darwin 21.5.0) x64
Node: v16.14.0
npm: 8.3.1

android Environment:

android:

ios Environment:

xcodebuild:

Xcode 13.4.1 Build version 13F100

Project Setting Files:

config.xml:

<?xml version='1.0' encoding='utf-8'?>

<content src="index.html" />
<access origin="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<allow-navigation href="*" />
<preference name="Orientation" value="portrait" />
<preference name="ScrollEnabled" value="false" />
<preference name="android-minSdkVersion" value="22" />
<preference name="android-targetSdkVersion" value="30" />
<preference name="BackupWebStorage" value="none" />
<preference name="SplashMaintainAspectRatio" value="true" />
<preference name="FadeSplashScreenDuration" value="300" />
<preference name="SplashShowOnlyFirstTime" value="false" />
<preference name="SplashScreen" value="screen" />
<preference name="SplashScreenDelay" value="5000" />
<platform name="android">
    <edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application" xmlns:android="http://schemas.android.com/apk/res/android">
        <preference name="AndroidPersistentFileLocation" value="Compatibility" />
        <application android:networkSecurityConfig="@xml/network_security_config" />
    </edit-config>
    <resource-file src="resources/android/xml/network_security_config.xml" target="app/src/main/res/xml/network_security_config.xml" />
    <allow-intent href="market:*" />
</platform>
<platform name="ios">
    <allow-intent href="itms:*" />
    <allow-intent href="itms-apps:*" />
    <icon height="29" src="resources/ios/icon/icon-small.png" width="29" />

    <splash height="2732" src="resources/ios/splash/Default@2x~universal~anyany.png" width="2732" />
</platform>
<plugin name="cordova-plugin-device" spec="2.0.2" />

package.json:

--- Start of Cordova JSON Snippet --- { "plugins": { "cordova-plugin-device": {}, "cordova-plugin-splashscreen": {}, "cordova-plugin-ionic-keyboard": {}, "cordova-plugin-fingerprint-aio": {}, "cordova-plugin-nativestorage": {}, "cordova-plugin-android-permissions": {}, "cordova-plugin-app-version": {}, "cordova-plugin-network-information": {}, "cordova-plugin-statusbar": {}, "cordova-plugin-market": {}, "cordova-plugin-whitelist": {}, "cordova-plugin-ionic-webview": {}, "cordova-plugin-inappbrowser": {}, "cordova-plugin-google-analytics": {}, "cordova-sqlite-storage": {}, "cordova-plugin-purchase": {} }, "platforms": [ "browser", "ios", "android" ] } --- End of Cordova JSON Snippet ---

alyleite commented 2 years ago

Same thing here with expired status