AlexDisler / cordova-plugin-inapppurchase

A lightweight cordova plugin for in app purchases on iOS/Android
316 stars 191 forks source link

ionic Unknown product identifier #76

Open waterkcl opened 7 years ago

waterkcl commented 7 years ago
$scope.pay = function () {
    inAppPurchase
    .buy('my.productId')
        .then(function (data) {
            console.log(JSON.stringify(data));
            console.log('consuming transactionId: ' + data.transactionId);
            return inAppPurchase.consume(data.type, data.receipt, data.signature);
        })
        .then(function () {
                var alertPopup = $ionicPopup.alert({
                title: 'Purchase was successful!',
                template: 'Check your console log for the transaction data'
            });
            console.log('consume done!');
            $ionicLoading.hide();
        })
        .catch(function (err) {
            $ionicLoading.hide();
            console.log(err);
            $ionicPopup.alert({
            title: 'Something went wrong',
            template: 'Check your console log for the error details'
        });
    });
};

At Xcode Console display 2016-10-29 22:25:09.749 tutorial[15049:3900446] RMStore: unknown product id my.productId 2016-10-29 22:25:09.868 tutorial[15049:3900446] {"errorMessage":"Unknown product identifier","errorCode":100}

i am using consumable for testing

pls help!

vernondegoede commented 7 years ago

I have the exact same issue! I tried the cordova-plugin-purchase plugin before, but that one didn't work as well...

https://github.com/j3k0/cordova-plugin-purchase/issues/526

@waterkcl Just to be sure, did you have an approved In App Purchase method? And did you manage to resolve this issue somehow?

vernondegoede commented 7 years ago

Your code / steps to reproduce

window.inAppPurchase
    .buy(FLOXER_PRO_IOS_PRODUCT_ID)
    .then(function(data) {
        console.log(data);
    })
    .catch(function(err) {
        console.log(err);
    });

Console output

objc[56399]: Class PLBuildVersion is implemented in both /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/AssetsLibraryServices.framework/AssetsLibraryServices (0x11624b998) and /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/PhotoLibraryServices.framework/PhotoLibraryServices (0x116070d38). One of the two will be used. Which one is undefined.
2016-11-02 09:11:57.042 Floxer[56399:2583746] Apache Cordova native platform version 4.2.0 is starting.
2016-11-02 09:11:57.043 Floxer[56399:2583746] Multi-tasking -> Device: YES, App: YES
2016-11-02 09:11:57.049 Floxer[56399:2583746] 

Started backup to iCloud! Please be careful.
Your application might be rejected by Apple if you store too much data.
For more information please read "iOS Data Storage Guidelines" at:
https://developer.apple.com/icloud/documentation/data-storage/
To disable web storage backup to iCloud, set the BackupWebStorage preference to "local" in the Cordova config.xml file

