This topic contains 9 replies, has 0 voices, and was last updated by jschneller 8 years, 8 months ago.
-
AuthorPosts
-
September 3, 2015 at 2:02 pm #6872
sfsonarboyGreetings,
We’re working an integration where a Sales Order is entered via SuiteTalk. One of my business requirements is to immediately delete the Sales Order (and return a meaningful error message) if the credit card authorization fails. The problem I’m having is that NetSuite returns the authorization failure message via SOAP before I’m able to trap it in the SuiteScript (after submit) code. So far I’ve tried alternately setting the “getAuth” in the SOAP call or in SuiteScript, and have tried a bit of before_submit code as well, but still haven’t found a way to do this.
Thanks in advance for your assistance!
Steve Egelman
This is a cached copy. Click here to see the original post. -
September 8, 2015 at 11:53 am #6873
sfsonarboyJust a “bump” to see if anyone has any suggestions…thanks again!!
-
September 9, 2015 at 5:06 am #6874
Olivier Gagnon NCWhy is it a problem the auth failure occurs before your script? I thought you wanted to delete the SO if auth failed? How else would you know it failed if not for the auth message coming in before your script execution? What did you want as logic here?
-
September 9, 2015 at 12:10 pm #6875
sfsonarboyThanks for your reply Olivier and for any additional help you can offer. My replies in-line below.
Why is it a problem the auth failure occurs before your script?
SE: Because the SO is created/saved in NS; Business requirements are to not save the SO if credit card auth fails.
I thought you wanted to delete the SO if auth failed?
SE: Correct.
How else would you know it failed if not for the auth message coming in before your script execution?
SE: I was optimistic that I could do so in SuiteScript.
What did you want as logic here?
SE: We have some custom processing in SuiteScript that happens when a SO comes in via SuiteTalk. If CC auth fails we don’t want to run this custom processing or save the SO.
Thanks again!!
-
September 9, 2015 at 1:26 pm #6876
Olivier Gagnon NCOk, you’re in trouble then. CC auth happens AFTER the SO has saved. This is not avoidable. You can let it create, fail cc, then delete it. What you cannot do is prevent it from creating.
If that requirement cannot be modified, then you will need to code your own cc auth process to replace NetSuite’s own, so you can run that logic in before submit. If it fails, you could just throw an error to prevent the SO from saving.
The degree to which I do NOT recommend you try doing that cannot be sufficiently emphasized. It will take hundreds of hours to rebuild the auth process.
-
September 9, 2015 at 1:55 pm #6877
sfsonarboyThanks! Following-up on your comment “You can let it create, fail cc, then delete it.”, can you advise a bit more specifically about this? This is acceptable requirement-wise, as long as the SO can be deleted immediately and programmatically. So far I’ve tried setting getAuth on the SO to true in the SOAP request, which I couldn’t find a way to trap failure in SuiteScript for. I’ve also looked to setting getAuth to false in SOAP and true via SuiteScript but haven’t had too much success yet. Any suggestions about this (or if I’m missing something obvious) are greatly appreciated, and big thanks for your continued assistance!!
Steve
-
September 10, 2015 at 5:16 am #6878
Olivier Gagnon NCIn SuiteScript, in afterSubmit, you would then check the record to see if there is a Payment Event that is a failure. I think maybe there is a hidden field on the SO that also says if the cc failed, but it might be best to check the Event. I do remember doing this a few years back and indeed struggling with finding out how to detect the failure, but alas I no longer have the code where I achieved this. So my first bet would be to try checking for Payment Events.
-
September 15, 2015 at 3:21 pm #6879
sfsonarboyThanks again for your help! Indeed, checking the paymentevent sublist as a first step in my afterSubmit code solved the problem. Pasting a snippet below should anyone else run into this – my business case allows for no payment records or successful cc authorization, but should delete the SO in other scenarios which for us practically will be a cc failure. Thanks again!! Steve
[…noting curRec is the currently-submitted SalesOrder]
var curRecId = curRec.getId();
var paymentStatus = curRec.getLineItemValue(‘paymentevent’, ‘result’, 1);
if (paymentStatus != null && paymentStatus != ‘Accept’)
{
nlapiLogExecution(‘debug’, ‘CC auth failed, deleting SalesOrder: ‘, curRecId);
nlapiDeleteRecord(‘salesorder’, curRecId);
…
-
December 17, 2015 at 8:55 am #6880
seanlin816This is only doable after you submit the SO. We had the same requirement too. I can’t get a code snippet now. I will post it later.
-
March 10, 2016 at 1:07 pm #6881
jschnellerYou could take a customer deposit and if that is successful then submit the SO for saving. Then once you get the SO internalid update the customer deposit with the SO internalid so the deposit is tied to the sales order.
-
AuthorPosts
You must be logged in to reply to this topic.