title: Mac OS LION 10.7 In-App Purchase
body: <p>I'm testing the in-app Purchase new feature available on Mac OS Lion,I'm stuck at the receipt validation part, My code always fail at this part as if i'm not connected to sandbox or the application receipt never send me the receipt as the <strong>"exit(173);"</strong> is supposed to work.</p>
  
  <p>Those are My steps:</p>
  
  <p>1-Register an explicit App ID for the application. ([Member Center][1]).</p>
  
  <p>2-Add an application on itunes with App ID with status :"prepare for upload".</p>
  
  <p>3-Add in app purchase products product.</p>
  
  <p>5-Create a test user 
  6-Create, download, and install a Mac Signing Certificate that uses App ID enabled for In-App Purchase7-development provisioning profil with this certificate. ([Member Center][1]).</p>
  
  <p>7-Add Provisioning profile to the Xcode Observer.</p>
  
  <p>8-Enter the Bundle Identifier portion of App ID in the Bundle Identifier field of My Target's Info pane in Xcode.</p>
  
  <p>9-Sign the code with my Certificate . </p>
  
  <p><strong>NOTE:</strong> I'm Testing the Application on the finder not the Xcode Debuger.</p>
  
  <p>Here is application Code:</p>
  
  <p>Header:</p>
  
  <pre><code>#import &lt;Cocoa/Cocoa.h&gt;
  #import &lt;StoreKit/StoreKit.h&gt;
  @interface AppDelegate : NSObject &lt;NSApplicationDelegate,SKProductsRequestDelegate,SKPaymentTransactionObserver&gt;
  {
      NSWindow *window;
      IBOutlet NSTextField *label;
      IBOutlet NSButton *checkox;
  }
  
  @property (assign) IBOutlet NSWindow *window;
  -(void)request:(SKRequest *)request didFailWithError:(NSError *)error;
  - (void)applicationDidFinishLaunching:(NSNotification *)notification;
  -(void)requestUpgradeProductsData;
  -(void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response;
  -(IBAction)checkBoxState:(id)sender;
  @end
  </code></pre>
  
  <p>Code:</p>
  
  <pre><code> #import "AppDelegate.h"
  
   @implementation AppDelegate
  
   @synthesize window = _window;
  
  -(void)applicationWillFinishLaunching:(NSNotification *)notification
  {
      NSLog(@"applicationDidFinishLaunching");
      NSURL *receiptUrl = [[NSBundle mainBundle] appStoreReceiptURL];
      if (![[NSFileManager defaultManager] fileExistsAtPath:[receiptURL path]])
      {
          NSLog(@"no receipt - exit the app with code 173");
          exit(173);
      }
  }
  
  -(void)requestUpgradeProductsData
  {
      if([SKPaymentQueue canMakePayments])
      {
          SKProductsRequest *request =[[SKProductsRequest alloc]initWithProductIdentifiers:[NSSet setWithObjects:@"com.comany.MyApp.DLC1",@"com.comany.MyApp.DLC2",nil]];
          request.delegate = self;
          [request start];
      }
  }
  
  -(void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response
  {
      int count = response.products.count;
      if(count!=0)
      {
          NSLog(@"COUNT IS NOT ZERO");
      }
      else 
      {
          [label setStringValue:@"NO PRODUCT"];
      }
  }
  
  -(IBAction)checkBoxState:(id)sender
  {
      [self requestUpgradeProductsData]; 
  }
  -(void) request:(SKRequest *)request didFailWithError:(NSError *)error
  {
      NSLog(error);
  }
  @end
  </code></pre>
  
  <p>-My code always exit at <strong>"exit(173);"</strong> and if i remove this check i get all my products as invalid identifiers.
  -And When i sign my code with 3d party certificate app store asks for login information, But when i sign my code with development certificate app store does nothing.</p>
  
  <p>thanks.</p>
  
  <p><a href="https://developer.apple.com/membercenter/index.action" rel="nofollow">https://developer.apple.com/membercenter/index.action</a></p>