cancel
Showing results for 
Search instead for 
Did you mean: 

AuthNet help

AuthNet dlegates not getting called ??

 

have followed all steps as specified..need help..what to do exactly??

Manju1990
Member
6 REPLIES 6

What's a dlegates?

 

First step is to supply us with more information. What programming language are you using? PHP? C#? What API are you using? AIM? SIM? What specific code are you using? Post it in a code box (fourth option from the left in rich text mode). What errors are you getting?

TJPride
Expert

Language used : Objective C (for iphone app development)

- (void) loginToGateway {
    MobileDeviceLoginRequest *mobileDeviceLoginRequest =
    [MobileDeviceLoginRequest mobileDeviceLoginRequest];
    mobileDeviceLoginRequest.anetApiRequest.merchantAuthentication.name =@"username";
    mobileDeviceLoginRequest.anetApiRequest.merchantAuthentication.password =@"password";
    mobileDeviceLoginRequest.anetApiRequest.merchantAuthentication.mobileDeviceId =
    [[[UIDevice currentDevice] uniqueIdentifier]
     stringByReplacingOccurrencesOfString:@"-" withString:@"_"];
    
    AuthNet *an = [AuthNet getInstance];
    [an authNetWithEnvironment:ENV_TEST];
    [an setDelegate:self];
    [an mobileDeviceLoginRequest: mobileDeviceLoginRequest];
    
}

- (void) 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] uniqueIdentifier]
     stringByReplacingOccurrencesOfString:@"-" withString:@"_"];
    request.anetApiRequest.merchantAuthentication.sessionToken = sessionToken;
    [an purchaseWithRequest:request];
}

- (void) requestFailed:(AuthNetResponse *)response {
    // Handle a failed request
}

- (void) connectionFailed:(AuthNetResponse *)response {
    // Handle a failed connection
}

- (void) paymentSucceeded:(CreateTransactionResponse *) response {
    // Handle payment success
}

- (void) mobileDeviceLoginSucceeded:(MobileDeviceLoginResponse *)response {
    sessionToken = [response.sessionToken retain];
    [self createTransaction];
}

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    [self loginToGateway];
    self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
    // Override point for customization after application launch.
    self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];
    return YES;
}

 As i am trying to implement authorize.net sdk so dont know much about AIM or how to and where to use the APIs in my code. This code i found from sample docs of authorize.net site itself. so how exactly to implement the concept ,i dont know..can u help me to solve out this thing.

Did you follow the directions above the sample code? Also see step 4. According to that, it should fail on login until you register your device inside your account.

https://developer.authorize.net/integration/fifteenminutes/ios

 

There also seem to be a few differences between your code and what's on the code sample there. And I notice that your card expiration date has a weird character in it, and you don't have any code in the failure / success handlers, so you have no way to tell if a transaction goes through or not.

 

I'm only scratching the surface, of course - I'm not an iPhone programmer and I use PHP instead of C. So there's probably other things that someone with a more experienced eye would notice.

have followed all the steps and step 4 as well. But the thing is that delgates are not getting called .so how to make transaction and even track the transaction status? 

 

 

 

I would imagine it's something simple, but we'll have to wait for someone with iPhone experience. Can you retitle your first post to "AuthNet help with iPhone SDK?" so people are more likely to click it?

DId you do this before calling loginToGateway?

 

[AuthNet authNetWithEnvironment:ENV_TEST];