I try to clear a transaction when I receive IPN message from a payment gateway in a View's renderImmediate() function
Quote:
$ret = GalleryCheckoutApi::changeTransactionStatus($transaction, 'clear');
if ($ret) {
return $ret;
}
$transaction is correct.
but the transaction status does not change to cleared in the 'Admin orders' list. It is 'unpaid', but when I open the that order in the order history I can see Sat 20 Feb 2010 06:09:26 CST : Payment cleared.
Client receives a message, and there is a link to download items in a zip file.
What am I doing wrong?
Posts: 4342
Look in the g2_CheckoutTransaction table, the row for that transaction. What's in the g_timeCleared column? What happens if you clear the db cache?
Posts: 26
There are zeros in g2_timeCleared, G2timePaid and all further columns. After clearing db cache nothing happened, values remained zeros.
Gallery version 2.3
Posts: 4342
These two statements should be mutually exclusive - the contents of that db field is just a unix timestamp whose value is tested and printed {g->date timestamp=$block.checkout.cleared style = "datetime"} if non zero. It's difficult to imagine where the "Sat 20 Feb" actually value comes from if the database is really holding zero for the timeCleared for that transaction.
I'd suspect a caching issue, or else you're looking at the db record for the wrong transaction perhaps?
Posts: 26
I believe I'm looking at the right transaction record. There are more records which are cleared in the IPN processing script, but in the order list they are unpaid. All acceleration is disabled, even template caching is disabled. I guess that IPN message from the payment gateway comes before calling checkout.Complete in my case. Could this be a problem?
I haven't tested the live scenario yet, I am playing in sandbox mode. I have an ability to resend IPN message from the payment gateway manually. This message clears an order and the customer is notified with a download link, but in the 'admin orders' list order remains unpaid as I said before.
Posts: 4342
I don't understand what you mean by this?
They can happen in either order. It's not critical that the checkout.Complete view is accessed at all (as it can't be guaranteed).
Posts: 26
Posts: 4342
Trace through the execution flow that leads to it being listed as "cleared" and see if you can determine (with judicious use of "echo" statements, etc - typical debugging tactics) where the timestamp data is appearing from. At present I don't accept that if it's listed as zero in the db that a random date can be displayed, the data must be coming from somewhere, so you'll have to investigate.
Posts: 26
I'll try to investigate, the clearing date is not random, it is the correct date and time.
Posts: 26
The problem was that in renderImmediate() I used exit('OK') as it was in the example file provided by the payment gateway company, instead of echo 'OK'.