在iPhone模拟器中,我已注册并使用authorize.net成功登录。但我无法进行交易。 MobileDeviceLoginRequest和createTransaction的代码,如下所示。
- (无效)loginToGateway {
MobileDeviceLoginRequest * mobileDeviceLoginRequest = [MobileDeviceLoginRequest mobileDeviceLoginRequest];
mobileDeviceLoginRequest.anetApiRequest.merchantAuthentication.name = @“ * ** ”;
mobileDeviceLoginRequest.anetApiRequest.merchantAuthentication.password = @“ * **** ”;
mobileDeviceLoginRequest.anetApiRequest.merchantAuthentication.mobileDeviceId = [OpenUDID value];
[AuthNet authNetWithEnvironment:ENV_TEST];
AuthNet * an = [AuthNet getInstance];
[setDelegate:self]; [mobileDeviceLoginRequest:mobileDeviceLoginRequest];
}
- (void)mobileDeviceLoginSucceeded:(MobileDeviceLoginResponse *)响应 {
sessionToken = [response.sessionToken retain];
[self createTransaction];
} - (无效)createTransaction {
AuthNet *an = [AuthNet getInstance];
[an setDelegate: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] identifierForVendor] UUIDString];
request.anetApiRequest.merchantAuthentication.sessionToken = sessionToken;
[an purchaseWithRequest:request];}
mobileDeviceLoginResponse,如下所示: //我也正在进行会话
<resultCode>Ok</resultCode>
<message>
<code>I00001</code>
<text>Successful.</text>
createTransactionResponse,如下所示:
<code>E00054</code>
<text>The mobile device is not registered with this merchant account.</text>
答案 0 :(得分:0)
错误代码E00054表示您需要先执行mobileDeviceRegistrationRequest并批准商家界面中的设备,然后才能创建交易。