Mac app In-app Purchase : Invalid product ID

Discussion in 'Mac Programming' started by Nobita.ZZZ, Feb 19, 2013.

  1. Nobita.ZZZ, Feb 19, 2013
    Last edited by a moderator: Feb 19, 2013

    macrumors newbie

    Joined:
    Jan 11, 2012
    #1
    Thanks for reading. I'm having problem with Mac app In-app Purchase.<br/>
    I just setup Mac developer account with $99 subscription.<br/>
    1) Go to Developer Certificate Utility, create App ID: com.mpham.TestIAP, create certificate, add my Mac ID to System list. Final, add Provisioning profile (development)<br/>
    2) Go to iTunes connect, create App: com.mpham.TestIAP, create IAP: com.mpham.TestIAP.IAP1. Final, make app status to "Waiting For Upload"<br/>
    3) I create simple Cocoa app: com.mpham.TestIAP, choose Code sign to com.mpham.TestIAP <br/>

    Code:
        //
        //  AppDelegate.h
        //
        
        #import <Cocoa/Cocoa.h>
        #import <StoreKit/StoreKit.h>
        
        
        @interface AppDelegate : NSObject <NSApplicationDelegate, SKProductsRequestDelegate, SKProductsRequestDelegate, SKPaymentTransactionObserver>
        {
            SKProduct *proUpgradeProduct;
            SKProductsRequest *productsRequest;
        }
        
        @property (assign) IBOutlet NSWindow *window;
        @end

    and

    Code:
        //
        //  AppDelegate.m
        //
        
        #import "AppDelegate.h"
        
        #define k1 @"com.mpham.TestIAP.IAP1"
        #define k2 @"IAP1"
        
        
        @implementation AppDelegate
        
        - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
        {
            if ([SKPaymentQueue canMakePayments])
            {
                [self requestIAP1];
                [self requestIAP2];
                
            }
            
        
        }
        
        
        - (void)requestIAP1
        {
            NSLog(@"requestIAP1");
            NSSet *productIdentifiers = [NSSet setWithObject:k1];
            productsRequest = [[SKProductsRequest alloc] initWithProductIdentifiers:productIdentifiers];
            productsRequest.delegate = self;
            [productsRequest start];
            
        }
        - (void)requestIAP2
        {
            NSLog(@"requestIAP2");
            NSSet *productIdentifiers = [NSSet setWithObject:k2];
            productsRequest = [[SKProductsRequest alloc] initWithProductIdentifiers:productIdentifiers];
            productsRequest.delegate = self;
            [productsRequest start];
            
        }
        
        #pragma mark SKProductsRequestDelegate methods
        
        - (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response
        {
            NSArray *products = [[NSArray alloc] initWithArray:response.products];
            
            
            for(SKProduct *item in products)
            {
                NSLog(@"Product title: %@" , item.localizedTitle);
                NSLog(@"Product description: %@" , item.localizedDescription);
                NSLog(@"Product price: %@" , item.price);
                NSLog(@"Product id: %@" , item.productIdentifier);
            }
            
            for (NSString *invalidProductId in response.invalidProductIdentifiers)
            {
                NSLog(@"Invalid : %@" , invalidProductId);
            }
        }
        
        #pragma mark - PaymentQueue
        
        -(void)paymentQueue:(SKPaymentQueue *)queue removedTransactions:(NSArray *)transactions
        {
        }
        
        -(void)paymentQueue:(SKPaymentQueue *)queue restoreCompletedTransactionsFailedWithError:(NSError *)error
        {
        }
        
        -(void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions
        {
        }
        
        -(void)paymentQueueRestoreCompletedTransactionsFinished:(SKPaymentQueue *)queue
        {
        }
        
        @end

    It's run and show the log

    Code:
        2013-02-18 16:59:14.948 TestIAP[12646:403] requestIAP1
        2013-02-18 16:59:14.951 TestIAP[12646:403] requestIAP2
        2013-02-18 16:59:15.939 TestIAP[12646:1b03] Invalid : IAP1
        2013-02-18 16:59:16.043 TestIAP[12646:1b03] Invalid : com.mpham.TestIAP.IAP1
    It's mean there is Invalid product, but I created product in iTunesConnect, could anyone please help me?
     

Share This Page