I am trying to get my mobile device (iPhone 4S) registered on my test merchant account so I can use the SDK to send transactions from the iOS device.
I have downloaded the latest version of the SDK from Authorize.NET. I have been over and over the sample code several times. I've also been through the "up in 15 minutes" for iOS example many times. For one thing, the "up in 15 minutes" page leaves several things out that is in the README for the SDK--which I found incredibly confusing, as I kept getting referred back to the "15 minutes" page.
That said, the "15 minutes" page indicates that you just use that sample code and the first time you run it, the device will show up in "pending status" in the merchant account (Mobile Device Management). This is not correct as far as I can tell. When you run the sample code, if you look in the output console in Xcode, you see the following message output:
"The mobile device is not registered with this merchant account."
Of course I know it isn't registered, that's what I'm trying to do. So after reading a couple of posts in these forums, I was told that you don't actually just run the sample code as the "15 minutes" example, or the README in the SDK indicates, but instead you must actually call the mobileDeviceRegistrationRequest: method the very first time you use a device and this will actually register it with the merchant account.
Well, I've written code to call mobileDeviceRegistrationRequest: as well, and that doesn't work either. After running that code, I also get the message "The mobile device is not registered with this merchant account." And I checked Settings in the merchant account one more time, just to make sure the device hadn't appeared in "pending status"--which of course it didn't.
I'm completely stuck and this is getting incredibly frustrating. Does anyone have any idea what is going on with this and how to get a device successfully registered using the iOS SDK?
For reference, here is the code I wrote for the mobileDeviceRegistrationRequest: method:
MobileDeviceRegistrationRequest *mobileDeviceRegistrationRequest = [MobileDeviceRegistrationRequest mobileDeviceRegistrationRequest];
mobileDeviceRegistrationRequest.mobileDevice.mobileDeviceId = @"XXXXX";
mobileDeviceRegistrationRequest.mobileDevice.mobileDescription = @"XXXXX";
mobileDeviceRegistrationRequest.mobileDevice.phoneNumber = @"99999";
mobileDeviceRegistrationRequest.anetApiRequest.merchantAuthentication.name = @"username";
mobileDeviceRegistrationRequest.anetApiRequest.merchantAuthentication.password = @"password";
mobileDeviceRegistrationRequest.anetApiRequest.merchantAuthentication.mobileDeviceId = [[UIDevice currentDevice] uniqueGlobalDeviceIdentifier];
Note that I have removed my information from the "mobileDevice" object and the user name and password. Further, the "uniqueGlobalDeviceIdentifier" is a custom function I'm using that generates a unique device ID since the UUID functionality is deprecated in iOS 5 by Apple.
Thanks,
Chris
Solved! Go to Solution.
02-10-2012 03:55 PM - edited 02-10-2012 03:59 PM
OK, so I figured this out and successfully got a device to register. For those having the same problem (sample code not working, the "up and running in 15 minutes" page missing details):
All of the information I wrote above is correct--meaning the sample code and README are missing a few steps. The major piece being you have to call the method mobileDeviceRegistrationRequest: not just run the sample code and then look for your device in the Mobile Device Management area of https://test.authorize.net. It would be nice if all of this documentation was updated by Authorize.NET so it was consistent and not confusion--and most importantly, missing key bits of informaiton.
My problem below with the code was I was sending this line as a part of my call (which isn't needed):
mobileDeviceRegistrationRequest.anetApiRequest.merchantAuthentication.mobileDeviceId = [[UIDevice currentDevice] uniqueGlobalDeviceIdentifier];
So the sample code, there is the function loginToGateway which you need to add the mobileDeviceRegistrationRequest: method to as well. You add this before the mobileDeviceLoginRequest: method. In this way, the device registration call is always made no matter what, but if your device is already registered, it doesn't affect anything and it moves on to the login request. So either way you are always covered. The loginToGateway function should look like this:
- (void)loginToGateway { // First time we need to do a mobile device registration request. Remember that if this is the first time you've registered your // device, the transaction will fail, however your device will now be in "pending" status in the test portal // (https://test.authorize.net). MobileDeviceRegistrationRequest *mobileDeviceRegistrationRequest = [MobileDeviceRegistrationRequest mobileDeviceRegistrationRequest]; mobileDeviceRegistrationRequest.mobileDevice.mobileDeviceId = @"<YOUR_DEVICE_UUID>"; mobileDeviceRegistrationRequest.mobileDevice.mobileDescription = @"<DEVICE_DESC>"; mobileDeviceRegistrationRequest.mobileDevice.phoneNumber = @"<DEVICE_PHONE_NUM>"; mobileDeviceRegistrationRequest.anetApiRequest.merchantAuthentication.name = @"<USER_NAME>"; mobileDeviceRegistrationRequest.anetApiRequest.merchantAuthentication.password = @"<PASSWORD>"; // Create our login request. MobileDeviceLoginRequest *mobileDeviceLoginRequest = [MobileDeviceLoginRequest mobileDeviceLoginRequest]; mobileDeviceLoginRequest.anetApiRequest.merchantAuthentication.name = @"<USER_NAME>"; mobileDeviceLoginRequest.anetApiRequest.merchantAuthentication.password = @"<PASSWORD>"; mobileDeviceLoginRequest.anetApiRequest.merchantAuthentication.mobileDeviceId = [[UIDevice currentDevice] uniqueGlobalDeviceIdentifier]; // Set up an AuthNet instance. AuthNet *an = [AuthNet getInstance]; [an setDelegate:self]; // Process a mobile device registration request. [an mobileDeviceRegistrationRequest:mobileDeviceRegistrationRequest]; // Process a mobile device login request. [an mobileDeviceLoginRequest:mobileDeviceLoginRequest]; }
Hope this helps anyone who was also struggling with this.
02-10-2012 05:49 PM - edited 02-10-2012 05:51 PM
OK, so I figured this out and successfully got a device to register. For those having the same problem (sample code not working, the "up and running in 15 minutes" page missing details):
All of the information I wrote above is correct--meaning the sample code and README are missing a few steps. The major piece being you have to call the method mobileDeviceRegistrationRequest: not just run the sample code and then look for your device in the Mobile Device Management area of https://test.authorize.net. It would be nice if all of this documentation was updated by Authorize.NET so it was consistent and not confusion--and most importantly, missing key bits of informaiton.
My problem below with the code was I was sending this line as a part of my call (which isn't needed):
mobileDeviceRegistrationRequest.anetApiRequest.merchantAuthentication.mobileDeviceId = [[UIDevice currentDevice] uniqueGlobalDeviceIdentifier];
So the sample code, there is the function loginToGateway which you need to add the mobileDeviceRegistrationRequest: method to as well. You add this before the mobileDeviceLoginRequest: method. In this way, the device registration call is always made no matter what, but if your device is already registered, it doesn't affect anything and it moves on to the login request. So either way you are always covered. The loginToGateway function should look like this:
- (void)loginToGateway { // First time we need to do a mobile device registration request. Remember that if this is the first time you've registered your // device, the transaction will fail, however your device will now be in "pending" status in the test portal // (https://test.authorize.net). MobileDeviceRegistrationRequest *mobileDeviceRegistrationRequest = [MobileDeviceRegistrationRequest mobileDeviceRegistrationRequest]; mobileDeviceRegistrationRequest.mobileDevice.mobileDeviceId = @"<YOUR_DEVICE_UUID>"; mobileDeviceRegistrationRequest.mobileDevice.mobileDescription = @"<DEVICE_DESC>"; mobileDeviceRegistrationRequest.mobileDevice.phoneNumber = @"<DEVICE_PHONE_NUM>"; mobileDeviceRegistrationRequest.anetApiRequest.merchantAuthentication.name = @"<USER_NAME>"; mobileDeviceRegistrationRequest.anetApiRequest.merchantAuthentication.password = @"<PASSWORD>"; // Create our login request. MobileDeviceLoginRequest *mobileDeviceLoginRequest = [MobileDeviceLoginRequest mobileDeviceLoginRequest]; mobileDeviceLoginRequest.anetApiRequest.merchantAuthentication.name = @"<USER_NAME>"; mobileDeviceLoginRequest.anetApiRequest.merchantAuthentication.password = @"<PASSWORD>"; mobileDeviceLoginRequest.anetApiRequest.merchantAuthentication.mobileDeviceId = [[UIDevice currentDevice] uniqueGlobalDeviceIdentifier]; // Set up an AuthNet instance. AuthNet *an = [AuthNet getInstance]; [an setDelegate:self]; // Process a mobile device registration request. [an mobileDeviceRegistrationRequest:mobileDeviceRegistrationRequest]; // Process a mobile device login request. [an mobileDeviceLoginRequest:mobileDeviceLoginRequest]; }
Hope this helps anyone who was also struggling with this.
02-10-2012 05:49 PM - edited 02-10-2012 05:51 PM
thank you for your post
it very helped me
i followed to Quick Start Guide and couldn't redister my device
why this important info isn't present in Quick Start Guide?
i think i'm not first person who has the same issue
thank you again!
good luck!
01-29-2013 09:37 AM - edited 01-29-2013 09:37 AM
Thank you so much, seems like they would update the documenation immediatly.
08-21-2013 09:31 AM
Thanks for your post now its fine but i am getting below error message while using Authorize.net payment gateway in IOS App
Can you pleae help me in this problem to sort out.?
CFNetwork SSLHandshake failed (-9806)
223:60b] errorCode = 2
[223:60b] error = Error Domain=NSURLErrorDomain Code=-1001 "The request timed out." UserInfo=0x165c1b40 {NSErrorFailingURLStringKey=https://apitest.authorize.net/xml/v1/request.api, NSErrorFailingURLKey=https://apitest.authorize.net/xml/v1/request.api, NSLocalizedDescription=The request timed out., NSUnderlyingError=0x16738a50 "The request timed out."}
2014-02-03 16:32:55.723 Jewellery Daily Deals[223:60b] NSError code = -1001
2014-02-03 16:32:55.724 Jewellery Daily Deals[223:60b] NSError description = The request timed out.
02-03-2014 03:10 AM
02-04-2014 12:02 PM
This is what I had to do:
A related question that I have now:
Will every iOS device have to get enabled in the Merchant Interface manually? That's a pain.
-Brian
08-05-2014 09:16 AM - edited 08-05-2014 09:16 AM
Hello @blalond
Requiring each new device to be approved in the Merchant Interface is a security feature and provides the account owners and administrators the ability to control which devices are allowed.
Richard
08-05-2014 10:02 AM