AppStore added a way to validate the in App purchasement, which is that Apple provides a URL address for development testing:
Https://sandbox.itunes.apple.com/verifyReceipt
Products by:
Https://buy.itunes.apple.com/verifyReceipt
When the purchase is successful, you will get a receipt from Apple (receipt), Apple recommends the method is to send the receipt to the developer's server, the server like the above address post HTTP message, to verify that Apple will return the results. Whether it is a real purchase or a fake purchase.
Small partners without their own servers can be sent using the app, the code below.
#defineItms_sandbox_verify_receipt_url @ "https://Sandbox.itunes.apple.com/verifyreceipt "#pragmamark-verifyfinishedtransaction-(void) Verifyfinishedtransaction: (Skpaymenttransaction *) transaction{if(Transaction.transactionstate = =skpaymenttransactionstatepurchased) {NSString*transactionidentifier =Transaction.transactionidentifier; NSData*transactionreceipt =Transaction.transactionreceipt; //Send Transactionidentifer and encrypted transactionreceipt data to the server sideNSString* Receipent = [NSString stringWithFormat:@"%s", Transactionreceipt.bytes]; NSLog (@"receipent =%@", receipent); //validation on the app, only for testingNSString *payload = [NSString stringWithFormat:@"{\"Receipt-data\": \ "%@\", \ "password\": \ "%@\"}", Receipent, Transactionidentifier]; NSData*payloaddata =[payload datausingencoding:nsutf8stringencoding]; Nsmutableurlrequest*request =[Nsmutableurlrequest Requestwithurl:[nsurl Urlwithstring:itms_sandbox_verify_receipt_url]; [Request Sethttpmethod:@"POST"]; [Request Sethttpbody:payloaddata]; Nserror*err; Nsurlresponse*theresponse =Nil; NSData*data=[nsurlconnection sendsynchronousrequest:request returningresponse:&theresponse Error:&err]; Nserror*jsonparsingerror =Nil; Nsdictionary*dict = [Nsjsonserialization jsonobjectwithdata:data options:kniloptions error:&Jsonparsingerror]; NSLog (@"%@", Dict); NSLog (@" Done"); }}