Approval Post URL question

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
spacebiscuit
Forum Contributor
Posts: 390
Joined: Mon Mar 07, 2005 3:20 pm

Approval Post URL question

Post by spacebiscuit »

Hi,

I am using a 3rd party to accept/approve credit card transactions on my Website.

There is an option to pass back Approval Post URL information, such as cutomer name, email etc which I would like to capture and store in a database.

In principle it all seems easier enough to implement but my question is how will the PHP code which receives the date be invoked as PHP is a client-side based language.

However it must be possible as the payment ompany says :
"The Approval Post URL or Denial Post URL should point to a script such as CGI, PHP, ASP, etc. "
Any help would be apprecited.

Thanks,

Rob.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

The Approval Post URL is a standard HTTP request from the credit part processors servers.

I'm a bit confused by your post :?
User avatar
Chalks
Forum Contributor
Posts: 447
Joined: Thu Jul 12, 2007 7:55 am
Location: Indiana

Re: Approval Post URL question

Post by Chalks »

robburne wrote:In principle it all seems easier enough to implement but my question is how will the PHP code which receives the date be invoked as PHP is a client-side based language.

However it must be possible as the payment ompany says :
"The Approval Post URL or Denial Post URL should point to a script such as CGI, PHP, ASP, etc. "
um, PHP is a server-side language.

Also, it looks like they're asking for a page (mypage.php), but without more information such as what exactly they ask for... it's hard to say.


edit: I'm confused too.
spacebiscuit
Forum Contributor
Posts: 390
Joined: Mon Mar 07, 2005 3:20 pm

Post by spacebiscuit »

Ok let my try and explain in a little more detail.

When user wants to pay they are taken to a payment stage.

Once payment has been approved variable are sent to URL which I choose.

However once approved the customer is taken to a different page to that which I have chosen to receive the variable data, so how is the PHP code that I have set up ever to receive the data?

Does that mak any more sense?

Rob.
Begby
Forum Regular
Posts: 575
Joined: Wed Dec 13, 2006 10:28 am

Post by Begby »

When the transaction is complete, two things happen

1. Your client is redirected to another page by the third party

2. The third party server, at the same time as above or right before, sends a request to a URL of your choice with the data.


So the customer gets redirected to some other page, but at the same time your server is getting a request with some data on it. Your customer never gets to see the php page that gets loaded on your server, they have been redirected somewhere else. It is the 3rd party server which is loading the page and sending you data. So in reality the customer is not involved at this point. It is a conversation between you and the 3rd party server via HTTP.
User avatar
Chalks
Forum Contributor
Posts: 447
Joined: Thu Jul 12, 2007 7:55 am
Location: Indiana

Post by Chalks »

You'll probably need to retrieve the data sent by the 3rd party using $_GET.
check it out here and here.
spacebiscuit
Forum Contributor
Posts: 390
Joined: Mon Mar 07, 2005 3:20 pm

Post by spacebiscuit »

Ok that all makes sense, so the the php to capure the variables will never actually be invoked will it?

Or am I missing something here?

Rob.
Last edited by spacebiscuit on Fri Jul 20, 2007 9:56 am, edited 1 time in total.
Begby
Forum Regular
Posts: 575
Joined: Wed Dec 13, 2006 10:28 am

Post by Begby »

No, it will be invoked. Just not by the customer. It will be invoked when the 3rd party server requests the page from you.

To run a PHP script you don't have to have someone physically viewing it with a web browser. Using a number of methods in PHP it is possible to request pages from other servers thereby executing the code in those scripts, without every redirecting the user. For instance I can write a page on my server that loads a page from CNN, pulls off the headlines, then shows them to the person viewing the page on my server without redirecting them. Yet my request from my server to CNN caused server side scripting to run on the CNN server.

This is what the 3rd party processing people are doing. The customer checks out, then gets redirected. At that time the 3rd party server sends a page request to your server with data in it, which causes your PHP script to load and run the code in it.

Your customer will never see your PHP page. However the code in it still gets invoked.
Last edited by Begby on Fri Jul 20, 2007 9:58 am, edited 1 time in total.
spacebiscuit
Forum Contributor
Posts: 390
Joined: Mon Mar 07, 2005 3:20 pm

Post by spacebiscuit »

I was not aware this possible, so how do ou eecute a php script without manually calling the page in a browser?

Thanks,

Rob.
Begby
Forum Regular
Posts: 575
Joined: Wed Dec 13, 2006 10:28 am

Post by Begby »

robburne wrote:I was not aware this possible, so how do ou eecute a php script without manually calling the page in a browser?

Thanks,

Rob.
There are a lot of ways. One popular way is to use curl. You can also use file functions. Look those up in the php manual.

Another similar way of executing code remotely on another server is SOAP.
spacebiscuit
Forum Contributor
Posts: 390
Joined: Mon Mar 07, 2005 3:20 pm

Post by spacebiscuit »

Thanks for feedback guys, getting there slowly I think!

I've just read about the CURL extension in the PHP manual but I don't see how I can excute the PHP without calling the page.

Any pointers would be appreciated.

Thanks,

Rob.
Post Reply