[checkout]cannot clear transaction in custom payment module

anonimlt

Joined: 2010-02-11
Posts: 26
Posted: Sat, 2010-02-20 12:42

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?

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Sun, 2010-02-21 02:13

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?

 
anonimlt

Joined: 2010-02-11
Posts: 26
Posted: Sun, 2010-02-21 18:03

There are zeros in g2_timeCleared, G2timePaid and all further columns. After clearing db cache nothing happened, values remained zeros.
Gallery version 2.3

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Sun, 2010-02-21 18:47
Quote:
I can see Sat 20 Feb 2010 06:09:26 CST : Payment cleared.

Quote:
There are zeros in g2_timeCleared

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?

 
anonimlt

Joined: 2010-02-11
Posts: 26
Posted: Sun, 2010-02-21 19:36

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.

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Sun, 2010-02-21 19:55
Quote:
There are more records which are cleared in the IPN processing script

I don't understand what you mean by this?

Quote:
I guess that IPN message from the payment gateway comes before calling checkout.Complete

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).

 
anonimlt

Joined: 2010-02-11
Posts: 26
Posted: Sun, 2010-02-21 20:16
Quote:
alecmyers wrote:
Quote:
There are more records which are cleared in the IPN processing script

I don't understand what you mean by this?

I mean there are a number of orders which were cleared by IPN messages and all of them look the same ('unpaid' in the orders list, 'cleared' when I open the order record).

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Mon, 2010-02-22 00:20

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.

 
anonimlt

Joined: 2010-02-11
Posts: 26
Posted: Mon, 2010-02-22 12:59

I'll try to investigate, the clearing date is not random, it is the correct date and time.

 
anonimlt

Joined: 2010-02-11
Posts: 26
Posted: Thu, 2010-02-25 20:44

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'.