Hi Alex, I've tried the code you posted earlier but the invoice does not appear in the am_invoice_payment table. I can access the invoice details through the amember control panel though. The invoice was a recurring payment, if that makes any difference. I can open a ticket with my site details if that would help track down the issue.
Hi Alex, I've created a ticket on the help system KBE-49628-659 I've used the exact code you posted on the 1st page of this thread, simply modifying the invoice number to reflect one in the database. Cheers Glen.
For clarity with this, in case anyone else is having issues, this is the code that works for me (thanks alex for the fixes) PHP: <?phpclass Am_Plugin_Betgear extends Am_Plugin{ function onPaymentAfterInsert(Am_Event $event) { $payment = $event->getPayment(); $invoice = $payment->getInvoice(); $email = $invoice->getEmail(); foreach ($invoice->getItems() as $item) { $this->subReceived($item->item_id, $email, $item->qty, $payment->transaction_id); } //$this->getDi()->errorLogTable->log("BET GEAR HOOK: " . $s); } function subReceived($pid, $email, $qty, $transId) { print_rr("Prod ID $pid\r\nEmail $email\r\nQty $qty\r\nTrans ID $transId"); }}?> This plugin is placed into the following directory amember/application/default/plugins/misc/ I just need productID, Email, Quantity and TransactionId to update my database, but hopefully this may be useful to someone else. Cheers Glen.
I am troubleshooting the Post Affiliate Pro plug-in, which is not registering sales. I have determined that the plug-in's onPaymentAfterInsert() method is not being called. An invoice is being created for a free, 60-day trial download (does not call Authorize.net or PayPal plug-ins) and it appears that the free payment processor does not trigger onPaymentAfterInsert() - is that correct? Also, the "URL_TO_PAP" appears to be hard-coded, instead of using the configured script path. function onPaymentAfterInsert(Am_Event_PaymentAfterInsert $event) { $level = KLogger:EBUG; $log = new KLogger ( dirname(__FILE__)."/pap.log", $level ); $log->LogDebug( "onPaymentAfterInsert called..." ); if(!$this->getConfig('sale_tracking')) return; $log->LogDebug( "Sale tracking is configured. Processing..." ); $payment = $event->getPayment(); $invoice = $this->getDi()->invoiceTable->load($payment->invoice_id); $log->LogDebug( "Payment:" ); $log->LogDebug( $payment ); try { // $saleTracker = new Pap_Api_SaleTracker('URL_TO_PAP/scripts/sale.php'); $saleTracker = new Pap_Api_SaleTracker('http://www.mysite.com/affiliates/scripts/sale.php', true); // ****** DEBUG enabled if($acc = $this->getConfig('pan_account')) $saleTracker->setAccountId($acc); if($visitor_id = @$_COOKIE['PAPVisitorId']) $saleTracker->setVisitorId ($visitor_id); $sale = $saleTracker->createSale(); $sale->setTotalCost($payment->amount); $sale->setOrderID($payment->receipt_id); $saleTracker->register(); $log->LogDebug( "Sale registered." ); } catch (Exception $e) { $this->getDi()->errorLogTable->logException($e); } }
I have confirmed that the onPaymentAfterInsert() function gets called if a real payment is made (e.g., Authorize.Net), but not if no payment is generated (the free payment processor). Is it possible to have the free payment processor call onPaymentAfterInsert(), so free trials can be recorded and tracked for affiliates in PAP?
Sure this is possible but I can't provide exact code via forum(it needs to be tested first) Please contact us in helpdesk we will help to troubleshoot this issue and fix it for sure.