I'm trying to void an existing AUTH_CAPTURE transaction on an iOS device using the transaction ID and it is failing. I can't find what the minimum required fields are to void a transaction. I've tried just creating a TransactionRequestType and setting the refTransID and authCode and set the TransactionRequestType object to a CreateTransactionRequest object, and it said the credit card field was invalid. So I added the payment type and set the card number and expiration date and now the error is this:
element is invalid - The value '' is invalid according to its datatype 'String' - The Pattern constraint failed.
Please help!
01-24-2013 03:26 PM
Here is the minimum required fields.
The credit card info is not required for a void transaction.
01-24-2013 04:53 PM
Below is the code I'm using to set the minimum required fields, and it's still giving me a weird error. It's saying that the credit card field is invalid, but I never even created a credit card type or anything.
AuthNet *an = [AuthNet getInstance];
TransactionRequestType *requestType = [TransactionRequestType transactionRequest];
requestType.refTransId = self.transactionID;
CreateTransactionRequest *request = [CreateTransactionRequest createTransactionRequest];
request.transactionRequest = requestType;
request.transactionType = VOID;
request.anetApiRequest.merchantAuthentication.mobileDeviceId = [[[Device currentDevice] uuid] stringByReplacingOccurrencesOfString:@"-" withString:@"_"];
request.anetApiRequest.merchantAuthentication.sessionToken = sessionToken;
[an voidWithRequest:request];
Also, if I look at the XML that is being auto generated, it doesn't even include the transaction type or the transaction ID in the XML:
<?xml version="1.0" encoding="utf-8"?><createTransactionRequest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd"><merchantAuthentication><sessionToken>HZyvKhGAIfX4VR4jF_bT_jLgqfb5rsEFq$zeWhUdLfS3iC6SciKX6QN5PkjTM5CNx94WJCA9Dhgp4hxOnewePYsxooYHxi_qxPiqBlA56iFLz9WbdsfPBv8ezTb1w$axA$hSiejcAOm9Mj0UsY9r7gAA</sessionToken><mobileDeviceId>33B1555A_60BC_4117_9314_FDB570607A76</mobileDeviceId></merchantAuthentication><transactionRequest><payment><creditCard></creditCard><bankAccount></bankAccount><trackData></trackData></payment><order></order><lineItems></lineItems><customer></customer><billTo></billTo><shipTo></shipTo><transactionSettings></transactionSettings><userFields></userFields></transactionRequest></createTransactionRequest>
01-25-2013 12:18 PM
I got it to include the transaction type "voidTransaction" and the refTransID, and it's still telling me that the credit card field is invalid.
01-25-2013 01:00 PM
I FINALLY got it to work! You have to specify that the payment object is nil. I'm not sure if I needed to do the others or not, but I did it anyway.
AuthNet *an = [AuthNet getInstance];
TransactionRequestType *requestType = [TransactionRequestType transactionRequest];
requestType.payment = nil;
requestType.tax = nil;
requestType.duty = nil;
requestType.shipping = nil;
requestType.transactionType = @"voidTransaction";
requestType.refTransId = self.referenceNumber;
requestType.authCode = self.authCode;
CreateTransactionRequest *request = [CreateTransactionRequest createTransactionRequest];
request.transactionRequest = requestType;
request.transactionType = VOID;
request.anetApiRequest.merchantAuthentication.mobileDeviceId = [[[Device currentDevice] uuid] stringByReplacingOccurrencesOfString:@"-" withString:@"_"];
request.anetApiRequest.merchantAuthentication.sessionToken = sessionToken;
[an voidWithRequest:request];
01-25-2013 01:12 PM