Saturday, March 24, 2012

AuthNet iOS Integration Part 1

  1. You can start with the official instructions to get an account with Authorize.Net and download their iOS SDK. Afterwards the instructions are bit out of date, so you can follow along below.
  2. After you download and unzip the SDK, you can move the files around to have them structured in this manner:
  3. The structure above has the following pros:
    • Clarity around which version has been downloaded and in use at any point of time: anet_ios_sdk-X.X.X
    • If you work long enough to have multiple versions, then having them in your repository (assumption - GIT repo) helps figure out any migration issues
      • $(SRCROOT)/anet_ios_sdk-1.0.0/ANMobilePaymentLib/
      • $(SRCROOT)/anet_ios_sdk-1.0.1/ANMobilePaymentLib/
      • $(SRCROOT)/anet_ios_sdk-1.0.2/ANMobilePaymentLib/
      • ...
      • $(SRCROOT)/anet_ios_sdk-X.X.X/ANMobilePaymentLib/
  4. Goto MyProject > Targets > Build Settings in Xcode and set:
    1. Header Search Paths
      1. "${SDK_DIR}"/usr/include/libxml2
        • Mark the Recursive checkbox as checked
      2. "$(SRCROOT)/anet_ios_sdk-1.0.0/ANMobilePaymentLib"
    2. Library Search Paths
      1. "$(SRCROOT)/anet_ios_sdk-1.0.0/ANMobilePaymentLib"
    3. Other Linker Flags
      1. -lxml2
  5. Drag & Drop the ANMobilePaymentLib.xcodeproj file from a Finder window into Xcode under MyProject.
    • If you don't follow this step then you will face compilation issues like:
  6. Goto MyProject > Targets > Build Phases in Xcode and set:
    1. Link Binary With Libraries
      1. libANMobilePaymentLib.a
  7. For a discussion on the fixes to the sample code, head over to AuthNet iOS Integration Part 2


  1. Hey I read you post I am still getting errors
    'libxml/tree.h' file not found in the file GDataXMLNode.h.

    I am really not able to figure out what else should be done.

    I would really appreciate if you can post a sample code zip file.. Thanks.

  2. I googled that error and some folks resolved it here:

    I personally didn't run into it, perhaps there's a step that I took but didn't carefully document here in the blog? Feel free to post back and let us all know how it goes for you.

    I can't post the code because that hard-drive has been scrapped plus I was taking generic notes while working on a very specific and sensitive project so even if I still had it ... I wouldn't be able to sanitize it quickly enough to give it to you. My apologies.

  3. Hey,
    Thanks for responding back. I really appreciate that. I had one more question. You mentioned in step 5, the auth_net project needs to be dragged and dropped into the parent project. When I do it I cannot access any of the header files from the added project. But if I copy and paste the whole folder I can access those header files. The problem is if I copy paste it the added project compiles again and becomes very slow and faces some cache issues. Is there something else very obvious that has to be done when I drag and drop the project?

    Thanks again.. Any input is very much appreciate. Thanks for your efforts to put up the detailed tutorial when don't even bother to update their own sample code or respond on the forums. Thanks again.

  4. We can try to work together over some kind of screen share?

  5. hi,
    i am new to iPhone development.Can you provide step by step integration guide with ios 6.1

  6. I don't plan on revisiting this post or its content because it is not relevant in my day to day work anymore. I jotted it down as notes while working in the past.