Is anyone able to perform Receipt validation??

Discussion in 'Mac Programming' started by aravind, Apr 26, 2011.

  1. macrumors newbie

    Apr 25, 2011
    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?
  2. Moderator emeritus


    Jun 15, 2000
  3. thread starter macrumors newbie

    Apr 25, 2011
    Thank you very much for your reply

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

    Please clarify..?
  4. Moderator emeritus


    Jun 15, 2000
    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:
    The OS then detects that and pops up the App Store login window.
  5. thread starter macrumors newbie

    Apr 25, 2011
    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..
  6. macrumors G5


    Nov 25, 2005
    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.
  7. thread starter macrumors newbie

    Apr 25, 2011
    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??
  8. macrumors G5


    Nov 25, 2005
    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.
  9. Moderator emeritus


    Jun 15, 2000
    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.
  10. thread starter macrumors newbie

    Apr 25, 2011
    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..
  11. thread starter macrumors newbie

    Apr 25, 2011
    MAC App's receipt validation

    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. )
  12. Moderator emeritus


    Jun 15, 2000
    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.
  13. thread starter macrumors newbie

    Apr 25, 2011
    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)??
  14. thread starter macrumors newbie

    Apr 25, 2011
    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">

    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...
  15. chrismaddern, Dec 6, 2011
    Last edited: Dec 6, 2011

    macrumors newbie

    Mar 17, 2009
    Online tool to Verify iTunes Receipt

    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

    The code is available too incase you want it.

  16. macrumors 6502a


    Jun 2, 2006
    washington dc
    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)

Share This Page