title: Verifying a Receipt with the App Store
body: <p><br><br>
  Retrieve the receipt data from the transaction’s transactionReceipt property and encode it using base64 encoding.</p>
  
  <p>How can I encode NSData using base64 encoding? Please give the code for that.</p>
  
  <p><em><strong>EDIT</em></strong>
  <br>I did it. but now the response is </p>
  
  <pre><code>{exception = "java.lang.NullPointerException"; status = 21002;}
  </code></pre>
  
  <p>my recipt verification method is this</p>
  
  <pre><code>-(BOOL)verifyReceipt:(SKPaymentTransaction *)transaction
  {
      NSString *recieptString = [transaction.transactionReceipt base64EncodingWithLineLength:0];
      NSLog(@"%@",recieptString);
  
      ASIFormDataRequest *request = [[ASIFormDataRequest alloc] initWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://buy.itunes.apple.com/verifyReceipt"]]];
  
      [request setPostValue:recieptString forKey:@"receipt-data"];
      [request setPostValue:@"95140bdac98d47a2b15e8e5555f55d41" forKey:@"password"];
      [request start];
  
      NSDictionary* subsInfo = [[request responseString] JSONValue];
      NSLog(@"%@",subsInfo);
  
      return subscriptionEnabled;
  }
  </code></pre>
  
  <p>Where </p>
  
  <pre><code>NSString *recieptString = [transaction.transactionReceipt base64EncodingWithLineLength:0];
  </code></pre>
  
  <p>returns me base64 encoded string. <br>
  I also tried<br></p>
  
  <pre><code>NSString *recieptString = [transaction.transactionReceipt base64EncodingWithLineLength:[transaction.transactionReceipt length]];
  </code></pre>
  
  <p>but response is same.
  <br>
  can any one of you let me know where I could be wrong.
  <br>
  Thanks-</p>