Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

My boat is sinking...


jhande

Recommended Posts

My boat is sinking fast and I'm not sure if I should jump ship or start bailing. <_<

 

Awhile back everyone pointed me towards the need to upgrade to the PayPal IPN v2.3.3 contrib (dated 16 Nov 2007).

No problem, I worked through that just like all the other contributions I've added, trial-n-error sometimes until I got it fixed.

 

I've added a few recent contribs such as - Ultimate HTML Emails and just found out that the PayPal IPN might not utilize it.

 

I finally sat down and figured out (was rather easy duh) how to test my checkout in PayPal's Sandbox. AHHHH.... :o

Something is definately broken! So I tried to search for a fix, not having much luck yet.

 

Here's what's happening -

I get to the PayPal checkout page just fine. I click on the pay button and this -

This invoice has already been paid. For more information, please contact the merchant. Return to Merchant

So I read through the IPN instructions again. Seems I should only be getting that error if I tried ordering more than once or if I have multiple shops using the same PayPal account. Neither apply!

 

So I head to my admin panel, now I can't even enter the Customers > Orders page. I receive this error -

Fatal error: Call to undefined function tep_hide_session_id() in /home/handesho/public_html/catalog/admin/orders.php on line 350

Order ID: [ box ]

 

More searching and I uncover this contribution - PayPal Website Payments Standard v1.0 by Harold Ponce de Leon 11 Jan 2008.

 

Whats more the PayPal IPN needs register_global set to on, I thought that was a no - no?

 

Here's my situation -

  • I'm on a shared server with a shared SSL
  • PHP 5.2.6 and MySQL 5.0.45
  • Local USPS shipping only
  • PayPal Website Payments Standard only method

What the heck am I to do now??

Can the errors be easily fixed from the PayPal IPN and how?

Should I just switch to the PayPal Website Payments Standard v1.0 contrib?

Or any other suggestions before I'm swimming with the fishies?

 

:wacko:

 

- :: Jim :: -

- My Toolbox ~ Adobe Web Bundle, XAMPP & WinMerge | Install ~ osC v2.3.3.4 -

Link to comment
Share on other sites

So I head to my admin panel, now I can't even enter the Customers > Orders page. I receive this error -

Fatal error: Call to undefined function tep_hide_session_id() in /home/handesho/public_html/catalog/admin/orders.php on line 350

Order ID: [ box ]

 

Well I found a fix for my admin error - here.

 

PayPals Sandbox still gives me the message that the invoice has already been paid. <_<

 

Is it normal when using the Sandbox that your shopping cart doesn't empty? :huh:

- :: Jim :: -

- My Toolbox ~ Adobe Web Bundle, XAMPP & WinMerge | Install ~ osC v2.3.3.4 -

Link to comment
Share on other sites

When I installed paypal IPN on the site I manage, it said in the install instructions that the "This invoice has already been paid" would happen, but there were also instructions on how to fix it. And it worked like a charm.

 

But I'll be danged if I remember which version I installed.

:blush:

 

And who knows if that "fix" applies to any version?

:unsure:

If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

 

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -

 

"Headers already sent" - The definitive help

 

"Cannot redeclare ..." - How to find/fix it

 

SSL Implementation Help

 

Like this post? "Like" it again over there >

Link to comment
Share on other sites

Gee...

 

I just found some files dated around the time I installed it.

 

I think it's V2.2

 

And here was the "fix":

 

"This invoice has already been paid" PayPal error message

 

Background:

The PayPal IPN sends a parameter "invoice" to PayPal. This parameter is equal to the order ID (1,2,3,4 etc). However, PayPal requires the invoice parameter to be unique so if you have already sent an order ID with the same number, then it will be refused. Sending the same order ID can e.g. happen if you have two osCom shops linked to one PayPal account - the PayPal account cannot distinguish between different shops / domains / databases, it just looks at the number and says "hey, that's already been paid!"

 

There are two possible solutions:

 

 

******************************************

 

1. Create a unique invoice ID for each shop

this solution keeps the invoice ID check functionality but allows you to create unique IDs

 

Description:

If you have multiple shops linked to your PayPal account, then you get around this problem by adding a unique letter to your invoice parameter. As the invoice parameter can be any string (max length 127), it doesn't matter that it's not numeric. If you run several shops all with one PayPal account, then choose a different letter for each shop.

 

Note: this solution is for coders who have a reasonable knowledge of PHP. To alter your invoice parameter:

 

In /includes/modules/payment/paypal_ipn.php find this code:

$parameters['invoice'] = substr($cart_PayPal_IPN_ID, strpos($cart_PayPal_IPN_ID, '-')+1);

 

and change to this:

$parameters['invoice'] = 'K' . substr($cart_PayPal_IPN_ID, strpos($cart_PayPal_IPN_ID, '-')+1);

 

choose any letter but keep it to ONE letter only!

 

 

 

In /ext/modules/payment/paypal/ipn.php just after

 

curl_close($ch);

}

 

add

 

$invoice_id = substr($_POST['invoice'],1);

 

and then replace all occurrences of

 

$_POST['invoice']

 

with

 

$invoice_id

 

(use a search / replace function if available)

 

 

The above code will add the letter to the order ID when sending to PayPal and then strip it back out again with the substr command. It's vital that you replace all occurences of the variable in ipn.php as otherwise your database update won't happen or be wrong.

 

