Does anyone have any thoughts on where and what change this may need?
Does anyone have any thoughts on where and what change this may need?
Came across a function in a paypal module that appears to either updte the value or at least capture the information to update it. By a little manipulation of the data that is returned by. It at the right place and may be able to solve this issue. The file is located in the includes/modules/payment/paypal directory. It has the wod update in the function. I didn't yet have a chance to find where the function is called to be able to identify the status returned by paypal to assist in the correction.
ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...
I sure appreciate your efforts... But - I have no idea how to find this stuff. I decided to put the files from vs. 1.3.8a and the new ones from 1.5.1 into DiffMerge to see what had been changed since the update. Alas. There are way too many changes for me to find and risk "fixing" this myself.
Can you tell me why the new version does this now when it didn't do it in prior versions?
My guess is that because it became more ZC centric and there probably were other security updates to apply. Afterall ZC 1.3.8 had significant security issues to begin with, let alone perhaps something with PayPal. I'll see if I can take a gander again to find what I had found before and possibly identify the work around for which you are looking.
By ZC centric I mean that it was probably considered that the issue should be handleable from the store side. The fact that PayPal may have also made changes that did not get corrected/updated in ZC well, as long as it functions in a way is minimum requirements. If through this or others work a functional improvement is identified, then perhaps it would make it into future versions, but it must be universal enough and not conflict with other design considerations. Otherwise it may be something for a specific cart only (ie. custom modification)...
ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...
Not sure this is the location where this goes, but seemed like it. I haven't gone and done any test transactions, but looked like the right place.
So, if you open the ipn_main_handler.php located in the store's main directory go find (in ZC 1.5.1) line 454 that in this area looks like:
and insert the following code the line below the one that ends with "-cleared') {":Code:if ((int)$new_status == 0) $new_status = 1; if (in_array($_POST['payment_status'], array('Refunded', 'Reversed', 'Denied', 'Failed')) || substr($txn_type,0,8) == 'cleared-' || $txn_type=='echeck-cleared' || $txn_type == 'express-checkout-cleared') {
Then if you test one transaction like you normally process or hope to prevent from occurring (from within PayPal whatever group transaction/processing that identified this situation) where the status of the order has already been bumped up to something past processing before the above test. (It may seem a little complicated for the setup, but...)Code://mc12345678 Start Override new_status $sql = ("select orders_status from " . TABLE_ORDERS . " where orders_id = '" . (int)$ordersID . "'"); $old_status = $db->Execute($sql); if ($new_status < $old_status->fields['orders_status']) { $new_status = $old_status->fields['orders_status']; }//mc12345678 End Override new_status
What the above is expected to do is, allow normal processing of an authorized payment, except if the calculated new order status (which if defined in the database is that value or a value of 2 I think is the default status) is less than the current status then basically the status is not updated. This is based on the principle that increasing order status is approaching a "final" desired state. There is no specific hard rule on that aspect, other than if you review the maximum and minimum values in some areas such as downloads and in the specific max/min area.
Let me know if that works for you. The assumption was that the paypal function ipn_update_orders_status_and_history is also called to make this happen in the setup that you have.. The code may need to go elsewhere; however, I'm not in a position to test those conditions.
Let me further state, test this at your own risk. I do not claim responsibility for any negative results. Ideally this could be done in a test environment rather than real payments...
ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...
Wondering...
Success?
ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...
Okay, since that worked, it would be good to add a little something, because this section of code applies to more than just the action you need it for. I haven't looked over the code more to see howmuch work it would be to separate this section out and to maintain the functionality, but I'm thinking that the code should look like this to ensure that all addressed functionality in this section will be maintained and that only the clearing process that has been a problem would stay changed as desired. So, the code should now look like this:
So, if you open the ipn_main_handler.php located in the store's main directory go find (in ZC 1.5.1) line 454 that in this area looks like:
and insert the following code the line below the one that ends with "-cleared') {":Code:if ((int)$new_status == 0) $new_status = 1; if (in_array($_POST['payment_status'], array('Refunded', 'Reversed', 'Denied', 'Failed')) || substr($txn_type,0,8) == 'cleared-' || $txn_type=='echeck-cleared' || $txn_type == 'express-checkout-cleared') {
This way items that fit the status of any of the following:'Refunded', 'Reversed', 'Denied', or 'Failed' will be handled/downgraded as applicable. The additional code as compared to the previous is provided in red.Code://mc12345678 Start Override new_status $sql = ("select orders_status from " . TABLE_ORDERS . " where orders_id = '" . (int)$ordersID . "'"); $old_status = $db->Execute($sql); if ($new_status < $old_status->fields['orders_status'] && (substr($txn_type,0,8) == 'cleared-' || $txn_type=='echeck-cleared' || $txn_type == 'express-checkout-cleared')) { $new_status = $old_status->fields['orders_status']; }//mc12345678 End Override new_status
Last edited by DrByte; 21 Oct 2014 at 09:28 PM. Reason: Fixed missing ]
ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...
This is just a quick note to mention that after upgrading to 1.5.5d, I have the same problem again. I remembered dealing with this before, so I pulled up this old post and am applying the same fix again. Here's hoping all goes well as before!