2013-02-05 42 views
2

我想在我的應用程序中使用授權ios sdk作爲支付網關。我已經成功整合了,但我在測試帳戶中遇到了上述錯誤。「驗證類型不允許用於此方法調用」錯誤authorize.net 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]; 
+0

您是否得到了答案?我也有同樣的問題 –

+0

也許它會幫助某人後來,但我得到這個錯誤,因爲我不小心使用null作爲商家ID和交易密鑰的值。 – JPollock

回答

5

如果您的設備已註冊然後 評論設備註冊代碼
以下行註冊,請評論它

[an mobileDeviceRegistrationRequest:mobileDeviceRegistrationRequest]; 

希望這是你。如果任何其他問題有幫助,請告訴我。

2

此錯誤即將發生,因爲deviceLoginRequest調用在得到deviceRegistrtationRequest的響應之前得到執行。爲避免此錯誤,請確保在請求deviceLogin之前獲得deviceRegistration調用的響應。

相關問題