Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Feb 19, 2013, 04:59 AM   #1
Nobita.ZZZ
macrumors newbie
 
Join Date: Jan 2012
Mac app In-app Purchase : Invalid product ID

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?

Last edited by maflynn; Feb 19, 2013 at 12:10 PM. Reason: Changed quote tags to code tags
Nobita.ZZZ is offline   1 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 06:09 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC