I am trying to refund credit card transactions through the AIM api.
Heres my code in php:
$this->_constructXml("createTransactionRequest");
($params['transID'] ?
$this->_xml->addChild("refId", $params['transID']) : null);
$transactionRequest = $this->_xml->addChild("transactionRequest");
$transactionRequest->addChild("transactionType","refundTransaction");
($params['amount'] ?
$transactionRequest->addChild("amount", $params['amount']) : null);
$payment = $transactionRequest->addChild("payment");
$paymentCreditCard = $payment->addChild("creditCard");
($params['creditCardNumber'] ?
$paymentCreditCard->addChild("cardNumber", $params['creditCardNumber']) : null);
$result = $this->makeRequest();
when i try to execute this code i get the error
The element 'creditCard' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd' has incomplete content. List of possible elements expected: 'expirationDate' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd'.
But when i execute the getTransactionDetail i get the expiration date as XXXX.
[payment] => SimpleXMLElement Object
(
[creditCard] => SimpleXMLElement Object
(
[cardNumber] => XXXX0012
[expirationDate] => XXXX
[cardType] => Discover
)
)
So i randomly put the expiartion date as 0713 and it worked. May be since its sandbox account it didn't verify the expiration date.
$paymentCreditCard->addChild("expirationDate", "0713");
But my issue is how would i make it to work in live environment since the credit card expiartion dates cannot be retrieved.
Is the code correct? Any help?
Thanks in advance.
Regards,
Sarita.
Solved! Go to Solution.
06-01-2013 04:57 AM
Thank you RaynorC1emen7 for your help and pointing that out.
Yes the xml node sequence was actually wrong and its 'refTransId' and not refId.
The refTransId node should be after the payment node.
And yes the XXXX masked expiration date works too :).
Heres the correct code:
$this->_constructXml("createTransactionRequest"); $transactionRequest = $this->_xml->addChild("transactionRequest"); $transactionRequest->addChild("transactionType","refundTransaction"); ($params['amount'] ? $transactionRequest->addChild("amount", $params['amount']) : null); payment = $transactionRequest->addChild("payment"); $paymentCreditCard = $payment->addChild("creditCard"); $paymentCreditCard->addChild("cardNumber", 'XXXX0027'); $paymentCreditCard->addChild("expirationDate", "XXXX"); ($params['transID'] ? $transactionRequest->addChild("refTransId", $params['transID']) : null); $result = $this->makeRequest();
And heres the link for the correct xml format
06-11-2013 04:04 AM
Did you try just XXXX (masked expiration date)? or just send in blank?
06-01-2013 07:27 AM
Yes i had tried that but it gave me an error credit card expiration date is invalid.
Also the refund API works only when i provide the whole credit card number which too are not returned from the getTransactionDetails. Last 4 digits or numbers like XXXX0012 gives an error credit card number is invalid.
Any ideas please?
06-03-2013 03:52 AM
The xml documentation said the reference id is <refTransId> not <refId>
probably it think it is a unlinked credit which required full credit card information
06-03-2013 04:53 AM
I tried using 'refTransId' instead of 'refId' but it gives the following error
[message] => SimpleXMLElement Object ( [code] => E00003 [text] => The element 'createTransactionRequest' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd' has invalid child element 'refTransId' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd'. List of possible elements expected: 'refId, transactionRequest' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd'. )
I am able to refund only when i use refId along with the whole credit card number and expiration date.
Any ideas please how I could make it work?
Thank You.
06-09-2013 11:39 PM
Read the xml documentation. you need to follow the xml node sequence.
06-10-2013 05:03 AM
Thank you RaynorC1emen7 for your help and pointing that out.
Yes the xml node sequence was actually wrong and its 'refTransId' and not refId.
The refTransId node should be after the payment node.
And yes the XXXX masked expiration date works too :).
Heres the correct code:
$this->_constructXml("createTransactionRequest"); $transactionRequest = $this->_xml->addChild("transactionRequest"); $transactionRequest->addChild("transactionType","refundTransaction"); ($params['amount'] ? $transactionRequest->addChild("amount", $params['amount']) : null); payment = $transactionRequest->addChild("payment"); $paymentCreditCard = $payment->addChild("creditCard"); $paymentCreditCard->addChild("cardNumber", 'XXXX0027'); $paymentCreditCard->addChild("expirationDate", "XXXX"); ($params['transID'] ? $transactionRequest->addChild("refTransId", $params['transID']) : null); $result = $this->makeRequest();
And heres the link for the correct xml format
06-11-2013 04:04 AM
Is there any other way for refund transaction? i want to refund using just transactionid and don't want to use card details.
11-15-2016 07:47 PM