9

我正在使用Authorize.net的客戶信息管理器API(CIM)。我的測試用例集中在用戶在結帳時給出錯誤的地址。Authorize.net CIM重複交易窗口

我的應用程序將嘗試給每個用戶提交表單時創建一個客戶檔案:

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

我試過設置傳遞x_duplicate_window,你可以在上面看到,以「額外選項」,其中,在SDK,是請求的以下部分:

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

不管我用什麼值x_duplicate_window,直到默認時間已過authorize.net總是會返回一個錯誤。

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

我擔心如果我們的(潛在的)的一個用戶嘗試提交了錯誤的地址,實現他或她的錯誤,然後同時發生事務超時被用錯誤的更多的時間約3分鐘的歡迎。

回答

9

有一個在Authorize.net SDK代碼中的錯誤:

〜線路360-364在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");結果中的一個節點不匹配str_replace函數調用:<extraOptions/>

修改str_replace會解決這個問題,它將沿着x_duplicate_window參數傳遞好:

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

Authorize.net的API太糟糕了,我的工作很糟糕。 – Acyra 2013-05-05 15:45:30

+2

我必須說,Stripe是我用過的最好的支付處理API。 – Nick 2014-07-16 02:44:22