Posts: 2
Registered: ‎03-11-2017
Accepted Solution

Accept.JS and Integration Testing

I am trying to set up an integration test for a workflow that uses Accept.JS but have run into an issue. Since the dataDescriptor and dataValue are retrieved using Accept.JS, I can't seem to figure out how to run a test transaction to our sandbox strictly using PHP. 


Has anyone had any success settong up testing for an Accept.JS workflow?

Posts: 375
Registered: ‎11-03-2016

Re: Accept.JS and Integration Testing

Hi @greckers,


You've got a couple of options here. For a complete end to end test running in PHP, you could look into something like v8js, which is an extension to access the Chrome V8 interpreter from within PHP. Your test scripts could run independent of the browser, and get the dataDescriptor and dataValue by interacting with our accept.js script.


I can't promise this would work as I've not tried it myself. Our script does some checking to make sure it's being called from a page served from a secure connection, so you'd have to set up the v8js environment to make sure the protocol and window.location and everything looked right to our script.


Option 2: If you step through the Accept.js script and the AcceptCore.js script, you can see what they're actually doing is making a call to our API with the card data and getting a payment token back. This API request isn't documented anywhere, but if you follow every step through the scripts, and reference the schema XSD, you can see how it's constructed. I'll save a step and just post a sample request here:

<securePaymentContainerRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
    		<fullName>Testy McTesterson</fullName>

Sending a request like this gets a response like so:

<?xml version="1.0" encoding="utf-8"?>
<securePaymentContainerResponse xmlns:xsi="" xmlns:xsd="" xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">

Using this format, you could write a script to get the payment nonce/token for your tests without interacting with JavaScript at all.


There's no guarantee that this would continue to work. It would be a hack on your part with no official support from us. But, it's what our scripts are doing currently.



Aaron Wright
Developer Advocate - Authorize.Net

Follow Authorize.Net developer news on Twitter!
Posts: 2
Registered: ‎03-11-2017

Re: Accept.JS and Integration Testing

Hi Aaron,


This is perfect. Option 2 was exactly what I was hoping for. I tried to read through the scripts but figured somebody may have already figured out what the request would need to be and I didn't need to bang my head against the wall for hours figuring out the right request info.


I'm sure I will get some failed tests if the script changes but I think I can live with that for now and I'm sure its not going to change too often (hopefully).

Posts: 4
Registered: ‎12-02-2011

Re: Accept.JS and Integration Testing

@greckers, did you have any luck with this, or do you have any advice to share on your experience or things to keep an eye out for?  I'm trying to do the same thing.  Thanks!