Post by salmoon » Tue Nov 13, 2007 9:33 pm

I have to launch a client site by tomorrow but have just come across this issue with paypal :(

Basically i make an order on the site and pay with paypal. The payment goes out of my account, and into the shops paypal account. However, there's no record of the order in the admin page / customer account page, and no confirmation email has been sent (other than the notifications from paypal).

I'm using opencart version 0.7.6, hosting the site on hostnine.com. I've also password protected the public_html directory so it can't be accessed until i make it live. - would that be the cause of this?

Also, i notice that if you don't click the "return to merchant" on the paypal page once you've completed the payment, then the shopping basket is not cleared. Would this also stop the order record from showing up?

I hope someone can help me, i'm pretty desperate here.
Thanks in advance.
Last edited by salmoon on Tue Nov 13, 2007 9:46 pm, edited 1 time in total.

New member

Posts

Joined
Sun Oct 21, 2007 9:59 pm

Post by salmoon » Tue Nov 13, 2007 9:51 pm

Perhaps i should add that i'm also using 'Cheque' method on the site and that works fine. It's just paypal which is causing problems..

New member

Posts

Joined
Sun Oct 21, 2007 9:59 pm

Post by tchemis » Tue Nov 13, 2007 9:58 pm

Try to change the word "authorization" to "sale" in the following file
catalog/extension/payment/paypal.php

Look for
$ouput .= '' . "\n";
and change it to
$ouput .= '' . "\n";

Hope this works for you, it will make the payment instant instead of authorization.

Active Member

Posts

Joined
Tue Aug 21, 2007 9:23 am

Post by salmoon » Tue Nov 13, 2007 10:07 pm

Hey tchemis, thanks a lot for the quick response.

I've made this change, however now i'm getting an issue with paypal. When i make an order, and click to pay via paypal.. when it takes me to the paypal page it comes up with the error page saying "This invoice has already been paid. For more information, please contact the merchant." I've tried the order on a different product but makes no difference  ???

Any ideas??

New member

Posts

Joined
Sun Oct 21, 2007 9:59 pm

Post by salmoon » Tue Nov 13, 2007 10:58 pm

It's actually doing this for any item i try to order from the site....  :-[

New member

Posts

Joined
Sun Oct 21, 2007 9:59 pm

Post by salmoon » Wed Nov 14, 2007 12:29 am

OK i managed to fix this by changing "Block accidental payments" to 'no' my clients paypal profile page.

I changed the line in paypal.php file to 'sale' instead of 'authorize' and the payment went through, and this time there was no authorizing payment / capturing process.. the payment was instantly sent and received.

However i am still having the problem of the order records not showing up. It's as if no order was placed still. How did you get yours to work tchemis??

New member

Posts

Joined
Sun Oct 21, 2007 9:59 pm

Post by gary » Wed Nov 14, 2007 12:54 am

this worries me too. Why can't order be processed BEFORE going to paypal? Then order would be created with status "Pending", and after success message from paypal it could be changed to "Paid" (or something like that).

New member

Posts

Joined
Sun Nov 04, 2007 11:55 pm

Post by salmoon » Wed Nov 14, 2007 12:57 am

I read in another thread that people on godaddy's servers are having this problem because godaddy blocks certain ports?

Is it possible this the cause of the problem i'm having? If so, how do you find out what ports need to be opened?

New member

Posts

Joined
Sun Oct 21, 2007 9:59 pm

Post by salmoon » Wed Nov 14, 2007 1:11 am

Or is it that i have to set some sort of API thing up on the paypal side??

New member

Posts

Joined
Sun Oct 21, 2007 9:59 pm

Post by salmoon » Wed Nov 14, 2007 6:26 pm

If anyone can help please help. I need to launch this site today.  :-[

New member

Posts

Joined
Sun Oct 21, 2007 9:59 pm

Post by salmoon » Wed Nov 14, 2007 7:35 pm

I've just been told by my host (hostnine.com) that they disable "fsockopen" for security reasons. Is this the cause of my problem?

New member

Posts

Joined
Sun Oct 21, 2007 9:59 pm

Post by tmcguire » Wed Nov 14, 2007 11:09 pm

I think you may be on to something. I just added fsockopen to the list of disable_functions in my php.ini and restarted apache and it royally messed up the paypal process. Then I removed fsockopen from the php.ini file and restarted apache and tried to make another purchase and now I get an error from paypal "This invoice has already been paid. For more information, please contact the merchant."

So, my first reaction is to say that fsockopen being blocked is absolutley the root of the issue.

I'm not sure how to help you here. Maybe your host will let you over ride the use of fsockopen via a .htaccess file.

I'll have to login to paypal and decline that purchase to see if I can get rid of that invoice now

New member

Posts

Joined
Mon Nov 12, 2007 3:56 am
Location - Across from the Kitchen

Post by salmoon » Thu Nov 15, 2007 1:07 am

tmcguire, i managed to resolve this by doing the following:
salmoon wrote: OK i managed to fix this by changing "Block accidental payments" to 'no' my clients paypal profile page.

I changed the line in paypal.php file to 'sale' instead of 'authorize' and the payment went through, and this time there was no authorizing payment / capturing process.. the payment was instantly sent and received.

However i am still having the problem of the order records not showing up. It's as if no order was placed still. How did you get yours to work tchemis??



Going back to my original problem of orders not being recorded once payment has been compelted, it turns out my host (hostnine.com) does have fsockopen disabled and i don't think they will enable it for security reasons. Changing to another host is not an option as i need to launch this site today. Surely there has to be an alternative to using fsockopen as it seems quite a common thing for hosts to have this disabled. I've been researching it all day and keep coming across 'CURL' stuff but i dont understand it. Surely there's some code we can use instead of fsockopen??

I'm getting pretty desperate here and am running out of time. Can someone please help me out?

:-[

New member

Posts

Joined
Sun Oct 21, 2007 9:59 pm

Post by gary » Thu Nov 15, 2007 11:56 pm

salmoon wrote: ] i am still having the problem of the order records not showing up. It's as if no order was placed still. How did you get yours to work tchemis??
I am now in the same boat. Yesterday I moved the code to the server to see if everything works - and paypal does not callback.
I did not yet try to contact hosting service.

In order to work around the problem - I tried to change opencart code to submit order before going to paypal. This way - even if paypal does not callback - orders can be processed. Paypal sends email when payment is made - so callback is not that necessary. However - order has to processed somehow - and currently the paypal order processing trigger is paypal callback.

The thing is - that opecart paypal class does not even have a separate "process" function - all processing is done in callback function.
cod class has "process" function, but not callback function.
So as quick workaround - it is posible to just copy "process" function from cod class to paypal class - and order will be processed even if paypal does not call back.

One problem with this workaround is - that if paypal calls back - you have to make sure that order will not be processed again - so you can just comment out the line with order->process call in paypal callback function.
I was trying to be more fancy and write code to actually update order status to "processing" after callback. For this you need to create new function in order class which has to retrieve the order in question and update its order_status_id. Same with order_history. Also - in this case you have to be sure that you do not delete order_data record when processing order originally (the query near the end of order->process function) - because order object loads order info from that table - and it will be needed when updating order_status_id.
Needless to say - I did not test if my callback function actually updates order status - because paypal does not call back for me. So don't rely on this too much.

Another problem with this workaround that order is processed only after user returns to merchant from paypal. I did not yet find the way to do it just before going to paypal - for I don't want to rely on user coming back to merchant in order to know what did he order and in order for order stock to be subtracted.

So I am still looking for a way to trigger paypal order processing just before user gets redirected to paypal.
Last edited by gary on Fri Nov 16, 2007 2:10 am, edited 1 time in total.

New member

Posts

Joined
Sun Nov 04, 2007 11:55 pm

Post by salmoon » Fri Nov 16, 2007 5:31 am

Spent all day working on this with my host and they have now eradicated any possibliity of it being a server side issue. They enabled fsockopen and all the necessary ports. They even did a test to make sure the socket could connect and it works fine. So i think there's actually a problem with the paypal.php code and not my host.

Daniel can you assist us with this please?
Last edited by salmoon on Fri Nov 16, 2007 5:37 am, edited 1 time in total.

New member

Posts

Joined
Sun Oct 21, 2007 9:59 pm

Post by Daniel » Fri Nov 16, 2007 6:17 am

From previous posts you will see paypal does always not reply back straght away.

I don't know if PayPal has changed there system or not and now its not working. There is a differn't URL listed in the intergration documents for fsocket. When I was creating this module I could not get the one paypal recommended working so I found another url was posted in a forum.

How long did you wait to see if PayPal did the callback?

OpenCart®
Project Owner & Developer.


User avatar
Administrator

Posts

Joined
Fri Nov 03, 2006 6:57 pm

Post by salmoon » Fri Nov 16, 2007 6:23 am

daniel, thanks for replying.

i have done lots of test orders over the past 3 days and got not one callback. I have had a long search for these alternative URLS you mention but i can't find anything. Any chance you know where they are exactly?

Oh also, my host suggsted i tried taking the ssl:// out of the urls in the callback function.. but that still didn't work.

Thanks again.

New member

Posts

Joined
Sun Oct 21, 2007 9:59 pm

Post by gary » Fri Nov 16, 2007 6:49 am

I was finally able to get callback from paypal.

I changed only two things - disabled password protection on directory and enabled SSL option in the admin.

Also - I continued playing with separating order placing from paypal callback.

From confirmation page - opencart goes directly to paypal. After paypal processes payment - it sends callback.
In the original implemantation - callback is what triggers order processing. So - order is created, cart is cleared, success pages is displayed.

Now, if order processing and callback is separated (by copying cod process function to paypal) - then process function is trigerred after user clicks "return to merchant" from paypal.
While callback function is trigerred when paypal calls back.

So - if user delays returning to the page - process can be called after callback.

Logically - you would want to create order first with "pending" status and then in callback - update it to processing. If callback never comes - you can just update status to procesing manually through admin.
So we need a function that creates and inserts order, and another - small one - which just updates order status.

order->process function already exists. It creates order and clears it from order_data table. However, order_data stores all working knowledge about the order - so we need to keep it until callback (I think). Just have to comment out that part of the $order->process function - or make it conditional.

so only simple function somewhat like this is needed (to be trigerred from paypal callback):
function process_paid($order_status_id){
if ($this->data) {

//get order id 
$sql  = "select order_id from `order` where reference = '?'";
$order_id = $this->database->getRow($this->database->parse($sql, $this->reference));

$sql = "update `order` set order_status_id = '?' where order_id = '?'";
$this->database->query($this->database->parse($sql, $order_status_id, $order_id));

$sql = "update order_history set order_status_id = '?' where order_id = '?'";
$this->database->query($this->database->parse($sql, $order_status_id, $order_id));

//kill order_data
$sql = "delete from order_data where reference = '?'";
$this->database->query($this->database->parse($sql, $this->reference));
}
}
However - if callback comes - and user did not click "return" button - then callback tries to update order which does not exist yet.
Logical solution would be to create order just before going to paypal - with "pending" (or "not paid") status. Then you can be sure that it exists no matter if user clicks "return" or not. So callback can always find it.

If user never pays - you can just cancel the order manually. Its better than not getting order at all.

Then problem remains - to clear order_data if callback never comes. I guess it could be done when manually changing order status.
Last edited by gary on Fri Nov 16, 2007 6:53 am, edited 1 time in total.

New member

Posts

Joined
Sun Nov 04, 2007 11:55 pm

Post by salmoon » Fri Nov 16, 2007 9:56 am

Well Gary, i find all that a bit confusing. I tried what you suggested with taking password off the directory and using SSL but this didn't work for me.

I've tried so many things now. I've tried taking ssl:// from the fsockopen lines.. and just using www. I've tried using http:// because someone said if you're coming from a http:// you need to set the url in fsock to the same. Made no difference.

I've even added the lines:
mail('myemail@mail.com', "INVALID IPN", "$res\n $req");
mail('myemail@mail.com', "VALID IPN", "$res\n $req");


to try and get some email notification if the IPN was returning valid / invalid but i didn't even get those emails. So it seems paypal just isn't communicating back to the shopping cart at all..

New member

Posts

Joined
Sun Oct 21, 2007 9:59 pm

Post by salmoon » Fri Nov 16, 2007 6:35 pm

I have just stumbled across a few threads on paypaldeveloper.com forums where people are suddenly having IPN problems. Then i found this status page which reports paypal IPN has a delay: http://www.pdncommunity.com/blog?blog.id=mts_updates

Is this the cause of our problems? Or is there actually something wrong with the code in paypal payment module?

New member

Posts

Joined
Sun Oct 21, 2007 9:59 pm
Who is online

Users browsing this forum: No registered users and 8 guests