user2044006
user2044006

Reputation: 21

"The authentication type is not allowed for this method call" error in authorize.net ios sdk

I am trying to use authorize ios sdk as payment gateway in my application. I have integrated successfully, but I am getting above error with the test account.

AuthNet *an = [AuthNet getInstance];

[an setDelegate:self];

CreditCardType *creditCardType = [CreditCardType creditCardType];
creditCardType.cardNumber = @"38000000000006";
creditCardType.cardCode = @"100";
creditCardType.expirationDate = @"121213";

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 authorizeWithRequest:request];
[an purchaseWithRequest:request];

Upvotes: 2

Views: 1223

Answers (2)

shripad20
shripad20

Reputation: 858

this error is coming because the deviceLoginRequest call is getting executed before getting response of deviceRegistrtationRequest. To avoid this error make sure you get response for deviceRegistration call before you request for deviceLogin.

Upvotes: 2

Mohit
Mohit

Reputation: 359

If your device is already registered then comment the device registration code
Below line is for registration, please comment it

[an mobileDeviceRegistrationRequest:mobileDeviceRegistrationRequest];

Hope this is helpful for you.If any other issue please tell me.

Upvotes: 5

Related Questions