Reply
Contributor
Posts: 48
Registered: ‎11-29-2016

Re: Help with Accept Hosted

Thanks, Aaron,

 

I am receiving a message in my popup javascript via the IFrameCommunicator when a transaction is approved.  Turns out that it's a set of JSON objects:

 

action=transactResponse&response={"accountType":"MasterCard","accountNumber":"XXXX4010","transId":"xxxxxx","authorization":"xxxxx","billTo":{"firstName":"Jerry","lastName":"Malcolm","address":"13016 xxxxxxxxx","city":"Austin","state":"Tx","zip":"787xx"},"shipTo":{},"totalAmount":"1.00","dateTime":"1/23/2017 7:33:34 PM"}

 Up to now, I have not been working with JSON other than the trivial coding of settings in some of the requests.  I know I can go find a JSON package that likely will parse this response into XML or give me an easy way to pull values out of it.  But being the lazy person I am... I suspect there might be some utility class already available somewhere in the Authnet API code that can process this JSON string and make it easier to retrieve the data.  Or am I on my own to download a JSON parser?  Not complaining... but with all of the helper code provided to send/receive API requests, it just seems odd that there would not be anything to assist with this response (??).

 

Thanks.

 

 

All Star
Posts: 699
Registered: ‎11-03-2016

Re: Help with Accept Hosted

If you're looking to process it within the script, JavaScript has a built-in JSON.parse() function to convert the string into an object. If you're passing the whole JSON object back to the application on the server and trying to get the application to deal with it, then you'll need a parser library in your application.

 

Might be easiest to let JavaScript turn it into an object, and then deliver that object to your application in whatever format your application wants.

Contributor
Posts: 48
Registered: ‎11-29-2016

Re: Help with Accept Hosted

I'll just let javascript handle it for me and pass the extracted parms to the server.

 

I understand that the docs for this are in progress.  Are there any docs yet that define all the possibilities I might get on this response?  e.g. if the card is expired, what fields is the response object going to contain?  Since I'm kinda 'reverse engineering' from the one 'approved' transaction I received, I'm afraid there are going to be some totally different response objects come in that I want to be sure to handle as well.

 

Thanks.

All Star
Posts: 699
Registered: ‎11-03-2016

Re: Help with Accept Hosted

Nothing yet, I'm afraid. It's extremely high priority for me, though, so I hope to have something sooner rather than later.

 

In the meantime, feel free to use our testing guide to simulate whatever responses you want to know about and see how the responses differ. I hope they don't differ in format, only in value, but if you see anything funky, please let me know.

Contributor
Posts: 48
Registered: ‎11-29-2016

Re: Help with Accept Hosted

It's going to be difficult for me to go back to the sandbox.  I've only got one instance running, and it's now live with the CIM functionality.  I can't take it down and move back to the sandbox.  I'd have to create a completely separate parallel instance to test in the sandbox.  Therefore, I think I'll just let it ride for a bit and handle 'accepted' transactions and just fail on anything that doesn't look like it was accepted.  I'll clean it up once your docs are all available.

 

That does bring up one additional question... In every API in CIM I have the standard line of code:

if (response.getMessages().getResultCode() == MessageTypeEnum.OK)

There is not a 'messages' section in the JSON response block I'm getting on the acceptHosted and therefore no resultCode.   I guess I can possibly just look at one of the other fields in the response, such as "authorization", and somehow determine from that whether it was accepted or rejected.  But without a little guidance, I'm a bit nervous.  Is there some field in what I'm getting that I can safely rely on to always tell me "OK" vs. "ERROR"?  And if so, what value do I look for to determine the transaction result?

Contributor
Posts: 48
Registered: ‎11-29-2016

Re: Help with Accept Hosted

Aaron,

 

I know you are thinking 'when will this guy go away????....' :-)

 

It just occurred to me after sending the last post that I might be overthinking this.  Is it the case that I will NEVER get this message unless the transaction is approved?  i.e. you just put any error messages up in the IFrame window until/unless the transaction is approved and then notify me, and therefore I simply don't need to handle error messages, etc?

 

If I'm wrong here and I can still get error messages as well via this IFrameCommunicator process, then ignore above, and the question in my previous post is still pending.

All Star
Posts: 699
Registered: ‎11-03-2016

Re: Help with Accept Hosted


@MalcolmEnt1 wrote:

 

Is it the case that I will NEVER get this message unless the transaction is approved?  i.e. you just put any error messages up in the IFrame window until/unless the transaction is approved and then notify me, and therefore I simply don't need to handle error messages, etc?


This is my current assumption. There's really three scenarios:

 

  1. Customer tries transaction and it fails.
  2. Customer tries transaction and it succeeds.
  3. Customer cancels transaction.

Transaction failures are handled in the form, giving the customer the ability to correct and retry without having to return to the merchant.

 Transaction success... well, you've seen what happens in that case.

Customer cancels - If the customer clicks on the cancel button and you have a cancel URL, you've got some notification there. If the customer just closes the browser window and walks away, well, there's very little we can do about that.

 

Given all this, I'm guessing what you're getting from the script is the only thing you get since it's the only scenario where that kind of notification is really needed. I still plan to fully test it myself to be sure, though.

 


@MalcolmEnt1 wrote:

 

I know you are thinking 'when will this guy go away????....' :-)

 


 

Ha ha! No worries!

 

Again, it's a great help to have people point out where things are confusing so that we can improve it for anyone else.

Contributor
Posts: 48
Registered: ‎11-29-2016

Re: Help with Accept Hosted

I'm not getting any iFrameCommunicator messages if Cancel is pressed on the AcceptHosted popup.  So I have no way to close the popup window.

 

I noticed that I only get the accept transaction message we were discussing yesterday if I set "showReceipt" setting to 'false'.  So I suspect there is some other flag I need to turn on or off to start receiving the cancel message (??)

 

I'm getting a resize message.  So I know the iFrameCommunicator is functioning.  However, when the window resizes, the buttons at the bottom are half cut off.  That's not as urgent an issue as the cancel message (or lack thereof) issue.

 

Thanks.

Contributor
Posts: 48
Registered: ‎11-29-2016

Re: Help with Accept Hosted

Any update on this latest question?

 

Thx

 

Jerry

All Star
Posts: 699
Registered: ‎11-03-2016

Re: Help with Accept Hosted

Sorry, no. Still testing on my end.