Saturday, March 24, 2012

AuthNet iOS Integration Part 2

There are quite a few gaps in the sample code provided by AuthNet, we will discuss the logs indicating the problem and what chunk of code needs to be added/removed to get to a complete sample that works. This blog entry assumes that you've cleared the challenges of adding AuthNet binaries to your Xcode project. If not then have a peek at AuthNet iOS Integration Part 1 before continuing.
  1. Create a header & an implementation class containing the sample code
  2. If you happen to be using PayPal as well as AuthNet in your code then you may run into some syntactical problems. To resolve any such issues, please have a look at this post on stackoverflow.
  3. When substituting values in the code, if you provide the "API Login ID" and "Transaction Key" as the name / password values in your call to AuthNet then you will run into the following error as seen in the logs:
  4. This fails as password and transactionKey are distinctly different variables in the header files.
  5. So make sure to substitute the sample code with the username and password used with or
  6. If you run the code at this point and end up calling loginToGateway, you will run into the following error logs:
  7. This is not the same as being at the point where you simply need to login to the sandbox ( and enable the new device. No, this is very different and you need to get past this to get to the next point. So you need to add some additional code which is talked about on the forums as well:
  8. Now you should be at a point where running the code results in the following error logs:
  9. This is more like it! So head over to and enable your new device. Here are some screenshots: screenshot_1 and screenshot_2
  10. Sadly we aren't done yet, we see a message about the mobile device being ready for use but we also notice that the sessionToken has come back as null and therefore the next call's response displays an error ... claiming that the request content was incomplete:
  11. Even I don't have a solution past this point, feel free to follow this forum thread for any progress on the matter.


  1. I got the solution from the forum by the moderator Trevor:

    "I know that this is a late response, but I wanted to follow up since this thread never really got a resolution. It appears that the issue here came down to a conflict between the design of the SDK and the way that you were trying to use it. The current implementation of the iOS SDK does not allow concurrent requests. Your code is running the mobileDeviceLoginRequest before the mobileDeviceRegistrationRequest has been completed and closed out. Simply changing the request pattern should resolve the null response."

    Now I confirm that he is right. The first time I ran using the registration code. After the
    device was approved online, I ran the code again but this time commenting out the registration line
    as seen below and the token was not null anymore:

    //[an mobileDeviceRegistrationRequest:mobileDeviceRegistrationRequest];
    [an mobileDeviceLoginRequest: mobileDeviceLoginRequest];

    I hope the good author will please continue with the next steps.

  2. Thank You Romeo, this is very encouraging, I will follow up on this post soon :)
    Let's connect on linkedin:

  3. What abt the rest of the process?when the transaction takes place?
    please can complete the post Tiklup, caz im getting an error saying that
    "Error.errorCode = 87\nError.errorText = Transactions of this market type cannot be processed on this system.\n"
    waiting for response soon,thanks in advance..

  4. Honestly I've found better alternatives to handling integration myself like ZooZ (it handles it for me) so I don't think I'll be revisiting my code for a follow up. Please treat what you see here (my notes) as reference material and carry forward on your own :)

  5. I am getting following error code,

    TransactionResponse.errors = (
    "Error.errorCode = 87\nError.errorText = Transactions of this market type cannot be processed on this system.\n"

  6. Did you already post on Authorize.Net forums about this? I haven't seen this :(