2016-11-02 09:11:57.080 Floxer[56399:2583746] Using UIWebView
2016-11-02 09:11:57.082 Floxer[56399:2583746] [CDVTimer][handleopenurl] 0.049055ms
2016-11-02 09:11:57.083 Floxer[56399:2583746] [CDVTimer][intentandnavigationfilter] 1.541018ms
2016-11-02 09:11:57.084 Floxer[56399:2583746] [CDVTimer][gesturehandler] 0.060976ms
2016-11-02 09:11:57.084 Floxer[56399:2583746] [CDVTimer][TotalPluginStartup] 2.298057ms
2016-11-02 09:11:57.321 Floxer[56399:2583746] Resetting plugins due to page load.
2016-11-02 09:11:57.510 Floxer[56399:2583746] Finished load of: file:///Users/vernon/Library/Developer/CoreSimulator/Devices/6CC2E033-A64A-4207-90E4-F3DAB95F3A7F/data/Containers/Bundle/Application/AD66D84D-30E7-452B-B950-15C40917B169/Floxer.app/www/index.html
2016-11-02 09:11:57.589361 Floxer[56399:2583799] [] nw_host_stats_add_src recv too small, received 24, expected 28
2016-11-02 09:11:57.591773 Floxer[56399:2583799] [] ____nwlog_simulate_crash_inner_block_invoke dlopen CrashReporterSupport failed
2016-11-02 09:11:57.591938 Floxer[56399:2583799] [] __nwlog_err_simulate_crash simulate crash failed "nw_socket_set_common_sockopts setsockopt SO_NOAPNFALLBK failed: [42] Protocol not available"
2016-11-02 09:11:57.592546 Floxer[56399:2583799] [] nw_socket_set_common_sockopts setsockopt SO_NOAPNFALLBK failed: [42] Protocol not available, dumping backtrace:
        [x86_64] libnetcore-856.20.4
    0   libsystem_network.dylib             0x000000010c272682 __nw_create_backtrace_string + 123
    1   libnetwork.dylib                    0x000000010c875932 nw_socket_add_input_handler + 3100
    2   libnetwork.dylib                    0x000000010c8534f4 nw_endpoint_flow_attach_protocols + 3768
    3   libnetwork.dylib                    0x000000010c852511 nw_endpoint_flow_setup_socket + 563
    4   libnetwork.dylib                    0x000000010c851270 -[NWConcrete_nw_endpoint_flow startWithHandler:] + 2612
    5   libnetwork.dylib                    0x000000010c86c44d nw_endpoint_handler_path_change + 1261
    6   libnetwork.dylib                    0x000000010c86be7c nw_endpoint_handler_start + 570
    7   libnetwork.dylib                    0x000000010c883ae5 nw_endpoint_resolver_start_next_child + 2240
    8   libdispatch.dylib                   0x000000010bfef980 _dispatch_call_block_and_release + 12
    9   libdispatch.dylib                   0x000000010c0190cd _dispatch_client_callout + 8
    10  libdispatch.dylib                   0x000000010bff6e6b _dispatch_queue_serial_drain + 236
    11  libdispatch.dylib                   0x000000010bff7b9f _dispatch_queue_invoke + 1073
    12  libdispatch.dylib                   0x000000010bffa3b7 _dispatch_root_queue_drain + 720
    13  libdispatch.dylib                   0x000000010bffa08b _dispatch_worker_thread3 + 123
    14  libsystem_pthread.dylib             0x000000010c3c24de _pthread_wqthread + 1129
    15  libsystem_pthread.dylib             0x000000010c3c0341 start_wqthread + 13
2016-11-02 09:11:57.940235 Floxer[56399:2583796] [] nw_host_stats_add_src recv too small, received 24, expected 28
2016-11-02 09:11:57.941952 Floxer[56399:2583796] [] __nwlog_err_simulate_crash simulate crash already simulated "nw_socket_set_common_sockopts setsockopt SO_NOAPNFALLBK failed: [42] Protocol not available"
2016-11-02 09:11:57.942291 Floxer[56399:2583796] [] nw_socket_set_common_sockopts setsockopt SO_NOAPNFALLBK failed: [42] Protocol not available, dumping backtrace:
        [x86_64] libnetcore-856.20.4
    0   libsystem_network.dylib             0x000000010c272682 __nw_create_backtrace_string + 123
    1   libnetwork.dylib                    0x000000010c875932 nw_socket_add_input_handler + 3100
    2   libnetwork.dylib                    0x000000010c8534f4 nw_endpoint_flow_attach_protocols + 3768
    3   libnetwork.dylib                    0x000000010c852511 nw_endpoint_flow_setup_socket + 563
    4   libnetwork.dylib                    0x000000010c851270 -[NWConcrete_nw_endpoint_flow startWithHandler:] + 2612
    5   libnetwork.dylib                    0x000000010c86c44d nw_endpoint_handler_path_change + 1261
    6   libnetwork.dylib                    0x000000010c86be7c nw_endpoint_handler_start + 570
    7   libnetwork.dylib                    0x000000010c883ae5 nw_endpoint_resolver_start_next_child + 2240
    8   libdispatch.dylib                   0x000000010bfef980 _dispatch_call_block_and_release + 12
    9   libdispatch.dylib                   0x000000010c0190cd _dispatch_client_callout + 8
    10  libdispatch.dylib                   0x000000010bff6e6b _dispatch_queue_serial_drain + 236
    11  libdispatch.dylib                   0x000000010bff7b9f _dispatch_queue_invoke + 1073
    12  libdispatch.dylib                   0x000000010bffa3b7 _dispatch_root_queue_drain + 720
    13  libdispatch.dylib                   0x000000010bffa08b _dispatch_worker_thread3 + 123
    14  libsystem_pthread.dylib             0x000000010c3c24de _pthread_wqthread + 1129
    15  libsystem_pthread.dylib             0x000000010c3c0341 start_wqthread + 13
