MADMAN32395 Posted April 27, 2017 Share Posted April 27, 2017 So I have noticed on my test site when I hook into \IPS\nexus\Package , using $purchase->id returns the wrong number. From what I understand its supposed to be t_id from nexus_transactions but isn't. 1274 is the actual number, but returns 964 when called. I have tried to bring this up in a ticket but was shrugged off by support. Edit: when targeting invoice->id that returns the correct invoice number. Link to comment Share on other sites More sharing options...
inkredible Posted April 27, 2017 Share Posted April 27, 2017 The first level support will never let you go through if you report a bug with the framework code. It's odd because when you post a bug with the Framework here, you usually will be asked to report the same via the ticketsystem again. Link to comment Share on other sites More sharing options...
HeadStand Posted April 27, 2017 Share Posted April 27, 2017 $purchase->id should return a purchase ID, not a transaction ID. Those are 2 different things. If you post your code here, I can give you a more intelligent answer, but it's hard to say anything without seeing what it is you're trying to do. Link to comment Share on other sites More sharing options...
MADMAN32395 Posted April 27, 2017 Author Share Posted April 27, 2017 11 hours ago, HeadStand said: $purchase->id should return a purchase ID, not a transaction ID. Those are 2 different things. If you post your code here, I can give you a more intelligent answer, but it's hard to say anything without seeing what it is you're trying to do. so overall instead of pulling ps_id which is what purchase->id grabs, im looking at grabbing t_id to get the transaction number. Link to comment Share on other sites More sharing options...
HeadStand Posted April 27, 2017 Share Posted April 27, 2017 6 minutes ago, MADMAN32395 said: so overall instead of pulling ps_id which is what purchase->id grabs, im looking at grabbing t_id to get the transaction number. Yes, but where? Please paste your code. I don't know what method you're hooking into or what you're trying to do. Please share code and I'll be happy to help you. Link to comment Share on other sites More sharing options...
MADMAN32395 Posted April 28, 2017 Author Share Posted April 28, 2017 2 hours ago, HeadStand said: Yes, but where? Please paste your code. I don't know what method you're hooking into or what you're trying to do. Please share code and I'll be happy to help you. public function onPurchaseGenerated( \IPS\nexus\Purchase $purchase, \IPS\nexus\Invoice $invoice ) { try { $COIN_PACKAGES = array( 1 => 'NULL', // 5 donator 9 => 5000, // 5 recurring donor 5 => 15000, // 10 donator, 2500 extra , non-recurring 14 => 20000, // 10 recurring donor 6 => 35000, // 15 donator, 5000 extra , non-recurring 15 => 40000, // 15 recurring donor 7 => 80000, // 25 donator, 5000 extra , non-recurring 16 => 85000, // 25 recurring donor 8 => 55000, // 20 donator, 10000 extra , non-recurring 13 => 60000, //20 recurring donor, following pattern of previous 11 => 2000, // 1 usd 12 => 5000 // 2 usd, 1000 extra (from previous) ); $gccoins = $COIN_PACKAGES[$this->id]; if (!$gccoins) { //die("Invalid Coin Package"); return; } $steamid = $purchase->member->steamid; if ($steamid == NULL) { $steamid = "NULL"; } $query = "INSERT INTO coin_purchases (communityID,forumID,coinsPurchased,redeemed,transactionID, invoiceID) VALUES ('".$steamid."',".$purchase->member->member_id.",".$gccoins.", 0,".$purchase->id.",".$invoice->id.")"; $dbc = mysqli_connect("<REDACTED>", '<REDACTED>', '<REDACTED>', '<REDACTED>'); $result = mysqli_query($dbc, $query); if($result === false) mysqli_close($dbc); return parent::onPurchaseGenerated( $purchase, $invoice ); } Link to comment Share on other sites More sharing options...
HeadStand Posted April 28, 2017 Share Posted April 28, 2017 Now we're talking. To get the transaction, you use the invoice, not the purchase. try { $row = \IPS\Db::i()->select( '*', 'nexus_transactions', array( 't_invoice=? and t_status=?', $invoice->id, \IPS\nexus\Transaction::STATUS_PAID ), 't_date desc' )->first(); $transaction = \IPS\nexus\Tranasaction::constructFromData( $row ); } catch( \UnderflowException $e ) { // error handling here - unable to find transaction } Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.