Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Authorize.net CIM Duplicate Transaction Window

I'm working with Authorize.net's Customer Information Manager API (CIM). My test case is centered around a user giving the wrong address during checkout.

My application will attempt to create a customer profile each time the user submits the form:

$txrq = new AuthorizeNetCIM;
$txrsp = $txrq->createCustomerProfileTransaction("AuthCapture", $transaction, 'x_duplicate_window=0');

I've tried setting passing x_duplicate_window as you can see above to "Extra Options," which, in the SDK, is the following part of the request:

<extraOptions><![CDATA[' . $this->_extraOptions . ']]></extraOptions>

No matter what value I use for x_duplicate_window, authorize.net will always return an error until the default time has passed.

AuthorizeNet Error: Response Code: 3 Response Subcode: 1 Response Reason Code: 11 Response Reason Text: A duplicate transaction has been submitted.

I worry if one of our (potential) users tries to submit the wrong address, realizes his or her error, and then gets greeted with 3 more additional minutes of errors while the transaction timeout occurs.

like image 402
Nick Avatar asked Jul 16 '12 04:07

Nick


1 Answers

There is an error in the Authorize.net SDK code:

~Line 360-364 in CIM.php's method _setPostString()

if ($this->_extraOptions) {
    $this->_xml->addChild("extraOptions");
    $this->_post_string = str_replace("<extraOptions></extraOptions>",'<extraOptions><![CDATA[' . $this->_extraOptions . ']]></extraOptions>', $this->_xml->asXML());
    $this->_extraOptions = false;
}

$this->_xml->addChild("extraOptions"); results in a node that does not match the str_replace call: <extraOptions/>

Modifying the str_replace will remedy this, which will pass along the x_duplicate_window parameter just fine:

if ($this->_extraOptions) {
    $this->_xml->addChild("extraOptions");
    $this->_post_string = str_replace("<extraOptions/>",'<extraOptions><![CDATA[' . $this->_extraOptions . ']]></extraOptions>', $this->_xml->asXML());
    $this->_extraOptions = false;
}
like image 74
Nick Avatar answered Oct 02 '22 16:10

Nick