2016-11-02 09:11:58.380862 Floxer[56399:2583813] [] nw_host_stats_add_src recv too small, received 24, expected 28
2016-11-02 09:11:58.382901 Floxer[56399:2583813] [] __nwlog_err_simulate_crash simulate crash already simulated "nw_socket_set_common_sockopts setsockopt SO_NOAPNFALLBK failed: [42] Protocol not available"
2016-11-02 09:11:58.383411 Floxer[56399:2583813] [] nw_socket_set_common_sockopts setsockopt SO_NOAPNFALLBK failed: [42] Protocol not available, dumping backtrace:
        [x86_64] libnetcore-856.20.4
    0   libsystem_network.dylib             0x000000010c272682 __nw_create_backtrace_string + 123
    1   libnetwork.dylib                    0x000000010c875932 nw_socket_add_input_handler + 3100
    2   libnetwork.dylib                    0x000000010c8534f4 nw_endpoint_flow_attach_protocols + 3768
    3   libnetwork.dylib                    0x000000010c852511 nw_endpoint_flow_setup_socket + 563
    4   libnetwork.dylib                    0x000000010c851270 -[NWConcrete_nw_endpoint_flow startWithHandler:] + 2612
    5   libnetwork.dylib                    0x000000010c86c44d nw_endpoint_handler_path_change + 1261
    6   libnetwork.dylib                    0x000000010c86be7c nw_endpoint_handler_start + 570
    7   libnetwork.dylib                    0x000000010c883ae5 nw_endpoint_resolver_start_next_child + 2240
    8   libdispatch.dylib                   0x000000010bfef980 _dispatch_call_block_and_release + 12
    9   libdispatch.dylib                   0x000000010c0190cd _dispatch_client_callout + 8
    10  libdispatch.dylib                   0x000000010bff6e6b _dispatch_queue_serial_drain + 236
    11  libdispatch.dylib                   0x000000010bff7b9f _dispatch_queue_invoke + 1073
    12  libdispatch.dylib                   0x000000010bffa3b7 _dispatch_root_queue_drain + 720
    13  libdispatch.dylib                   0x000000010bffa08b _dispatch_worker_thread3 + 123
    14  libsystem_pthread.dylib             0x000000010c3c24de _pthread_wqthread + 1129
    15  libsystem_pthread.dylib             0x000000010c3c0341 start_wqthread + 13
2016-11-02 09:11:58.394127 Floxer[56399:2583797] [] nw_host_stats_add_src recv too small, received 24, expected 28
2016-11-02 09:11:58.395902 Floxer[56399:2583797] [] __nwlog_err_simulate_crash simulate crash already simulated "nw_socket_set_common_sockopts setsockopt SO_NOAPNFALLBK failed: [42] Protocol not available"
2016-11-02 09:11:58.396252 Floxer[56399:2583797] [] nw_socket_set_common_sockopts setsockopt SO_NOAPNFALLBK failed: [42] Protocol not available, dumping backtrace:
        [x86_64] libnetcore-856.20.4
    0   libsystem_network.dylib             0x000000010c272682 __nw_create_backtrace_string + 123
    1   libnetwork.dylib                    0x000000010c875932 nw_socket_add_input_handler + 3100
    2   libnetwork.dylib                    0x000000010c8534f4 nw_endpoint_flow_attach_protocols + 3768
    3   libnetwork.dylib                    0x000000010c852511 nw_endpoint_flow_setup_socket + 563
    4   libnetwork.dylib                    0x000000010c851270 -[NWConcrete_nw_endpoint_flow startWithHandler:] + 2612
    5   libnetwork.dylib                    0x000000010c86c44d nw_endpoint_handler_path_change + 1261
    6   libnetwork.dylib                    0x000000010c86be7c nw_endpoint_handler_start + 570
    7   libnetwork.dylib                    0x000000010c883ae5 nw_endpoint_resolver_start_next_child + 2240
    8   libdispatch.dylib                   0x000000010bfef980 _dispatch_call_block_and_release + 12
    9   libdispatch.dylib                   0x000000010c0190cd _dispatch_client_callout + 8
    10  libdispatch.dylib                   0x000000010bff6e6b _dispatch_queue_serial_drain + 236
    11  libdispatch.dylib                   0x000000010bff7b9f _dispatch_queue_invoke + 1073
    12  libdispatch.dylib                   0x000000010bffa3b7 _dispatch_root_queue_drain + 720
    13  libdispatch.dylib                   0x000000010bffa08b _dispatch_worker_thread3 + 123
    14  libsystem_pthread.dylib             0x000000010c3c24de _pthread_wqthread + 1129
    15  libsystem_pthread.dylib             0x000000010c3c0341 start_wqthread + 13
