Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PHP accepting parameters but script not running - can it be done 2

Status
Not open for further replies.

LTeeple

Programmer
Joined
Aug 21, 2002
Messages
362
Location
CA
Dear colleagues,

Perhaps I'm foggy on php, having written relatively few scripts. I'm backed into a corner here, and would appreciate some advice.

I have a purchasing system where the user enters information to purchase 'tickets' for an event. The form, upon submittal, goes to a separate secure system (which I have no control over) which accepts certain parameters from the form. This separate secure system takes the users' credit card information, and along with the parameters from the form, processes the transaction.

Once the credit card information is processed, the system sends back to me a verification code (certain value for credit card accepted, and a different value for declined). The problem is, the script doesn't run, because this is happening behind the scenes. Is there a way to accept the parameters, and process them accordingly, say on a page called 'complete.php', even though the user never lands on the page?

If PHP isn't the solution, are there any suggestions for a language that can accomplish this?

My main goal is for a script that can accept parameters behind the scenes, and run a couple of functions, without the user ever seeing the page or knowing it exists.

Thank you for your time!

[cheers]
Cheers!
Laura
 
the script you call accepts parameters as POST or GET parameters?
 
Oops! As POST parameters.

Thanks :)

[cheers]
Cheers!
Laura
 
you could try to use frames...
have two frames (the main one from where you submit the user's data, and another one initially having as location about:blank to which you submit the data). basically, once the user submits the form, by using a bit of javascript, in the main form you display something like "checking your information" while using a javascript to constantly check for the other frame (the one to which you sibmitted the data) to see if it's loaded (you can use a window.setInterval - to create an interval at which you call a function that checks document.status to see if it's loaded). once it's loaded, try to see what's the content of the document in the second frame and according to it, you move on or display an error message.

hope this gives you a start.
 
The last time I needed to securely send data from a user to a credit-card company, I had the form submit to my local script. The script used PHP's cURL functions to send the data to the credit-card clearinghouse, react to the return, and provide a page informing the user.



Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Thanks for the quick responses.
DaZZleD, unfortunately, I cannot use frames. I am pretty limited in design. I must stick with a certain template. (unless there is a way to have an invisible frame that wouldn't affect the design in either IE or Netscape 4.x).
Is that possible?

sleipnir214, once my form is submitted to the credit-card clearinghouse, the user has technically left my site. There's no guaranteeing they'll be back. Can you please suggest how I could react to the data coming back from the credit-card clearing house? Do I use cURL for that?

Thanks again for the help people!

[cheers]
Cheers!
Laura
 
you can have an iframe in your design with width 0 and height 0 or a plain frame that has 0 width or height (depending on where you add it)
 
I can only agree with sleipnir214.
Have your script receive the parameters and store them locally. Invoke a remote call to the credit card clearing house using cURL for HTTP or another specified protocol that is supported by the clearing house. Last time I did this I used SOAP (nusoap class) to make the connection and receive the response.
This way the whole process relies on your server side scripting. When it somes to $$$ you don't want to rely on client side code to do anything. I recommend to keep everything under your full control i.e. server-side (PHP).
 
LTeeple:
Take a look at my FAQ faq434-2502. It talks about using cURL within a PHP script to send POST-method data to a foreign CGI.



Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Hi again, thanks for the responses folks. I wonder if I wasn't clear enough in my initial post.

DRJ478,
I don't rely on client-side for anything. it's all server-side scripting. The user types in their preferences. The form sends pre-determined data to the credit-card clearing house via POST (i.e. price, merchant ID, etc.)

After all is done, and the credit card order is processed, a code is generated on the credit-card clearing house. This code is sent to me via HTTP_POST.

I am then to use that code to update my database (i.e. insert the person's name, invoice number, and whether payment was accepted or not). I was just wondering if this can happen behind the scenes, without the user ever landing on the script that handles the return code.

[cheers]
Cheers!
Laura
 
I see - so you are not waiting for a response but the clearing house initiates a response as POST data to a specific return URL. Right?
It looks like you want to write a transactional server that initiates the authorization process and also receives the return code from the clearing house.
Have your initial script POST to your application. Save the data in a table and initiate the credit card transaction via a socket. Send the visitor to a page that displays the status of the initiated transaction.
In the background the clearing house will post to your "transaction server" script which updates the transaction tables. I'm sure there is some transaction ID involved which is transferred.
 
DRJ478

Hi thanks again for your responses. So you are saying I can save the data to a table. Then POST the required data via a socket?

This might be exactly what I need! Could you point me to documentation outlining sending data via socket? I need to know if there is a particular setup required on the server end (I have no control over that).

Thanks!!

[cheers]
Cheers!
Laura
 
sleipnir214's FAQ434-2502 mentioned in his post shows the use of sockets to contact an external server.
The basic socket functions are part of the PHP core. cURL is a compilation option. Look with phpinfo() what is available on your system.
 
The following question was posted as a comment to my FAQ faq434-2502 by LTeeple. I thought it best to post the question and my answer here.

LTeeple said:
The example posted for CURL shows the GET method. Is POST possible with this? The server I need to send to will only accept data sent via POST.

Also, does this require any special configuration on the server-side?

The cURL example code shows sending data to a CGI with included POST-method input values. This is indicated by the line:

curl_setopt ($curl_handle, CURLOPT_POST, 1);

which tells cURL to send the data via POST-method.

The code is based on working credit-card clearinghow communications code I use on serveral web sites. And the clearinghouse I've used required POST-method input, too.


I don't know what you mean by "configuration on the server-side". Are you asking about changes to your PHP installation? If so, yes, you have to make changes from the default configuration to PHP.

If not, I don't think I understand your question.



Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Thanks, sleipnir214

Re: your question: I don't know what you mean by "configuration on the server-side". I was asking about the server that will receive the POSTed variables. I understand now what I need to do.

I greatly appreciate your assitance! You and DRJ478 have both helped me get my head around this issue.

Best wishes!

[cheers]
Cheers!
Laura
 
Hi again!
I have sucessfully installed and configured CURL. I can send data to the clearing house, and have another question re: CURL that wasn't covered in sleipinir214's helpful FAQ, nor is it covered adequately on php.net:

When I execute the function curl_exec($curl_handle), the browser location is staying at my URL. The problem is, the server is configured to accept data ONLY from it's url. Here's the process:
The user types in his/her name, and request into my form. My form then intitiates the CURL exec to the credit-card clearing house. The clearing house gets the POSTed data just fine. From the page where the clearinghouse gets the POSTed data, the user then enters his/her credit card info. The clearing house processes the info and then sends the data back to me.

The problem hinges on the fact that when I execute curl_exec(), the browser location is staying at my website, and within the window, the creditcard clearinghouse page is loaded. when the user clicks submit after entering their cc information, the information is not processed because the referring URL is my web address, NOT the clearing house URL. Is do any one the CURLOPT_ constants handle this? The php.net information is net specific enough to help me. No explanation is provided about those constants...

Thanks for the help!!

[cheers]
Cheers!
Laura
 
I think I understand now:
The clearinghouse collects the credit card information, not you. You need to display their page for collection of the data. Then, after processing, the clearing house send you back some code.
There is a complete disconnect for some time between your application and the clearing house. I solved such a problem (as mentioned before) with a SOAP based transaction server.
1. User enters order and all data but the the credit card info.
2. Upon submission the order is written to the local database. A credit card transaction is opened in the local transaction table.
3. The application redirects (not cURL) to the clearing house page.
4. The clearing house takes the credit card info, processes.
5. Clearing house sends a return request to a probably initially provided URL that contains the transaction ID and the outcome.
6. The local receiving end closes the open credit card transaction and notes the authorization number etc.
 
DrJ478 - you have essentially paraphrased my situation, thank-you!

Can you direct me to any SOAP resources that I may investigate this further?

Thanks for your time!

[cheers]
Cheers!
Laura
 
I chose SOAP because it was "the thing to do" at the time and my credit card gateway was to be contacted by different applications. It also handles the application ID code etc.
You probably don't need that.
However, I'm not sure it is possible for your script to pass on the data to the clearinghouse using POST and have the user's browser end up on the clearinghouse page.
Maybe the clearinghouse has some technical docs that show how to transfer and process the information. That would help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top