<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic how to handle connection error in accept.js? in Integration and Testing</title>
    <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/how-to-handle-connection-error-in-accept-js/m-p/62278#M36634</link>
    <description>&lt;P&gt;I am following the tutorial to integrate Accept.js&lt;/P&gt;&lt;P&gt;&lt;A href="https://developer.authorize.net/api/reference/features/acceptjs.html" rel="nofollow noreferrer" target="_blank"&gt;https://developer.authorize.net/api/reference/features/acceptjs.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;let me get to the point&lt;/P&gt;&lt;P&gt;Here is the form&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&amp;lt;form id="paymentForm"
    method="POST"
    action="https://YourServer/PathToExistingPaymentProcessingScript" &amp;gt;
    &amp;lt;input type="text" name="cardNumber" id="cardNumber" placeholder="cardNumber"/&amp;gt; &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;
    &amp;lt;input type="text" name="expMonth" id="expMonth" placeholder="expMonth"/&amp;gt; &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;
    &amp;lt;input type="text" name="expYear" id="expYear" placeholder="expYear"/&amp;gt; &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;
    &amp;lt;input type="text" name="cardCode" id="cardCode" placeholder="cardCode"/&amp;gt; &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;
    &amp;lt;input type="hidden" name="dataValue" id="dataValue" /&amp;gt;
    &amp;lt;input type="hidden" name="dataDescriptor" id="dataDescriptor" /&amp;gt;
    &amp;lt;button type="button" onclick="sendPaymentDataToAnet()"&amp;gt;Pay&amp;lt;/button&amp;gt;
&amp;lt;/form&amp;gt;&lt;/PRE&gt;&lt;P&gt;and here is the function called&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&amp;lt;script type="text/javascript"&amp;gt;
function sendPaymentDataToAnet() {
    var authData = {};
        authData.clientKey = "YOUR PUBLIC CLIENT KEY";
        authData.apiLoginID = "YOUR API LOGIN ID";
    var cardData = {};
        cardData.cardNumber = document.getElementById("cardNumber").value;
        cardData.month = document.getElementById("expMonth").value;
        cardData.year = document.getElementById("expYear").value;
        cardData.cardCode = document.getElementById("cardCode").value;

    // If using banking information instead of card information,
    // build a bankData object instead of a cardData object.
    //
    // var bankData = {};
    //     bankData.accountNumber = document.getElementById('accountNumber').value;
    //     bankData.routingNumber = document.getElementById('routingNumber').value;
    //     bankData.nameOnAccount = document.getElementById('nameOnAccount').value;
    //     bankData.accountType = document.getElementById('accountType').value;

    var secureData = {};
        secureData.authData = authData;
        secureData.cardData = cardData;
        // If using banking information instead of card information,
        // send the bankData object instead of the cardData object.
        //
        // secureData.bankData = bankData;

        Accept.dispatchData(secureData, responseHandler);
}
&amp;lt;/script&amp;gt;&lt;/PRE&gt;&lt;P&gt;Now sometimes there is connection problem and Accept.dispatchData fails. i.e you get connection error in javascript console.&lt;/P&gt;&lt;P&gt;I have tried wrapping the Accept.dispatch code in try catch block but it doesnt catch the exception. So i am wondering how to catch the net connection error when Accept.dispatchData is executing and there is connection problem. I appreciate any help! Thanks!&lt;/P&gt;&lt;P&gt;Here is the connection error i am getting.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I cannot upload the image so please check here for the error image.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://stackoverflow.com/questions/49444998/how-to-handle-connection-error-in-accept-js" target="_blank"&gt;https://stackoverflow.com/questions/49444998/how-to-handle-connection-error-in-accept-js&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 23 Mar 2018 08:26:55 GMT</pubDate>
    <dc:creator>kofhearts</dc:creator>
    <dc:date>2018-03-23T08:26:55Z</dc:date>
    <item>
      <title>how to handle connection error in accept.js?</title>
      <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/how-to-handle-connection-error-in-accept-js/m-p/62278#M36634</link>
      <description>&lt;P&gt;I am following the tutorial to integrate Accept.js&lt;/P&gt;&lt;P&gt;&lt;A href="https://developer.authorize.net/api/reference/features/acceptjs.html" rel="nofollow noreferrer" target="_blank"&gt;https://developer.authorize.net/api/reference/features/acceptjs.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;let me get to the point&lt;/P&gt;&lt;P&gt;Here is the form&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&amp;lt;form id="paymentForm"
    method="POST"
    action="https://YourServer/PathToExistingPaymentProcessingScript" &amp;gt;
    &amp;lt;input type="text" name="cardNumber" id="cardNumber" placeholder="cardNumber"/&amp;gt; &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;
    &amp;lt;input type="text" name="expMonth" id="expMonth" placeholder="expMonth"/&amp;gt; &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;
    &amp;lt;input type="text" name="expYear" id="expYear" placeholder="expYear"/&amp;gt; &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;
    &amp;lt;input type="text" name="cardCode" id="cardCode" placeholder="cardCode"/&amp;gt; &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;
    &amp;lt;input type="hidden" name="dataValue" id="dataValue" /&amp;gt;
    &amp;lt;input type="hidden" name="dataDescriptor" id="dataDescriptor" /&amp;gt;
    &amp;lt;button type="button" onclick="sendPaymentDataToAnet()"&amp;gt;Pay&amp;lt;/button&amp;gt;
