PDA

View Full Version : Is anyone able to perform Receipt validation??




aravind
Apr 26, 2011, 11:38 PM
Please let me know, anyone now online able to perform receipt validation in MAC application??


I have a few doubts on this process...??


1. Have you used the ASN generated files in the application?

2. Are you able to produce a sample receipt by automatic popup of the iTunes authentication?



kainjow
Apr 27, 2011, 12:08 AM
I used a modified version of this:
https://github.com/roddi/ValidateStoreReceipt

In iTunes Connect you can create test accounts to use, which will generate the receipt file once authenticated.

aravind
Apr 27, 2011, 12:17 AM
Thank you very much for your reply

i am able to create test user in iTunes, but how to authenticate the user??

Please clarify..?

kainjow
Apr 27, 2011, 12:22 AM
Apple has docs on their website about this, but essentially if your code finds the receipt invalid or not found, you have to terminate your app using:
exit(173);
The OS then detects that and pops up the App Store login window.

aravind
Apr 27, 2011, 12:32 AM
yes my application always exit with 173, but not asking for authentication..

Is code signing needed for this??

I had performed that too.. But i am not so sure whether it is correctly done..
I had selected "third party signing...." in my Xcode.

In apple documentation, it is mentioned that MAC OS 10.6.6 and above will ask for authentication, i am using 10.6.7, but still not asking for authentication..

gnasher729
Apr 27, 2011, 01:31 AM
yes my application always exit with 173, but not asking for authentication..

Is code signing needed for this??

I had performed that too.. But i am not so sure whether it is correctly done..
I had selected "third party signing...." in my Xcode.

In apple documentation, it is mentioned that MAC OS 10.6.6 and above will ask for authentication, i am using 10.6.7, but still not asking for authentication..

Steps to do:

1. Your app must be signed. If it is not signed then Apple will not accept it on the Apple Store. If it is signed then people can download and start it without the operating system giving any warnings that it was downloaded from the internet etc., unless someone modifies the app and the OS gives a rather strong warning when starting it.

2. If you don't mind that people copy your application you do nothing.

3. If you don't want people to copy your application, then you add code that checks for the receipts. If there are no valid receipts then exit (173). If you are paranoid then write your code so that it crashes if the exit call returns:
char c, *p = NULL; if (receiptInvalid ()) exit (173); else p = &c; *p = 'x';

4. At no point will anything appear in the user interface that asks for authentication. The receipts that you checked are proof that the app was rightfully downloaded on this computer.

aravind
Apr 27, 2011, 01:41 AM
Fine..
I signed my application and in Xcode project target settings i selected "3rd part application---". I think the app is signed now.

I also had added the receipt validation checking in code..
When i tried searching for the receipt in app bundle the app exits with status 173, but not opening any authentication.. why it happens??

gnasher729
Apr 27, 2011, 05:51 AM
Fine..
I signed my application and in Xcode project target settings i selected "3rd part application---". I think the app is signed now.

I also had added the receipt validation checking in code..
When i tried searching for the receipt in app bundle the app exits with status 173, but not opening any authentication.. why it happens??

What makes you think there would be any authentication? Your code just noticed that there wasn't a correct receipt, so the application exits. Nothing else should happen.

kainjow
Apr 27, 2011, 08:17 PM
Fine..
I signed my application and in Xcode project target settings i selected "3rd part application---". I think the app is signed now.

I also had added the receipt validation checking in code..
When i tried searching for the receipt in app bundle the app exits with status 173, but not opening any authentication.. why it happens??

Are you testing a build straight out of Xcode? I think you need to test a build that is validated with Apple's servers (via Xcode > Window > Organizer). All I know is I tested builds using the Share option in the Organizer after a successful validation, and it worked then.

aravind
Apr 27, 2011, 11:30 PM
K thanks, Now i am able to simulate some what fine..

While build and run from xcode, no iTunes Login page popups, but when i try to open the .app file from the finder it popups.

But doesn't do anything.

What will the iTunes popup do for us, will it install a trial receipt in the app bundle for us, so that we can test all the receipt validation with that??

What is the difference in build and run the Project from the organiser?
How can we achieve that, when i click on organiser, the build button is in disabled state..

aravind
Apr 27, 2011, 11:54 PM
I had done the code signing, and added code to perform receipt validation also.


But i dont have a proper receipt to check with...!!!

I can't use the receipt given in Apple documentation, since it fails because of different system GUID, app ID etc.


In apple documentation it is mentioned that when app exits with 173 it will open iTunes and try to install a valid receipt..


When i tried build and run in Xcode, it fails to open the popup. When i opened the .app file from the finder, it popup's but no further messages. Every time i try opening the .app file the popup occurs, make me enter the test user credentials and nothing more...


What will be going wrong with my mac application...


I have to check my application, that it passes all the receipt validation, before submitting it to Appstore.


Please anyone help me out resolve this issue.


(I reached till this in receipt validation with the help of member of this forum..
Thanks a lot for your valuable help. )

kainjow
Apr 28, 2011, 01:43 AM
When i opened the .app file from the finder, it popup's but no further messages. Every time i try opening the .app file the popup occurs, make me enter the test user credentials and nothing more...

After logging in with your test account, if it doesn't display any errors, then it should generate the receipt file within your .app. If your code properly reads it, then the app should continue to launch properly. If it doesn't, you exit 173 and the App Store login window should pop up again. There shouldn't be any other dialogs appearing.

If you keep having to enter your login info, that probably means your code isn't properly reading the receipt.

aravind
Apr 28, 2011, 02:00 AM
I tried masking all the receipt validation code and only left the Receipt file checking code unmasked. ie , if receipt file exists, opens the app otherwise exit with 173. Still i am getting the repeated iTunes popup.

One more question

Are you able to see the receipt file in the contents/_MASRecceipt folder once you completed the first iTunes login(when the app exit with 173 status)??

aravind
May 2, 2011, 12:06 AM
When i viewed the Response and requests to the apple site while the popup appears, in Charles(HTTPDebugger)

It is shown that, a pList containing computer's GUID, app budle identifier, app version etc are sent as request(as an XML format) to the server and got a response XML(pList) with a single node as shown below..



<plist version="1.0">
<dict>
<key>status</key>
<string>500318</string>
</dict>
</plist>



While seeing the request to the server, i understood that these are the essential details to be enclosed in the Receipt file, but the response seems strange.

Is this the correct response?



Or else are you getting any Receipt file as such in the Response?



Please reply...

chrismaddern
Dec 6, 2011, 08:47 AM
Hey Guys - I think I just made what you were looking for; so for anyone using this for reference, I put a quick PHP script online to validate store receipts against the sandbox environment...

Validate iTunes Store Receipts Online (http://www.chrismaddern.com/validate-itunes-iap-receipt-codes-online-tool/)

The code is available too incase you want it.

Chris

rockstarjoe
Dec 6, 2011, 09:21 AM
I tried masking all the receipt validation code and only left the Receipt file checking code unmasked. ie , if receipt file exists, opens the app otherwise exit with 173. Still i am getting the repeated iTunes popup.

One more question

Are you able to see the receipt file in the contents/_MASRecceipt folder once you completed the first iTunes login(when the app exit with 173 status)??

Yes, you will see the reciept in your app bundle under Contents/_MASReceipt. I just did this for the first time last night and it seemed to work correctly for me. I only received the Itunes / App Store login popup once.

EDIT: for what it is worth, I am using NPRecieptValidation to check my receipt (it's on github)