[checkout paypal] how to automatically redirect client to his transaction status after payment ?

bchantre

Joined: 2005-11-16
Posts: 55
Posted: Tue, 2008-09-30 20:21

Hello,

I remarked that if someone use checkout paypal but doesn't click on the button to go back to the gallery after payment (transaction status), the order is not confirmed in checkout orders.

I had one case like that and had to manually search which temporary order it was, then edit client's details and change the order status to paid.

I think this problem can be avoided with an automatic forward to the transaction status from the gallery.

In paypal, there's a preference to automatically redirect the user after payment.

How can we use it to redirect to user to his transaction?

Thank you for your suggestions

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Tue, 2008-09-30 23:58
Quote:
change the order status to paid.

The order status doesn't depend on the user returning to the website - it's triggered by the automatic IPN from Paypal. So there's no need to change the order to paid, it's automatic.

Quote:
In paypal, there's a preference to automatically redirect the user after payment.

How can we use it

It's already used. Paypal redirects to the gallery site after 10 seconds. You can't stop the user closing his/her browser, however, which is why checkoutpaypal doesn't need the user to return to the website.

EDIT: just to clarify: the PAID status doesn't depend on the user returning to the website; the CONFIRMED status does, but CONFIRMED is not significant. What is significant is that the IPN reaches the website - which is independent of whether the user returns to the website. The IPN (and not the user's return to the website) fills in the customer details, and sets the status to PAID.

 
bchantre

Joined: 2005-11-16
Posts: 55
Posted: Sat, 2008-10-04 10:26

Ok. Thank you for the explanation.

It seems I have a problem with IPN. Can you tell me how preferences should be configured in Paypal to make the IPN work?

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Sat, 2008-10-04 10:54

HI Benoit,

in your Paypal IPN preferences set "Instant Payment Notification (IPN)" to "off" as described here
http://codex.gallery2.org/Gallery2:Modules:checkout#checkoutpaypal_-_the_.27paypal.27_payment_plugin

as far as I know, there are no other special settings required.

 
bchantre

Joined: 2005-11-16
Posts: 55
Posted: Sat, 2008-10-04 11:35

Hi Alec,

My preferences for IPN in Paypal are set to "off" and payment is not recorded into checkout orders.
I can see the payment in the Paypal account (I'm made these test in sandbox mode).

As soon as I click on the "return to gallery" button, the transaction is recorded into checkout orders, but It's marked "not paid".

That was working 2-3 weeks before, orders paid with Paypal were notified and marked as paid, but the automatic redirection wasn't working.

I know my host changed something on the server. It's maybe that. At my side, I didn't changed anything. Is there anything special to make IPN work at server side?

Do you have an idea?

Here's what I have in system info:
Gallery version = 2.2.5 core 1.2.0.7
PHP version = 5.2.4-2ubuntu5.3 apache2handler
Webserver = Apache
Database = mysqli 5.0.51a-3ubuntu5.1, lock.system=flock
Toolkits = Gd
Acceleration = none, none
Operating system = Linux plesk.unity-web.ch 2.6.18.8-xenU #3 SMP Mon Aug 18 13:39:03 CEST 2008 i686
Default theme = galerie
gettext = enabled
Locale = en_GB
Browser = Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; fr; rv:1.9.0.3) Gecko/2008092414 Firefox/3.0.3
Rows in GalleryAccessMap table = 17
Rows in GalleryAccessSubscriberMap table = 156
Rows in GalleryUser table = 2
Rows in GalleryItem table = 155
Rows in GalleryAlbumItem table = 8
Rows in GalleryCacheMap table = 0

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Sat, 2008-10-04 13:14

Hi Benoit,

IPNs are made to the following url:

http://<your-website>/.../main.php?g2_view=checkoutpaypal.IPN

if you visit that url directly yourself, you should just see the word 'Invalid' on screen. (That's good.) If you see 'Unable to Connect' that means your webserver can't contact Paypal directly to verify the IPN.

Also check your webserver log for accesses to this url.

 
bchantre

Joined: 2005-11-16
Posts: 55
Posted: Sat, 2008-10-04 14:20

Hi Alec,

Unfortunately, I have 'Unable to Connect'.

Here's what I have in the access log ; I don't know what to do with that info

83.76.220.142 - - [04/Oct/2008:16:17:31 +0200] "GET /sites/galerie/?g2_view=checkoutpaypal.IPN HTTP/1.1" 200 242 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_5; fr-fr) AppleWebKit/525.18 (KHTML, like Gecko) Version/3.1.2 Safari/525.20.1"
 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Sat, 2008-10-04 14:46
Quote:
Here's what I have in the access log ; I don't know what to do with that info

Actually you should be looking in the log for the equivalent line but triggered by an IPN from paypal (i.e. in the seconds following your payment of a sandbox order) to verify that the IPN call was made to your website. Although it's good to verify that your own test of the IPN system also generated a log entry.

Quote:
Unfortunately, I have 'Unable to Connect'.

That's a bad sign. Assuming you have the latest version of checkoutpaypal, put this line in the file modules/checkoutpaypal/IPN.inc at line 74:

        list ($responseBody, $responseStatus, $responseHeaders) = galleryCoreApi::postToWebPage($ppurl, $_POST);
        /* insert this line...*/
	echo "$responseStatus<br>$responseBody<br>";
	if (preg_match("/^HTTP\/\d+\.\d+\s2\d{2}/", $responseStatus)) {

Then go back to the ...g2_view=checkoutpaypal.IPN page and post what it says on the screen.

 
bchantre

Joined: 2005-11-16
Posts: 55
Posted: Sat, 2008-10-04 15:23

Here's what I have in the page source on the screen. It didn't changed anything, except a <br> tag

<br><br>Unable to Connect

I didn't found anything from paypal in the access log, even in the error log. Every log to ...?g2_view=checkoutpaypal.IPN is from my IP address

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Sat, 2008-10-04 16:42

HI Benoit,

it's tricky to know what to suggest then, sorry.

 
bchantre

Joined: 2005-11-16
Posts: 55
Posted: Sun, 2008-10-05 16:02

Hi Alec,

Thank you again for your help.

I tried to uninstall and reinstall the module, but that doesn't change anything.

I'll have a look at that problem with my host and keep you informed if we found a solution.

 
bchantre

Joined: 2005-11-16
Posts: 55
Posted: Mon, 2008-10-06 07:53

Hi Alec,

My host has disabled some PHP functions ; that's why its not working normally...

Do you know which PHP function is used by IPN ?

Thank you again

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Mon, 2008-10-06 08:07

Hi Benoit,

The most obvious candidate is the fsockopen(...) function which is used (not directly, but by the WebHelperSimple.class) to open a connection to Paypal to verify the IPN contents. If it *is* that, then you can't access Paypal for verification and checkoutpaypal won't work.

 
venturait

Joined: 2009-02-22
Posts: 1
Posted: Sun, 2009-02-22 03:34

how do you make your paypal have the timer so it goes back to your site after 10 seconds?

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Sun, 2009-02-22 06:38
Quote:
how do you make your paypal have the timer so it goes back to your site after 10 seconds?

It already does.