&amp;lt;/form&amp;gt;&lt;/PRE&gt;&lt;P&gt;and here is the function called&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&amp;lt;script type="text/javascript"&amp;gt;
function sendPaymentDataToAnet() {
    var authData = {};
        authData.clientKey = "YOUR PUBLIC CLIENT KEY";
        authData.apiLoginID = "YOUR API LOGIN ID";
    var cardData = {};
        cardData.cardNumber = document.getElementById("cardNumber").value;
        cardData.month = document.getElementById("expMonth").value;
        cardData.year = document.getElementById("expYear").value;
        cardData.cardCode = document.getElementById("cardCode").value;

    // If using banking information instead of card information,
    // build a bankData object instead of a cardData object.
    //
    // var bankData = {};
    //     bankData.accountNumber = document.getElementById('accountNumber').value;
    //     bankData.routingNumber = document.getElementById('routingNumber').value;
    //     bankData.nameOnAccount = document.getElementById('nameOnAccount').value;
    //     bankData.accountType = document.getElementById('accountType').value;

    var secureData = {};
        secureData.authData = authData;
        secureData.cardData = cardData;
        // If using banking information instead of card information,
        // send the bankData object instead of the cardData object.
        //
        // secureData.bankData = bankData;

        Accept.dispatchData(secureData, responseHandler);
}
&amp;lt;/script&amp;gt;&lt;/PRE&gt;&lt;P&gt;Now sometimes there is connection problem and Accept.dispatchData fails. i.e you get connection error in javascript console.&lt;/P&gt;&lt;P&gt;I have tried wrapping the Accept.dispatch code in try catch block but it doesnt catch the exception. So i am wondering how to catch the net connection error when Accept.dispatchData is executing and there is connection problem. I appreciate any help! Thanks!&lt;/P&gt;&lt;P&gt;Here is the connection error i am getting.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I cannot upload the image so please check here for the error image.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://stackoverflow.com/questions/49444998/how-to-handle-connection-error-in-accept-js" target="_blank"&gt;https://stackoverflow.com/questions/49444998/how-to-handle-connection-error-in-accept-js&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Mar 2018 08:26:55 GMT</pubDate>
      <guid>https://community.developer.cybersource.com/t5/Integration-and-Testing/how-to-handle-connection-error-in-accept-js/m-p/62278#M36634</guid>
      <dc:creator>kofhearts</dc:creator>
      <dc:date>2018-03-23T08:26:55Z</dc:date>
    </item>
  </channel>
</rss>

