|
| WebDev 20 and ScriptDisplay |
| Iniciado por guest, 02,jun. 2015 20:00 - 9 respuestas |
| |
| | | |
|
| |
| Publicado el 02,junio 2015 - 20:00 |
Hi All ,
WebDev 20, and a ScriptDisplay question if anyone know.
I have a dynamic site integrated with the Paypal api, and after some forth and back between my site and palpal where the common word is a "token" it`s time to collect the money via an url that looks something like: https://www.paypal.com/webscr… And in my string variable PaypalURL contains this url.
So I used to do a simple: ScriptDisplay(PayPalUrl) and everything was ok. - But now - in WebDev 20 - it dont work anymore and Paypal gives me a cryptic "At this time, we are unable to process your request. Please return to and try another option."
Strange thing is if I (Within a certain time-frame) copy the content of PaypalURL variable and paste into the address bar of my browser PayPal kicks off as it should.
Stupid as I was I did not test the payment part working correctly (The most importen part), when I upgraded my site to WebDev 20. I could probably go back to v18 I guess but I have made a lot of other work in the same period.
WebDev 20 say something about a Pre-launched session (Whatever that might be) - can this be the reason the scriptdisplay will not do the trick anymore?.
Quote WD20 Pre-launched sessions
Pre-launched sessions
If your project is using pre-launched sessions, this function must not be used in the "Initializing project" process. This function must be used in the "Initializing the project after connection to the site" process.
I Tried the following: PayPalUrl = PayPalUrl + tokenlistFirst.TokenValue //commented out when using scriptdisplay with parameters. ScriptDisplay(PayPalUrl,tokenlistFirst.TokenValue,true) ScriptDisplay(PayPalUrl) PHPDisplay(PayPalUrl) //,tokenlistFirst.TokenValue,true) ScriptExecute(PayPalUrl,tokenlistFirst.TokenValue,true) Is there another smart way of start another url from a dynamic site in WebDev ? (I start Paypal and to do a EndProgram, Since paypal will call back to my site if transaction is Ok or if Canceled.)
Any help will be well received  Cheers Tor-Bjarne |
| |
| |
| | | |
|
| | |
| |
| Publicado el 03,junio 2015 - 08:58 |
Hi Tor-Bjarne,
In WB20 I see a new section of code in the project initialization: "Initializing the project after connection to the site". It looks like the error has something to do with that. Can you explain how and where you use the ScriptDisplay function? Show the section of code and the section of your page or project where the code is executed.
Regards, Piet |
| |
| |
| | | |
|
| | |
| |
| Publicado el 03,junio 2015 - 13:59 |
Hi Piet - thank you for your reply.
The code block is startet as server code from a button, and the fuction is called Paypalsetup()
--- Browser code -------------------- IF CBOX_LevBet = 1 THEN PopupDisplay(POPUP_NoName1,popupCenter) END --- Browser code -------------------- END --- Servercode -------------------------- IF CBOX_LevBet = 0 THEN Info("Du må godta leveringsbetingelsene først!") RETURN ELSE PayPalSetup() //This is the function that connects to paypal... IF ContextExist(PAGE_OrderPG1) THEN ContextClose(PAGE_OrderPG1) END END --- Servercode -------------------------- And the actuall PaypalSetup - code: PROCEDURE PayPalSetup() XFORM is string //m_taValueurs is ANSI string moAMount is currency = EDT_Totalt cyMVA is currency = EDT_MVA tabValues is array of strings arrTabValues2 is array of strings sM_taValues is string tokenlistFirst is Data Source HCreateView(tokenlistFirst,Template_PPTokens) HDeleteAll(tokenlistFirst) HTTPCreateForm(XFORM) HTTPAddParameter(XFORM,"USER",PayPalUser) HTTPAddParameter(XFORM,"PWD",PayPalPWD) HTTPAddParameter(XFORM,"SIGNATURE",PayPalSign) HTTPAddParameter(XFORM,"VERSION",PayPalVer) HTTPAddParameter(XFORM, "METHOD","SetExpressCheckout") HTTPAddParameter(XFORM, "PAYMENTREQUEST_0_AMT",NumToString(moAMount,".2f")) //HTTPAddParameter(XFORM, "PAYMENTREQUEST_0_TAXAMT",NumToString(MVA,".2f")) HTTPAddParameter(XFORM, "PAYMENTREQUEST_0_DESC","Produkter fra Industrisoftware AS Webbutikk ( "+NumToString(moAMount,".2f")+" kr )") Trace("Produkter fra Industrisoftware AS Webbutikk ( "+NumToString(moAMount,".2f")+" kr )") HTTPAddParameter(XFORM, "PAYMENTREQUEST_0_SELLERPAYPALACCOUNTID",gsPayPalACCID) HTTPAddParameter(XFORM, "CANCELURL",PayPalCANCEL) SWITCH Nation() CASE nationEnglish HTTPAddParameter(XFORM, "LOCALECODE","us_US") CASE nationNorwegian HTTPAddParameter(XFORM, "LOCALECODE","no_NO") OTHER CASE HTTPAddParameter(XFORM, "LOCALECODE","no_NO") END HTTPAddParameter(XFORM, "NOSHIPPING","0") //if nospace(EDT_Firmanavn) <> "" then // HTTPAddParameter(XFORM, "PAYMENTREQUEST_0_SHIPTONAME",EDT_Firmanavn) //else // HTTPAddParameter(XFORM, "PAYMENTREQUEST_0_SHIPTONAME",EDT_Navn) //end //HTTPAddParameter(XFORM, "PAYMENTREQUEST_0_SHIPTOSTREET",EDT_Addresse1) //HTTPAddParameter(XFORM, "PAYMENTREQUEST_0_SHIPTOSTREET2",EDT_Addresse2) //HTTPAddParameter(XFORM, "PAYMENTREQUEST_0_SHIPTOZIP",EDT_Postnr) //HTTPAddParameter(XFORM, "PAYMENTREQUEST_0_SHIPTOCITY",EDT_Sted) //HTTPAddParameter(XFORM, "PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE",COMBO_Country[[1 to 2]]) //Generer fakturanr sYear is string = Today() nrec is int = GetKeyValue("ORDERNO") IF nrec = 0 THEN WriteKeyValue("ORDERNO","1") nrec = 1 ELSE nrec += 1 WriteKeyValue("ORDERNO",NumToString(nrec) ) END HTTPAddParameter(XFORM, "PAYMENTREQUEST_0_INVNUM","WEB Ordre- "+sYear[[1 TO 4]]+"-"+nrec) PayPalOK = PayPalOK+nrec HTTPAddParameter(XFORM, "RETURNURL",PayPalOK) //HTTPAddParameter(XFORM, "EMAIL",EDT_Epost) SWITCH Nation() CASE nationEnglish HTTPAddParameter(XFORM, "PAYMENTREQUEST_0_CURRENCYCODE","USD") CASE nationNorwegian HTTPAddParameter(XFORM, "PAYMENTREQUEST_0_CURRENCYCODE","NOK") OTHER CASE HTTPAddParameter(XFORM, "PAYMENTREQUEST_0_CURRENCYCODE","NOK") END HTTPAddParameter(XFORM, "BRANDNAME","WinVask WEBShop") HTTPAddParameter(XFORM, "PAYMENTREQUEST_0_PAYMENTACTION","Sale") HTTPAddParameter(XFORM, "SOLUTIONTYPE","Sole") HTTPAddParameter(XFORM, "LANDINGPAGE","Billing") HTTPAddParameter(XFORM, "CHANNELTYPE","Merchant") HTTP.IgnoreError = httpIgnoreInvalidCertificate IF HTTPSendForm(XFORM,PayPalURL2) THEN // now you have all the answers from PayPal... you can extract them to read them // if you have a valid token, you can procede... etc. Trace("Sendform seems ok") // tabValeurs is array of strings StringToArray(HTTPGetResult(httpResult), tabValues, "&") FOR i = 1 TO tabValues..Occurrence // m_taValues[[ExtractString(m_taValues, 1, "=")]] = (m_taValues[[Position(m_taValues, "=") + 1 TO]]) Trace(URLDecode(i+" - "+tabValues)) tokenlistFirst.Token = ExtractString(tabValues, 1, "=") tokenlistFirst.TokenID = i tokenlistFirst.TokenValue = ExtractString(tabValues, 2, "=") Trace("Val: "+tokenlistFirst.Tokenvalue) HAdd(tokenlistFirst) END //m_taValeurs["TOKEN"] // get the token, etc. IF HReadSeek(tokenlistFirst,Token,"TOKEN",hLockNo) = True THEN // if HReadSeek(tokenlist,Token,"TOKEN",hLockNo) = True THEN // Info("GOT-TOKEN: '"+URLDecode(tokenlist.TokenValue)+"'") Trace("GOT-TOKEN: '"+URLDecode(tokenlistFirst.TokenValue)+"'") // IF HReadSeek(tokenlist,Token,"TOKEN",hLockNo) = True THEN // PayPalTimeToken = tokenlist.TokenValue HReset(Tmp_Sale) Tmp_Sale.IpAddr = BrowserIPAddress() Tmp_Sale.Date = Today() Tmp_Sale.Time = Now() Tmp_Sale.UniqueToken= URLDecode(tokenlistFirst.TokenValue) Tmp_Sale.SESSID = nrec Tmp_Sale.INVNUM = "WEB Ordre- "+sYear[[1 TO 4]]+"-"+nrec Tmp_Sale.Done = False HAdd(Tmp_Sale) //Lagre hvem varer som kanskje er under bestilling FOR EACH gdsVogn HReset(Tmp_OrderLines) Tmp_OrderLines.UniqueToken = URLDecode(tokenlistFirst.TokenValue) Tmp_OrderLines.Varenr = gdsVogn.Varenr Tmp_OrderLines.Antall = gdsVogn.Antall Tmp_OrderLines.Pris = gdsVogn.Pris Tmp_OrderLines.INVNUM = "WEB Ordre- "+sYear[[1 TO 4]]+"-"+nrec IF HAdd(Tmp_OrderLines) = False THEN Info("Got an error: "+HErrorInfo(hErrFullDetails)) END END PayPalUrl = PayPalUrl + tokenlistFirst.TokenValue Trace(PayPalUrl,tokenlistFirst.TokenValue) Trace(PayPalUrl) // ScriptDisplay(PayPalUrl,tokenlistFirst.TokenValue,true) ScriptDisplay(PayPalUrl) // PHPDisplay(PayPalUrl) //,tokenlistFirst.TokenValue,true) // ScriptExecute(PayPalUrl,tokenlistFirst.TokenValue,true) STOP // HTTPCancelForm(XFORM) // multitask(200) // PageDisplay(PAGE_TrStatus) EndProgram() // End // END ELSE Info("Invalid tokenlist") // PageDisplay(PAGE_trCancel) END ELSE Trace("Sendform failes") END |
| |
| |
| | | |
|
| | |
| |
| Publicado el 03,junio 2015 - 16:04 |
Hi Tor-Bjarne,
I have no idea what could be wrong, all I can say is that I'm not comfortable with the way you included the EndProgram in the procedure. You check in the calling code if the current context still exists after EndProgram may have been executed. My approach would be to let the function Paypalsetup() return an errror string if something goes wrong and do all the error messaging and resulting actions outside the function. IOW: use a "clean" function. --- Servercode -------------------------- IF CBOX_LevBet = 0 THEN Info("Du må godta leveringsbetingelsene først!") RETURN ELSE sError=PayPalSetup() IF sError<>"" then Error(sError) RETURN ELSE EndProgram() END END --- Servercode -------------------------- If the program should end, then do a RESULT "" in the PayPalSetup, Otherwise return an errortext.
Regards, Piet |
| |
| |
| | | |
|
| | |
| |
| Publicado el 03,junio 2015 - 16:23 |
HI Piet.
Ok - But it`s the scriptdisplay that works diffrently than before (WB18). Also if unclear, this is not a AWP site but a full dynamic site EndProgram terminates as it should.
Reason is that Paypal will call back my site again and starting a new session, so there`s no point in continue the session. "If scriptdisplay works then terminate" 
Cheers Tor-Bjarne |
| |
| |
| | | |
|
| | |
| |
| Publicado el 04,junio 2015 - 08:30 |
Hi Tor-Bjarne,
You are right, I was focusing on EndProgram, while ScriptDisplay should just do its job, regardless of what happens afterwards. Can you replicate the problem by using ScriptDisplay with a different url?
Regards, Piet |
| |
| |
| | | |
|
| | |
| |
| Publicado el 04,junio 2015 - 14:40 |
Hi Tor-Bjarne
just an idea... It's possible that your v18 program was in ansi by default, and your v20 is in UNICODE by default...
In that case, the string sent to paypal would be in unicode and paypal would just not understand it
Best regards |
| |
| |
| | | |
|
| | |
| |
| Publicado el 05,junio 2015 - 06:30 |
Hi,
Thank you for uour reply 
Fabrice - no, it`s a ANSI project.
Piet I did, and to my suprice the following code worked from a Button 
s is string = "http://81.27.47.93/WD180AWP/WD180Awp.exe/CONNECT/WinVask…=" s2 is string = "KASSE" s = s + s2 ScriptDisplay(s) EndProgram So now I wonder why my v18 code got broked in WD20?
But what I did notice during my following test is this:
The URL is wrong, but the variable I try to Scriptdisplay contains the right data?
//Url of browser http://localhosthttps//www.paypal.com/webscr… //Content of PalPalUrl variable: https://www.paypal.com/webscr… I think "My site " adds Http://IP-Address to everything scriptdisplay is doing and also it parses out the colon in the "actual" address. Sems to recall some setting regarding "the friendly site" name but I can`t recall where to change at the moment.
Cheers Tor-Bjarne |
| |
| |
| | | |
|
| | |
| |
| Publicado el 05,junio 2015 - 10:17 |
Hi Tor-Bjarne,
Time to make a request to Tech Support. Please let us know the result.
Regards, Piet |
| |
| |
| | | |
|
| | |
| |
| Publicado el 08,junio 2015 - 20:59 |
Hi,
Found it!
Seems like Scriptdisplay in v20 will urlencode your variable if it contains a url, but the url returned from PayPal is already urlencoded, this is the problem.
In WevDev v18 I had: Scriptdisplay(PaypalURL) V20 I need: ScriptDisplay(URLDecode(PayPalUrl)) Cheers Tor-Bjarne |
| |
| |
| | | |
|
| | | | |
| | |
|