“authorize.net ios sdk”中的“此方法调用不允许使用身份验证类型”错误

时间:2013-02-05 17:06:34

标签: ios

我正在尝试使用authorize ios sdk作为我的应用程序中的支付网关。我已成功集成,但我在测试帐户上遇到上述错误。

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];

2 个答案:

答案 0 :(得分:5)

如果您的设备已经注册,那么 评论设备注册码
下面的行是注册,请评论

[an mobileDeviceRegistrationRequest:mobileDeviceRegistrationRequest];

希望这对你有所帮助。如有任何其他问题,请告诉我。

答案 1 :(得分:2)

此错误即将发生,因为在获取deviceRegistrtationRequest的响应之前,deviceLoginRequest调用正在执行。要避免此错误,请确保在请求deviceLogin之前获得deviceRegistration调用的响应。