ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Simple Commerce Module - Ping back to Paypal as Invalid

July 24, 2012 2:15pm

Subscribe [2]
  • #1 / Jul 24, 2012 2:15pm

    MasonH

    15 posts

    I have a single purchase system setup and working most of the time. However, for some users, the simple commerce module fails to record their purchase. It only happens to specific users, and if it happens to a specific user once, it happens to that same user every time.

    I’ve been keeping track of which IPNs fail and which ones don’t, and there doesn’t seem to be any consistencies. I’ve had it work for address_status confirmed and unconfirmed, for payer_status verified and unverified.

    I went into the Simple Commerce System to add a few checkpoints and send me some information via email to see if I could debug, and I found that these transactions are failing when ExpressionEngine tries to Ping Paypal back for a confirmation. The $result of $this->curl_process($url) is ‘INVALID’.

    Any idea why this would be invalid? I’m tempted to just remove this Ping back section all together so that these transactions go through smoothly and I no longer have to manually add people’s purchases.

  • #2 / Jul 24, 2012 2:44pm

    MasonH

    15 posts

    Okay, this is definitely interesting. The transactions were being pinged as Invalid because of the way stripslashes() now works in PHP. My customers who were experiencing issues had slashes in their address, and when the Simple Commerce Module was comparing its information, it was showing the address slightly differently and failing.

    I took this around line 587 of mod.simple_commerce.php:

    $postdata .= "&$key=".urlencode(stripslashes(str_replace("\n", "\r\n", $value)));

    and replaced it with this:

    $postdata .= "&$key=".get_magic_quotes_runtime() ? urlencode(stripslashes(str_replace("\n", "\r\n", $value))) : urlencode(str_replace("\n", "\r\n", $value));

    This checks to see if get_magic_quotes is on in your configuration of PHP and if it is, uses stripslashes(), otherwise doesn’t.

    Hope this helps someone else. It has taken me about a year to completely resolve this strange bug.

  • #3 / Jul 25, 2012 3:10pm

    Kyle Cotter

    730 posts

    Hey MasonH,

    Glad to see you were able to figure your issue out. Can I suggest you add your findings to the bug tracker so we can get this fixed up in a future version of ExpressionEngine?

    Thanks, if you have any more issues, feel free to open a new thread!

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases