PDA

View Full Version : Non critical bug somewhere along the Paypal way...?



MindTwist
10-09-2007, 05:37 PM
Here is a strange one in case someone wants to give it a try and check it out on a plain OSCMAX installation.

When I am looking at an order (edit) from the admin section, and the field "payment_method" for that order on the DB is set exactly to "Paypal" (not case sensitive), I get an error ... ?¿?

I hadn't found out before because until now I the info that was being stored there was "PayPal (Recargo de 0.35E + 4%)" , which is the full name of the payment method customers are seeing. But I changed it to just Paypal (so it would look nicer on invoices), and this is the error I get:

http://img233.imageshack.us/img233/1034/10102007032643qh8.th.jpg (http://img233.imageshack.us/my.php?image=10102007032643qh8.jpg)

http://img233.imageshack.us/img233/8710/10102007032724oh1.th.jpg (http://img233.imageshack.us/my.php?image=10102007032724oh1.jpg)

So, the first one has payment method "PayPal (Recargo de 0.35E + 4%)" and can be seen ok, the second one has payment method "Paypal" and breaks.

There is a table "paypal_ipn" on my database, but it is empty. Also, I checked my /admin/includes/database.php , and there was no reference there to TABLE_PAYPAL_IPN , so I added the following line:

define('TABLE_PAYPAL_IPN', 'paypal_ipn');

Reload, and now the error is:

http://img468.imageshack.us/img468/4174/10102007033356dz6.th.jpg (http://img468.imageshack.us/my.php?image=10102007033356dz6.jpg)

So what is TABLE_PAYPAL_IPN_TXN_TYPE ...???
I am quite lost here. I am not sure I have paypal_ipn working right now, since my table paypal_ipn contains no information about payments received. But, orders done with paypal_ipn are stored ok, I get the payments done, and they do seem to be working ok. So I might be missing some of the features on this module maybe...?

Since my problem was just a cosmetic one, now the Paypal payments are stored with the "payment_method" PaypaI (yeah, that is a capital i) so this problem is gone for me.

:confused:

michael_s
10-09-2007, 06:40 PM
I think this one is easy... Probably missing the spanish language file for paypal ipn.

Just copy it from the admin panel's english directory to the spanish directory and then translate the text to spanish.

MindTwist
10-10-2007, 12:28 AM
Hi michael,

You are kinda right and I failed mentioning that part when I did the post, the first time I did the change "PayPal (Recargo de 0.35E + 4%)" to "Paypal", the error it gave me was about a missing language file.

I copied the language file from /english to /spanish , and it changed to the one you can see on the screenshot here.

I searched checked order.php to see where the error might be coming from, and I see there 3 appearences of something like

strtolower($order->info['payment_method']) == 'paypal'

which I changed to

strtolower($order->info['payment_method']) == 'poypal'

to see if it would stop failing, but it didn't. It was kinda late and I really didn't feel like checking any more...

What I do not quite understand either is why the payment method is being checked like that to see if it is paypal, since it is quite possible that people will change the text to someone else.

In fact, the default name for the OSCMAX paypal_ipn module after install was "PayPal (Credit Card / Debit)" , so whatever code is supposed to be running there that is failing me wouldn't work with the default name, and it would work with the normal paypal.php module.

michael_s
10-10-2007, 07:02 AM
You shouldn't be changing the database. I think just changing the language define in the language file will do the trick.

I think I am not fully understanding what you are doing. What code in what file have you changed to cause this in the first place?

MindTwist
10-10-2007, 07:26 AM
I will try to do better this time :)

-----
From what I can tell, I have changed no code.

What I did change was the Paypal_ipn name, so instead of being the default text "PayPal (Credit Card / Debit)" it is just "Paypal".

On /includes/languages/whatever/modules/payment/paypal_ipn.php replace:


define('MODULE_PAYMENT_PAYPAL_IPN_TEXT_TITLE', 'PayPal (Credit Card / Debit)');
define('MODULE_PAYMENT_PAYPAL_IPN_TEXT_DESCRIPTION ', 'PayPal IPN');With:


define('MODULE_PAYMENT_PAYPAL_IPN_TEXT_TITLE', 'Paypal');
define('MODULE_PAYMENT_PAYPAL_IPN_TEXT_DESCRIPTION ', 'PayPal');Now when you make an order and pay with this payment module, the field "payment_method" on the order (stored on the table "orders" on the database) will contain just that text, "Paypal".

(NOTE: I also have a field "paypal_ipn_id" on every order, I have no clue what this fields are for. I also have an empty table on my database "paypal_ipn", I have no clue what this table is for)

The fact that the field "payment_method" is exactly "Paypal" (not case sensitive, "PaYpAl" would be the same) triggers something on /admin/orders.php that is giving me the error messages I was showing. You can do a text search for:


== 'paypal'on orders.php and will see 3 ocurrences. One of them is:


if (strtolower($order->info['payment_method']) == 'paypal') {
include 'paypal_ipn_order.php';
} else {which loads paypal_ipn_order.php , and I really didn't follow any more where the error might be coming from.

So, I guess I do have a few questions:

- /admin/orders.php is using a text comparison on the field "payment_method" to know if an order has been paid with Paypal. I doubt that is a good idea, since many people will change that text to something else, and in fact, by default it already comes as something else.

- I have no clue if my paypal_ipn payment module should be doing "more". I have no information on my "paypal_ipn" database table. I have no "paypal_ipn_id" on my orders, no matter how they are paid for.

- I am using paypal.com, but in spanish. I have no clue if the APIs or whatever they iffer are different. For one, we do not even have verified addresses outside the US.


I have the idea that maybe paypal_ipn is not fully working for me. That maybe when it is used as a payment method, I should be seeing more info on my DB, I should be seeing stored the information passed by Paypal, or whatever. Which in turn might make the orders.php fail, because there's no data in there.

But anyway, the fact of doing a text comparison on orders.php against "paypal" for knowing the payment method, does seem to be a bad approach to me.

michael_s
10-10-2007, 01:39 PM
I just tested this on my dev shop, and I was able to reproduce it. Seems to be an issue with the classes/paypal_ipn.php file not getting the paypal constants.

MindTwist
10-11-2007, 02:31 AM
Great, I'm glad my hint wasn't a time waster and there is something to be checked out... :)

What I found strange was that the method used on /admin/orders.php for knowing if a purchase has been paid with paypal_ipn was to compare the 'payment_method' against the text 'paypal', since by default the name has already been changed to something else.

michael_s
10-11-2007, 11:10 AM
No, I had never seen it before, so definitely worth the effort to report. It is one of those oddities that would never come up in normal usage, since most users leave the text as default for all the payment modules.

MindTwist
10-11-2007, 11:22 AM
I'm glad to help :D

Feel free to add it yourself on the bugtracker, I wouldn't even be able to know what summary to put on the issue.