Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

PayPal issues


Chris Dunning

Recommended Posts

Hey there all. Just a quick post to let you know some things I've learned over the last few days.

 

For the benefit of those who find this via the forum search, if you have problems with PayPal orders not showing up in osCommerce admin even though you've received a payment, the problem is caused by customers not clicking the final "continue" button on the PayPal site. The best solution I know of is to use the PayPal IPN feature. I suggest using the latest version of Pablo's contribution for it.

 

Now then, on to my "tips and tricks."

 

1 - Don't call the PayPal tech support line if you're having issues. They're not helpful and will tell you to go use their code. I really can't blame them for not supporting third party scripts, but the individual I spoke with seemed very uninformed - he didn't tell me anything I hadn't already read on their site.

 

2 - If you're using a script that works perfectly on another site (especially if it's hosted on the same server) then the problem probably is not in your script.

 

3 - If you're using Pablo's contribution titled PayPal IPN .981 (or likely any other PayPal IPN system) then your IPNs can come back as "completed" but "invalid" for a variety of reasons. Here are two that I dealt with over the last couple of days.

- The name of your store has an apostrophe in it. You can get around that by adding a line like this to the top of checkout_paypalipn.php:

define ('STORE_NAME', 'Store Name');

- The PayPal account you're using is not validated with the address you're using

 

4 - PayPal has a developer zone where you can send and receive payments without actually sending and receiving payments - great for testing. I'm sure the folks at PayPal won't be happy with all of the payments I've sent and refunded over the last 48 hours. You can find it at developer.paypal.com.

 

5 - In a bit I'm going to upload an improved checkout_paypalipn.php to the contributiuons section that includes code for sending the cart contents to PayPal rather than your store name. I read in several places that the code has been posted on the forums, but I couldn't find that post so I wrote it myself. It didn't take much work.

 

Good luck and happy coding!

Chris Dunning

osCommerce, Contributions Moderator Team

 

Please do not send me PM! I do not read or answer these often. Use the email button instead!

 

I do NOT support contributions other than my own. Emails asking for support on other people's contributions will be ignored. Ask in the forum or contact the contribution author directly.

Link to comment
Share on other sites

One instance of the problem about receiving invalid PayPal ipn responses can be resolved (as suggested in papaldev.org) responding with an Error 500 header.

 

The above post link doesn't actually utilize PayPal's shopping cart upload feature.

"Any fool can know. The point is to understand." -- Albert Einstein

Link to comment
Share on other sites

The code I wrote was much more simple.

 

Here are some samples - I'm curious to know the opinions of people who know this system better than I. Here are some samples from checkout_paypalipn.php:

 

Near the top, where the other variables are defined:

//define the variable to pass to PayPal - name the products ordered
$paypalipn_products_ordered = '';

 

This is within the loop that adds all of the products from the cart into the order:

 
  $products_ordered .= $order->products[$i]['qty'] . ' x ' . $order->products[$i]['name'] . ' (' . $order->products[$i]['model'] . ') = ' . $currencies->display_price($order->products[$i]['final_price'], $order->products[$i]['tax'], $order->products[$i]['qty']) . $products_ordered_attributes . "\n";

//add the names of the products ordered to the variable set aside for that purpose
   $paypalipn_products_ordered .= $order->products[$i]['name'] . "\n";

 

Then at the end, we simply change the redirect address:

 

  tep_redirect("https://www.paypal.com/cgi-bin/webscr?cmd=_ext-enter&redirect_cmd=_xclick&business=".MODULE_PAYMENT_PAYPALIPN_ID."&item_name=".urlencode($paypalipn_products_ordered)."&item_number=".$insert_id."&currency_code=".$paypal_ipn_currency."&amount=".$paypal_ipn_order_amount."&shipping=".$paypal_ipn_shipping_amount."&tax=".$paypal_ipn_tax_amount."&first_name=".urlencode($order->customer['firstname'])."&last_name=".urlencode($order->customer['lastname'])."&address1=".urlencode($order->customer['street_address'])."&city=".urlencode($order->customer['city'])."&state=".urlencode($order->customer['state'])."&zip=".urlencode($order->customer['postcode'])."&email=".$order->customer['email_address']."&bn=oscommerce-osmosis-0.981&return=".tep_href_link(FILENAME_CHECKOUT_SUCCESS, '', 'SSL')."&cancel_return=".tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL')."&notify_url=".MODULE_PAYMENT_PAYPALIPN_NOTIFY_URL);

 

In the original file, item_name was set to STORE_NAME rather than $paypalipn_products_ordered.

 

While I was typing this, I realized that a product with an apostrophe in its name could cause the same problem as a store with an apostrophe in its name - it looks like the end of a string. So, perhaps I should include this at some point:

 

$paypalipn_products_ordered=str_replace("'", "", $paypalipn_products_ordered);

 

While this doesn't really pass the contents of the cart as a cart, it passes all the names of the products which is enough for my purposes.

Chris Dunning

osCommerce, Contributions Moderator Team

 

Please do not send me PM! I do not read or answer these often. Use the email button instead!

 

I do NOT support contributions other than my own. Emails asking for support on other people's contributions will be ignored. Ask in the forum or contact the contribution author directly.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...