Wappler 6.8.0 AC2
Mac M1, NodeJS, Docker
I have an API integration to a payment gateway, all works well, and I have lots of successful payments, however when I get a bank/card which force requires 3-D Secure v2 Verification Flow then I run into some troubles, as I need to get the response from the banks API, and then load a base64 encoded string so the user can enter a popup with another form which submits a user password that is either predefined or been sent to their phone for verification.
Here is the decoded base64 answer they send.
<form id="downloadform3D" name="downloadform3D" method="post" action="https://v2-sim.preprod.psp-solutions.com/acs-simulation/challenge?redirectUrl=https%3A%2F%2Fmdepayments.epdq.co.uk%2Fncol%2Ftest%2Forder_A3DS.asp" >
<noscript>
<div>JavaScript is currently disabled or is not supported by your browser<br/>
Please click on the "Continue" button to continue the processing of your 3-D secure transaction.<br/>
<input class="ncol" type="submit" value="Continue" id="submit1" name="submit1" />
</div>
</noscript>
<div>
<input type="hidden" name="CSRFKEY" value="C17284...79" >
<input type="hidden" name="CSRFTS" value="2024...1" >
<input type="hidden" name="CSRFSP" value="/ncol/test/orderdirect.asp" >
<input type="hidden" name="creq" value="eyJ...2In0">
<input type="hidden" name="threeDSSessionData" value="UE9Q...1Ng">
</div>
</form>
<form method="post" action="order_agree.asp" name="uploadForm3D" id="uploadForm3D">
<input type="hidden" name="CSRFKEY" value="D5CED1AE...381" >
<input type="hidden" name="CSRFTS" value="202...1631" >
<input type="hidden" name="CSRFSP" value="/ncol/test/orderdirect.asp" >
<input type="hidden" name="branding" value="" />
<input type="hidden" name="payid" value="42...6" />
<input type="hidden" name="storealias" value="" />
<input type="hidden" name="hash_param" value="CC29B931BF...C8" />
<input type="hidden" name="xid_3D" value="" />
<input type="hidden" name="version_3D" value="" />
<input type="hidden" name="status_3D" value="XX" />
<input type="hidden" name="eci_3D" value="7" />
<input type="hidden" name="error_3D" value="" />
<input type="hidden" name="cardnumber" value="" />
<input type="hidden" name="Ecom_Payment_Card_Verification" value="123" />
<input type="hidden" name="CVCFlag" value="3" />
<input type="hidden" name="cavv_3D" value="" />
<input type="hidden" name="cavvalgorithm_3D" value="" />
<input type="hidden" name="signatureOK_3D" value="" />
<input type="hidden" name="hash_param_3D" value="D0...BB" />
</form>
<SCRIPT LANGUAGE="Javascript" >
<!--
var popupWin;
var submitpopupWin = 0;
function LoadPopup() {
if (self.name == null) {
self.name = "ogoneMain";
}
popupWin = window.open('about:blank', 'popupWin', 'height=400, width=390, status=yes, dependent=no, scrollbars=yes, resizable=no');
if (popupWin != null) {
if (!popupWin || popupWin.closed) {
return 1;
} else {
if (!popupWin.opener || popupWin.opener == null) {
popupWin.opener = self;
}
self.document.forms.downloadform3D.target = 'popupWin';
if (submitpopupWin == 1) {
self.document.forms.downloadform3D.submit();
}
popupWin.focus();
return 0;
}
} else {
return 1;
}
}
submitpopupWin = 1;
var aalp=LoadPopup();
if (aalp==1){
var OldMD = self.document.forms.downloadform3D.MD.value;
var NewMD = 'MAINW';
var ii;
for(ii = 5; ii< OldMD.length;ii++){
NewMD=NewMD + OldMD.charAt(ii);
}
self.document.forms.downloadform3D.MD.value = NewMD;
self.document.forms.downloadform3D.submit();
} else {
}
//-->
</SCRIPT>
Anyone have some advice how i should handle this, especially considering, that this needs to happen midway through my already processing form submit and running server action.
The Current Flow
- User gets to the payment page
- After entering card details, they submit, my Server Action runs.
Server Action Steps
- API Action to the Banks endpoint with form data.
- Database Insert successful response from bank
- Emails success or error from API response
Form
- on-success: reset form, show modal with success message
- on-error: show modal with error message.
Questions are
- How do i load this returned HTML
- How do i break out of the server action after getting this particular API response, and then continue the script running after the user enters their one time pin.