Forums / Bug Reports / [DONE 1.3.5] PayPal IPN and eCheck clearing

[DONE 1.3.5] PayPal IPN and eCheck clearing

Locked

Views: 3,607

Results 1 to 9 of 9
This thread is locked. New replies are disabled.
28 Jun 2006, 10:11 PM
#1
jrafuse avatar

jrafuse

New Zenner

Join Date:
Apr 2004
Posts:
31
Plugin Contributions:
0

[DONE 1.3.5] PayPal IPN and eCheck clearing

I just noticed something this morning with PayPal IPN and cleared eChecks on ZenCart v1.3.0.1.

Now when PayPal send the "cleared" message back to me for an eCheck, Zencart is actually re-setting the order from "Pending" to "Processing". This is GREAT, but there is one teeny-tiny problem. Zencart is NOT updating the order, and since most eChecks take at least 4 days to clear, this means that with the defualts of 5 days and 5 tries for the download of items at the store, that the items are being released to the customer as "Expired". Is there an easy fix to get Zencart to update the order so that it becomes current as well as released?

John

29 Jun 2006, 2:41 AM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: [DONE 1.3.5] PayPal IPN and eCheck clearing

I haven't done any testing on this, so I apologize if it doesn't work quite right.

However, if you can give it a try and report back whether it works as desired, it would be greatly appreciated!

/ipn_main_handler.php
starting at line 195, you have:```php
zen_db_perform(TABLE_ORDERS_STATUS_HISTORY, $sql_data_array);
}
break;
default:
ipn_debug_email('IPN WARNING:Could not establish txn type ' . $txn_type . ' postdata=' . $postdata);
}
?>


change that to this:```php
    zen_db_perform(TABLE_ORDERS_STATUS_HISTORY, $sql_data_array);

    if ($txn_type=='echeck-cleared') {
      $check_status = $db->Execute("select orders_status,
                                    date_purchased from " . TABLE_ORDERS . "
                                    where orders_id = '" . $ipn_id->fields['zen_order_id'] . "'");
      $zc_max_days = date_diff($check_status->fields['date_purchased'], date('Y-m-d H:i:s', time())) + DOWNLOAD_MAX_DAYS;
      $update_downloads_query = "update " . TABLE_ORDERS_PRODUCTS_DOWNLOAD . " set download_maxdays='" . $zc_max_days . "', download_count='" . DOWNLOAD_MAX_COUNT . "' where orders_id='" . (int)$ipn_id->fields['zen_order_id'] . "'";
      $db->Execute($update_downloads_query);
    }
  }
  break;
  default:
  ipn_debug_email('IPN WARNING:Could not establish txn type ' . $txn_type . ' postdata=' . $postdata);
}
?>

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

29 Jun 2006, 8:31 AM
#3
jrafuse avatar

jrafuse

New Zenner

Join Date:
Apr 2004
Posts:
31
Plugin Contributions:
0

Re: [DONE 1.3.5] PayPal IPN and eCheck clearing

DrByte:

I haven't done any testing on this, so I apologize if it doesn't work quite right.

However, if you can give it a try and report back whether it works as desired, it would be greatly appreciated!

DrByte,

     I have changed the code, and will let you know if it breaks something, and also if it works on my next eCheck! I think I can even do it from my own account, so I'll let you know in a few days.

John

5 Jul 2006, 3:39 PM
#4
jrafuse avatar

jrafuse

New Zenner

Join Date:
Apr 2004
Posts:
31
Plugin Contributions:
0

Re: [DONE 1.3.5] PayPal IPN and eCheck clearing

jrafuse:

DrByte,

     I have changed the code, and will let you know if it breaks something, and also if it works on my next eCheck! I think I can even do it from my own account, so I'll let you know in a few days.

John

This code didn't fix it :( Just got two echecks cleared and had to manually reset the order date again ...

John

12 Jul 2006, 9:00 AM
#5
jrafuse avatar

jrafuse

New Zenner

Join Date:
Apr 2004
Posts:
31
Plugin Contributions:
0

Re: [DONE 1.3.5] PayPal IPN and eCheck clearing

DrByte? ... Anyone???

Anyone have any ideas on how to solve this issue? I keep good records, so it is not a critical issue for me, as I can always refer to the email to get the order#, track it down for the customer, and reset it for them, but now that the IPN is actually activating eCheck cleared orders, it would be really great if it completed the update by adding the appropriate number of days to the order when it activates the eCheck order.

John

13 Jul 2006, 2:01 AM
#6
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: [DONE 1.3.5] PayPal IPN and eCheck clearing

hmmmm ... you'll need to add this function to your /includes/functions/functions_general.php

////
// compute the days between two dates
  function date_diff($date1, $date2) {
  //$date1  today, or any other day
  //$date2  date to check against

    $d1 = explode("-", $date1);
    $y1 = $d1[0];
    $m1 = $d1[1];
    $d1 = $d1[2];

    $d2 = explode("-", $date2);
    $y2 = $d2[0];
    $m2 = $d2[1];
    $d2 = $d2[2];

    $date1_set = mktime(0,0,0, $m1, $d1, $y1);
    $date2_set = mktime(0,0,0, $m2, $d2, $y2);

    return(round(($date2_set-$date1_set)/(60*60*24)));
  }

(This function is in the admin, but not the catalog area, but the ipn process doesn't use the admin functions. ... thus, the code was dying when it attempted to do the reset.)

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

13 Jul 2006, 5:53 AM
#7
jrafuse avatar

jrafuse

New Zenner

Join Date:
Apr 2004
Posts:
31
Plugin Contributions:
0

Re: [DONE 1.3.5] PayPal IPN and eCheck clearing

DrByte,

     I have added the code, and will let you know as soon as another one comes in.

John

26 Jul 2006, 6:13 PM
#8
jrafuse avatar

jrafuse

New Zenner

Join Date:
Apr 2004
Posts:
31
Plugin Contributions:
0

Re: [DONE 1.3.5] PayPal IPN and eCheck clearing

DrByte,

      Great News!!!! The new code works like a charm. Just had two PayPal eChecks clear, and both updated the date properly. All I had to do was send an announcement to the customer that their order was ready to go.

With this and the Who's Online ... you're two for two :thumbsup: (couldn't resist. Obviously the record is better than THAT!)

John
A Loyal Zenner

26 Jul 2006, 7:14 PM
#9
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: [DONE 1.3.5] PayPal IPN and eCheck clearing

Thanks for the update John. These fixes will be in the next release.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.