I've tested it on my online shop and it's all working in Sandbox - I think it's a cleaner solution than just changing the order IDs to something higher as previously suggested. And it's also sustainable over time (think 10 years down the road when you have thousands of orders), plus even with just one letter you can run up to 26 different shops on one PayPal account.

 

******************************************

 

2. Disable the inoice ID checking

with this solution PayPal will not check for duplicate order IDs - a potential problem if customers e.g. hit a button twice. I'd recommend to try the first solution first, and only if that fails, try this second one:

 

In your PayPal account, go to "Profile" - > "Payment Receiving Preferences". In there you will have the option:

Block accidental payments:

You may prevent accidental payments by blocking duplicate invoice IDs

Yes, block multiple payments per invoice ID

No, allow multiple payments per invoice ID

 

Select "No".

 

PayPal will now allow all orders to be paid, even if the order ID has already been paid previously. A potential problem is if customers pay an invoice twice by mistake (e.g. refreshing browser, hitting button twice etc.).

If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

 

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -

 

"Headers already sent" - The definitive help

 

"Cannot redeclare ..." - How to find/fix it

 

SSL Implementation Help

 

Like this post? "Like" it again over there >

Link to comment
Share on other sites

very funny but the problem is not in PayPal contribution, but in someone like who can't install the contribution properly due to can't(or don't want) to read the installation manual. Similar sort of problems with computer my neighbour having every time he does something to computer & saying I simply clicked OK without reading what!

Please read this line: Do you want to find all the answers to your questions? click here. As for contribution database it's located here!

8 people out of 10 don't bother to read installation manuals. I can recommend: if you can't read the installation manual, don't bother to install any contribution yourself.

Before installing contribution or editing/updating/deleting any files, do the full backup, it will save to you & everyone here on the forum time to fix your issues.

Any issues with oscommerce, I am here to help you.

Link to comment
Share on other sites

It does appear that the same (or very similar) file is supplied with that version.

:blush:

If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

 

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -

 

"Headers already sent" - The definitive help

 

"Cannot redeclare ..." - How to find/fix it

 

SSL Implementation Help

 

Like this post? "Like" it again over there >

Link to comment
Share on other sites

Thanks Jim for the reply.

 

I DID see that in the contributions directions, but I thought it pertained to ONLY multiple shops as it stated. And that I was receiving the error due to something else since I only have ONE shop.

 

I guess that was wrong, go figure!

 

I'll give it a try. ;)

 

Just seems kind of strange that the contrib was designed to work with one osC shop but produces such an error when used. :blink:

- :: Jim :: -

- My Toolbox ~ Adobe Web Bundle, XAMPP & WinMerge | Install ~ osC v2.3.3.4 -

Link to comment
Share on other sites

If it helps any, I did this fix:

 

1. Create a unique invoice ID for each shop

And I wouldn't be hard on myself.

 

The only people I know of that make absolutely no mistakes are the ones who can't do anything at all.

If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

 

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -

 

"Headers already sent" - The definitive help

 

"Cannot redeclare ..." - How to find/fix it

 

SSL Implementation Help

 

Like this post? "Like" it again over there >

Link to comment
Share on other sites

Thanks again Jim.

 

I was a little mislead with the way the contribs directions explained why someone might get that error. :blush:

I thought for sure with only having my one shop that I was getting the error caused by something else. You know, like I might of messed something up or didn't have my settings correct...

 

Any thoughts as to why the shopping cart retains the products after processing through Sandbox?

- :: Jim :: -

- My Toolbox ~ Adobe Web Bundle, XAMPP & WinMerge | Install ~ osC v2.3.3.4 -

Link to comment
Share on other sites

When I installed it the only problems I remember having were with creating the accounts on the Sandbox server.

:lol:

 

I don't remember having problems with the cart, but back then (a year ago) I doubt that I even realized the cart was supposed to empty after paying.

:blush:

 

Some days I have to look at my drivers license to even remember who I am...

:blink:

 

Looking at the PHP code, I believe the code responsible for emptying the cart would be located in the top of checkout_process.php

 

  $cart->reset(true);

Beyond that I'm as useless as the mammary glands on a boar...

:blush:

If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

 

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -

 

"Headers already sent" - The definitive help

 

"Cannot redeclare ..." - How to find/fix it

 

SSL Implementation Help

 

Like this post? "Like" it again over there >

Link to comment
Share on other sites

Don't feel so bad Jim. ;)

 

Between the residual effects from my head injury and getting up in age, even looking at my drivers license I don't have a clue! :blink:

 

Oh oh... me thinks you helped spot the problem.

In my checkout_process.php file the code [ $cart->reset(true); ] is line 290.

 

According to the IPN directions it doesn't use any code after line 50 -

"checkout_process.php

paypal_ipn.php bypases checkout_process by loading a redirect into the before_process. No code in checkout_process.php after the before_process() is used (around line 50)."

 

Buggers!!! Looks like I have more research to do. :(

 

Speaking of boars...

I had one chase me and a couple of friends through the woods when I was in Georgia... Oop's that's a long story. :P

- :: Jim :: -

- My Toolbox ~ Adobe Web Bundle, XAMPP & WinMerge | Install ~ osC v2.3.3.4 -

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...