x

Have SqPaymentForm report errors back to server?

I want to monitor the type of errors our customer experience when checking out using the SqPaymentForm.  The .js code uses the "console.log" statement for development purposes, which is commented out in the production version, because those messages are only sent to the browser's console window.  What I really want is for those errors to be sent back to the server and appended to a "nonce_error.log" so I can get see the kind and frequency of problems our customers are having.

 

Any suggestions?

626 Views
Message 1 of 3
Report
2 REPLIES 2
Admin

@dougvan I checked in with our API Specialists and we don't have any examples showing for this I'm afraid!

 

In the meantime, this Stack Overflow question might help or you can post a new question in our Developer Community on Stack Overflow.

️ Helen
Seller Community Manager

Did you find help in the Seller Community? Mark a Best Answer to help others.
607 Views
Message 2 of 3
Report

I finally got around to implementing this feature in our code.  Someone found a super slick method when all you want to do is send some info from javascript back to the website -- just create an "Image" object and set the ".src" property to a URL you have on your website!  (he called it a "beacon")

 

Following is the code added to the .js file in the "if (errors)" section of the cardNonceResponseReceived function.  I just send the same error message the user was shown:

 

var beacon = new Image();
beacon.src="http://example.com/nonce_err.php?error=" + encodeURIComponent(errid.innerHTML);

My "nonce_err.php" program is very simple.  I chose to add a date/time stamp in front of each error message.

 

$str = $_REQUEST['error'];
$log = date("F j, Y, g:i a") . ": $str\n";
file_put_contents(nonce_err.log', $log, FILE_APPEND);

I can now see the various errors my customers see when they have trouble entering their credit card info in the "nonce_err.log" file.  Hope this helps someone else!

555 Views
Message 3 of 3
Report