问题
I am trying to integrate iPhone SDK into my project. (AIM) I have some dificulties and I can't make it work.
I have followed the guide https://developer.authorize.net/integration/fifteenminutes/ios
AuthNet *an = [AuthNet getInstance];
[an setDelegate:self];
[an mobileDeviceLoginRequest: mobileDeviceLoginRequest];
In the code above, an
remains null because the class AuthNet doesnt instantiate while calling getInstance()
.
In the README file, it says that I have to call
[AuthNet authNetWithAPILoginID:@"YOUR_LOGIN_ID" andTransactionKey:@"YOUR_TRANSACTION_KEY" forEnvironment:ENV_TEST];
in order to instantiate the singleton. BUT there is no such method inside "AuthNet" class.
Am I missing something?
回答1:
-(void)registerDevice
{
MobileDeviceRegistrationRequest *registrationRequest=[MobileDeviceRegistrationRequest mobileDeviceRegistrationRequest];
registrationRequest.anetApiRequest.merchantAuthentication.name=@"loginid";
registrationRequest.anetApiRequest.merchantAuthentication.password = @"password";
registrationRequest.mobileDevice.mobileDescription=@"asd";
registrationRequest.mobileDevice.mobileDeviceId=[[[UIDevice currentDevice] uniqueIdentifier]
stringByReplacingOccurrencesOfString:@"-" withString:@"_"];
[AuthNet authNetWithEnvironment:ENV_TEST];
AuthNet *an = [AuthNet getInstance];
[an setDelegate:self];
[an mobileDeviceRegistrationRequest:registrationRequest];
}
Call this method 1st to register ur device.
来源:https://stackoverflow.com/questions/8104806/iphone-authorize-net-sdk-integration