2016-11-02 09:11:58.397042 Floxer[56399:2583797] [] nw_host_stats_add_src recv too small, received 24, expected 28
2016-11-02 09:11:58.399047 Floxer[56399:2583797] [] __nwlog_err_simulate_crash simulate crash already simulated "nw_socket_set_common_sockopts setsockopt SO_NOAPNFALLBK failed: [42] Protocol not available"
2016-11-02 09:11:58.399462 Floxer[56399:2583797] [] nw_socket_set_common_sockopts setsockopt SO_NOAPNFALLBK failed: [42] Protocol not available, dumping backtrace:
        [x86_64] libnetcore-856.20.4
    0   libsystem_network.dylib             0x000000010c272682 __nw_create_backtrace_string + 123
    1   libnetwork.dylib                    0x000000010c875932 nw_socket_add_input_handler + 3100
    2   libnetwork.dylib                    0x000000010c8534f4 nw_endpoint_flow_attach_protocols + 3768
    3   libnetwork.dylib                    0x000000010c852511 nw_endpoint_flow_setup_socket + 563
    4   libnetwork.dylib                    0x000000010c851270 -[NWConcrete_nw_endpoint_flow startWithHandler:] + 2612
    5   libnetwork.dylib                    0x000000010c86c44d nw_endpoint_handler_path_change + 1261
    6   libnetwork.dylib                    0x000000010c86be7c nw_endpoint_handler_start + 570
    7   libnetwork.dylib                    0x000000010c883ae5 nw_endpoint_resolver_start_next_child + 2240
    8   libdispatch.dylib                   0x000000010bfef980 _dispatch_call_block_and_release + 12
    9   libdispatch.dylib                   0x000000010c0190cd _dispatch_client_callout + 8
    10  libdispatch.dylib                   0x000000010bff6e6b _dispatch_queue_serial_drain + 236
    11  libdispatch.dylib                   0x000000010bff7b9f _dispatch_queue_invoke + 1073
    12  libdispatch.dylib                   0x000000010bffa3b7 _dispatch_root_queue_drain + 720
    13  libdispatch.dylib                   0x000000010bffa08b _dispatch_worker_thread3 + 123
    14  libsystem_pthread.dylib             0x000000010c3c24de _pthread_wqthread + 1129
    15  libsystem_pthread.dylib             0x000000010c3c0341 start_wqthread + 13
2016-11-02 09:12:21.067869 Floxer[56399:2583746] [MC] System group container for systemgroup.com.apple.configurationprofiles path is /Users/vernon/Library/Developer/CoreSimulator/Devices/6CC2E033-A64A-4207-90E4-F3DAB95F3A7F/data/Containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles
2016-11-02 09:12:21.068676 Floxer[56399:2583746] [MC] Reading from private effective user settings.
2016-11-02 09:12:26.059 Floxer[56399:2583746] RMStore: unknown product id com.coqtail.floxer.pro_account

Type of product you are working with consumable/non-consumable/subscription

subscription

Version of cordova

6.4.0

Version of iOS/Android

iOS 10.1

galcivar commented 7 years ago

I have the same issue: iOS In-app purchase nightmare Apple Suport Forums

vernondegoede commented 7 years ago

@galcivar Did you find a solution yet? I'm still experiencing issues retrieving IAP products 👎

galcivar commented 7 years ago

@vernondegoede Nothing, still waiting for Apple support to try and help (they get a 7-day thanksgiving holiday)...no response from anywhere else yet.

vernondegoede commented 7 years ago

@galcivar Same problem. I guess this issue is related to the issue I mentioned in the RMStore repo before. Even when we managed to get this working, our app will probably be rejected because it doesn't support IPV6.

galcivar commented 7 years ago

@vernondegoede agreed. I think its RMStore's issue, although it does render the plugin useless for iOS IAPs, which makes this issue critical for the plugin.

