[SOLVED] Simple HTTP Submission - Not Working

Just starting out? Need help? Post your questions and find answers here.
JHAustin1969
New User
New User
Posts: 2
Joined: Thu Aug 15, 2019 2:40 pm

[SOLVED] Simple HTTP Submission - Not Working

Post by JHAustin1969 »

Hello All,

I am new to PureBasic and have scoured the Help files and this Forum for a solution to the issue I am having, to no avail, so I am turning to you for some guidance.
I am using PureBasic 5.70 LTS (Windows - x64)

If I paste the below concatenated URL into any browser, I get the Response text I'm looking for, also below. If I log into the site, I can see that the transaction was successful, so I know it works. (BTW - All Data is Test Data, through a Test Account. I work for a Credit Card Processing Company and am looking to build a Simple POS system. I am using PB to prototype a Direct Post method that this Site supports. If I can get this working, which I have been able to do using App Game Kit (AGK), then I can proceed with the project. AGK doesn't have native GUI abilities, so I thought PB would be a better prototyping solution.)

The issue is that, I just can't seem to get PB to send that URL to the Site and then return a Response.

Concatenated URL sent to Site:
https://secure.nmi.com/api/transact.php ... ccexp=0319


Response From Site:
response=1&responsetext=SUCCESS&authcode=123456&transactionid=4855334505&avsresponse=N&cvvresponse=&orderid=&type=sale&response_code=100



Here is the current iteration of my code: (Taken from the Help Files)

Code: Select all

If InitNetwork() = 0
  MessageRequester("Error", "Can't initialize the network !", 0)
  End
EndIf

Port = 443
Path$ = "https://secure.nmi.com/api/transact.php?"

Username$ = "JPBTest"
Password$ = "08Aug2019"
firstname$ = "John"
lastname$  = "Smith"
address1$  = "45 Testing Road"
city$      = "Somewhere"
state$     = "MA"
zip$       = "02021"

Posting$ = Path$ + "username=" + Username$ + "&password=" + Password$ + "&firstname=" + firstname$ + "&lastname=" + lastname$ + "&address1=" + address1$ + "&city=" + city$ + "&state=" + state$ + "&zip=" + zip$ + "&payment=creditcard&type=sale" + "&amount=1.00&ccnumber=374245005741003&ccexp=0319"   

HttpRequest = HTTPRequest(#PB_HTTP_Get, Path$, Posting$, #PB_HTTP_Asynchronous)
If HttpRequest
  Debug "StatusCode: " + HTTPInfo(HTTPRequest, #PB_HTTP_StatusCode)
  Debug "Response: " + HTTPInfo(HTTPRequest, #PB_HTTP_Response)
  
  FinishHTTP(HTTPRequest)
Else
  Debug "Request creation failed"
EndIf
Any help would be greatly appreciated!

JHAustin
Last edited by JHAustin1969 on Sun Aug 25, 2019 10:05 pm, edited 1 time in total.
User avatar
mk-soft
Always Here
Always Here
Posts: 5393
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Simple HTTP Submission - Not Working

Post by mk-soft »

With "#PB_HTTP_Asynchronous" you need HTTPProgress() loop.
Remove it...
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
mk-soft
Always Here
Always Here
Posts: 5393
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Simple HTTP Submission - Not Working

Post by mk-soft »

P.S.
- No URL inside Posting
- Convert Posting with URLEncoder(...)

Code: Select all

If InitNetwork() = 0
  MessageRequester("Error", "Can't initialize the network !", 0)
  End
EndIf

Port = 443
Path$ = "https://secure.nmi.com/api/transact.php"

Username$ = "JPBTest"
Password$ = "08Aug2019"
firstname$ = "John"
lastname$  = "Smith"
address1$  = "45 Testing Road"
city$      = "Somewhere"
state$     = "MA"
zip$       = "02021"

Posting$ = URLEncoder("username=" + Username$ + "&password=" + Password$ + "&firstname=" + firstname$ + "&lastname=" + lastname$ + "&address1=" + address1$ + "&city=" + city$ + "&state=" + state$ + "&zip=" + zip$ + "&payment=creditcard&type=sale" + "&amount=1.00&ccnumber=374245005741003&ccexp=0319")
Debug Posting$

HttpRequest = HTTPRequest(#PB_HTTP_Get, Path$, Posting$);, #PB_HTTP_Asynchronous)
If HttpRequest
  Debug "StatusCode: " + HTTPInfo(HTTPRequest, #PB_HTTP_StatusCode)
  Debug "Response: " + HTTPInfo(HTTPRequest, #PB_HTTP_Response)
  
  FinishHTTP(HTTPRequest)
Else
  Debug "Request creation failed"
EndIf
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
JHAustin1969
New User
New User
Posts: 2
Joined: Thu Aug 15, 2019 2:40 pm

Re: Simple HTTP Submission - Not Working

Post by JHAustin1969 »

@mk-soft - Thank you!!

I knew it had to be something simple!! Much appreciated!

JHAustin
Post Reply