Reply
Highlighted
Member
Posts: 1
Registered: ‎06-11-2012

AIM with IOS

[ Edited ]

I am working on the AIM for ios and it throws me the following exception

      

            Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[NSString stringWithXMLTag:andValue:]: unrecognized selector sent to class

 

on the line:

 

            [AuthNet authNetWithEnvironment:ENV_TEST];

 

I set the above environment in my app delegate file.

 

My sample code is


#import "CreditTest.h"
#import "AuthNet.h"

@implementation CreditTest

- (void) loginToGateway {

    MobileDeviceRegistrationRequest *mobileDeviceRegistrationRequest = [MobileDeviceRegistrationRequest mobileDeviceRegistrationRequest];
    mobileDeviceRegistrationRequest.mobileDevice.mobileDeviceId = @"xxxxxxx";
    mobileDeviceRegistrationRequest.mobileDevice.mobileDescription = @"iPhone";
    mobileDeviceRegistrationRequest.mobileDevice.phoneNumber = @"xxxxxxx";
    mobileDeviceRegistrationRequest.anetApiRequest.merchantAuthentication.name = @"xxxxxxx";
    mobileDeviceRegistrationRequest.anetApiRequest.merchantAuthentication.password = @"xxxxxxxx";
    
    MobileDeviceLoginRequest *mobileDeviceLoginRequest =
    [MobileDeviceLoginRequest mobileDeviceLoginRequest];
    mobileDeviceLoginRequest.anetApiRequest.merchantAuthentication.name = @"xxxxxxx";
    mobileDeviceLoginRequest.anetApiRequest.merchantAuthentication.password = @"xxxxxxxxx";
    mobileDeviceLoginRequest.anetApiRequest.merchantAuthentication.mobileDeviceId =
    [[[UIDevice currentDevice] uniqueIdentifier]
     stringByReplacingOccurrencesOfString:@"-" withString:@"_"];
    
    AuthNet *an = [AuthNet getInstance];
    [an setDelegate:(id)self];
    [an mobileDeviceLoginRequest: mobileDeviceLoginRequest];
}

- (void) createTransaction {
    AuthNet *an = [AuthNet getInstance];
    
    [an setDelegate:(id)self];
    
    CreditCardType *creditCardType = [CreditCardType creditCardType];
    creditCardType.cardNumber = @"4111111111111111";
    creditCardType.cardCode = @"100";
    creditCardType.expirationDate = @"1212";
    
    PaymentType *paymentType = [PaymentType paymentType];
    paymentType.creditCard = creditCardType;
    
    ExtendedAmountType *extendedAmountTypeTax = [ExtendedAmountType extendedAmountType];
    extendedAmountTypeTax.amount = @"0";
    extendedAmountTypeTax.name = @"Tax";
    
    ExtendedAmountType *extendedAmountTypeShipping = [ExtendedAmountType extendedAmountType];
    extendedAmountTypeShipping.amount = @"0";
    extendedAmountTypeShipping.name = @"Shipping";
    
    LineItemType *lineItem = [LineItemType lineItem];
    lineItem.itemName = @"Soda";
    lineItem.itemDescription = @"Soda";
    lineItem.itemQuantity = @"1";
    lineItem.itemPrice = @"1.00";
    lineItem.itemID = @"1";
    
    TransactionRequestType *requestType = [TransactionRequestType transactionRequest];
    requestType.lineItems = [NSArray arrayWithObject:lineItem];
    requestType.amount = @"1.00";
    requestType.payment = paymentType;
    requestType.tax = extendedAmountTypeTax;
    requestType.shipping = extendedAmountTypeShipping;
    
    CreateTransactionRequest *request = [CreateTransactionRequest createTransactionRequest];
    request.transactionRequest = requestType;
    request.transactionType = AUTH_ONLY;
    request.anetApiRequest.merchantAuthentication.mobileDeviceId =
    [[[UIDevice currentDevice] uniqueIdentifier]
     stringByReplacingOccurrencesOfString:@"-" withString:@"_"];
    request.anetApiRequest.merchantAuthentication.sessionToken = sessionToken;
    [an purchaseWithRequest:request];
}

- (void) requestFailed:(AuthNetResponse *)response {
    // Handle a failed request
   
}

- (void) connectionFailed:(AuthNetResponse *)response {
    // Handle a failed connection
}

- (void) paymentSucceeded:(CreateTransactionResponse *) response {
    // Handle payment success
}

- (void) mobileDeviceLoginSucceeded:(MobileDeviceLoginResponse *)response {
    sessionToken = [response.sessionToken retain];
    [self createTransaction];
};

@end

 

Any help would be appreciated.

 

Thank You.

 

 

Highlighted
All Star
Posts: 1,072
Registered: ‎08-17-2009

Re: AIM with IOS

Hey durga23588, 

 

Thanks for bringing this to our attention. I'm forwarding your post on to our developers for them to look at as I don't have an answer for you right now on what's going on. When we hear back, we'll post more info to this thread.

 

Thanks,

 

Michelle

Developer Community Manager

Highlighted
Member
Posts: 3
Registered: ‎07-10-2012

Re: AIM with IOS

Any solution yet? I'm experiencing exactly same error.

Highlighted
Member
Posts: 3
Registered: ‎07-10-2012

Re: AIM with IOS

After struggling for a day with this I finally found a solution. Here it is:

http://stackoverflow.com/questions/10442653/unrecognized-selector-calling-category-method-in-static-...

Highlighted
Member
Posts: 3
Registered: ‎11-28-2013

Re: AIM with IOS

Hi durga23588,

let me know one thing In your    - (void) loginToGateway    method.You haven't registered your device,means you are missing the code:

[an mobileDeviceRegistrationRequest:mobileDeviceRegistrationRequest]
Then my question is how could you manage to do mobile device login request.

with only this code.

 [an mobileDeviceLoginRequest:mobileDeviceLoginRequest];

I think before login to merchant account your device must be registered and it's the common thing.
Please let me know your valuable feedback.
Thanks in advance.