stoconnor commented 7 years ago

Any updates on this issue? Facing this problem now with my app. Is there an alternative plugin to get IAP for iOS?

stoconnor commented 7 years ago

I've fixed this problem, it's not an issue with RMStore. I added additional logging to RMStore.m and realized the product list is empty, so nothing to do with product identifiers.

You need to have a 'Paid Applications' contract in iTunes Connect for your Paid products to appear. To do this go to your iTunes Connect homepage and select 'Agreements, Tax, and Banking'. Fill out your Contact, Bank and Tax info. Submit the form and wait 15 minutes for contract to process.

A good way to test is to add a free consumable product, this does not need a 'Paid Applications' contract.

rajeshvishnani commented 7 years ago

@stoconnor I have the Paid Applications Contract there, I am Still facing this issue, here are the logs ar 23 21:29:55 6-111-201-123 BoxyPay[13585]: THREAD WARNING: ['PaymentsPlugin'] took '26.597900' ms. Plugin should use a background thread. Mar 23 21:29:55 6-111-201-123 BoxyPay[13585]: {"errorMessage":"Unknown product identifier","errorCode":100} Mar 23 21:29:55 6-111-201-123 BoxyPay[13585]: THREAD WARNING: ['Console'] took '44.781738' ms. Plugin should use a background thread.

Please Help

mkobcc13 commented 7 years ago

Finally fixed it with the simple fact, that StoreKit wants a request of the products first. Just ask for the productData and use it right after for the new request. It solved my long searched problem:

buyStuff(yourProductInformationObject){

    this.iap
     .getProducts([yourProductInformationObject.buyId]) //just ask for this one element
     .then((productData) => {

          this.iap
            .buy(productData[0].productId)
            .then((data)=> {
          })
            .catch((err)=> {

              console.log(err);

            });

    })
     .catch((err) => {
       console.log(err);
     });

}

Allan-Nava commented 7 years ago

I have these errors:

InAppPurchase[objc]: About to do IAP 2017-09-26 15:12:50.843104+0200 Sportube[3181:1519465] *** WebKit discarded an uncaught exception in the webView:decidePolicyForNavigationAction:request:frame:decisionListener: delegate: Invalid product identifier: (null)

scottopolis commented 6 years ago

I'm having this issue as well, but it was all working before I submitted for iOS. After I submitted and it was approved, I downloaded from the app store and now it says "Unknown product identifier." Anybody know what could cause this?

Inframatic commented 6 years ago

A question to everyone who is having this problem: Do all attempted purchases give a 'Unknown Product Identifier" error or is it, like in my case, only with a specific user trying to make purchases?

scottopolis commented 6 years ago

In my case the problem was that I did not submit the in app purchase for review, just the app itself. So the IAP was not live, the problem was not with this plugin.

giladrom commented 6 years ago

@scottopolis What do you mean 'Submit the In App Purchase for review'? I'm having the same issue and for the life of me can't figure out what I did wrong. I completed all of the agreements and double /triple checked them, added products in iTunes connect, but still getting an empty array.

scottopolis commented 6 years ago

@giladrom in my case I had not completed the IAP listing properly, so when I submitted the app, it did not activate the in app purchase. You need to make sure there are no errors with your IAP, and make sure it's cleared for sale, then submit the app. When it is approved, the IAP will be approved as well. https://developer.apple.com/library/content/technotes/tn2259/_index.html

giladrom commented 6 years ago

@scottopolis So I must submit the app before I can test the IAP? I've completed all of the steps listed in the Apple Developer technotes, Cleared my IAP for sale and logged in using a Sandbox test account yet I still get "RMStore: invalid product with id com.xxx.xxxxxx". Did you have to officially submit the app to the app store before it actually worked?

scottopolis commented 6 years ago

No you don't have to submit first I don't think. https://alexdisler.com/2016/04/04/testing-cordova-in-app-purchases-on-ios-android/

giladrom commented 6 years ago

@scottopolis "make sure it's cleared for sale, then submit the app. When it is approved, the IAP will be approved as well. " <-- Doesn't this mean I have to submit it before I can test IAP?

giladrom commented 6 years ago

Just leaving this as an update here in case anyone else has the same issue as I did - For some reason I tried using the app name ('com.domain.app') as a parameter instead of the actual product names ('com.domain.app.product').