Pages

Tuesday, February 26, 2013

Mac app In-app Purchase : Invalid product ID

Thanks for reading. I'm having problem with Mac app In-app Purchase.

I just setup Mac developer account with $99 subscription.

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)

2) Go to iTunes connect, create App: com.mpham.TestIAP, create IAP: com.mpham.TestIAP.IAP1. Final, make app status to "Waiting For Upload"

3) I create simple Cocoa app: com.mpham.TestIAP, choose Code sign to com.mpham.TestIAP

 

 

    //

    //  AppDelegate.h

    //

   

    #import

    #import

   

   

    @interface AppDelegate : NSObject

    {

        SKProduct *proUpgradeProduct;

        SKProductsRequest *productsRequest;

    }

   

    @property (assign) IBOutlet NSWindow *window;

    @end

 

 

 

 

and

 

 

    //

    //  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

 

 

    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?


View the original article here

0 comments:

Post a Comment