function onPaymentAfterInsert(Am_Event_PaymentAfterInsert $event)
 {
     $guest = $this->getDi()->newsletterGuestTable->findByEmail($event->getUser()->email);
     if ($guest) {
         $guest->delete();
     }
 }
Beispiel #2
0
 public function onPaymentAfterInsert(Am_Event_PaymentAfterInsert $e)
 {
     if ($this->getConfig('unsubscribe_after_signup') != self::UNSUBSCRIBE_AFTER_PAID) {
         return;
     }
     $user = $e->getUser();
     if ($user->data()->get('unsubscribe_after_signup')) {
         return;
     }
     $user->data()->set('unsubscribe_after_signup', self::UNSUBSCRIBE_AFTER_PAID)->update();
     if (!($lists = $this->getConfig('unsubscribe_after_signup_lists'))) {
         return;
     }
     try {
         $this->changeSubscription($e->getUser(), array(), $lists);
     } catch (Exception $e) {
         //just log
         $this->getDi()->errorLogTable->logException($e);
     }
 }
 static function onPaymentAfterInsert(Am_Event_PaymentAfterInsert $event)
 {
     /**
      * This e-mail is sent for first payment in invoice only
      * another template must be used for the following payments
      */
     if ($event->getInvoice()->getPaymentsCount() != 1) {
         return;
     }
     if ($event->getDi()->config->get('send_payment_mail')) {
         $et = Am_Mail_Template::load('send_payment_mail', $event->getUser()->lang);
         if ($et) {
             $et->setUser($event->getUser())->setInvoice($event->getInvoice())->setPayment($event->getPayment())->setInvoice_text($event->getInvoice()->render());
             if (Am_Di::getInstance()->config->get('send_pdf_invoice', false)) {
                 try {
                     $invoice = new Am_Pdf_Invoice($event->getInvoice());
                     $et->getMail()->createAttachment($invoice->render(), 'application/pdf', Zend_Mime::DISPOSITION_ATTACHMENT, Zend_Mime::ENCODING_BASE64, $invoice->getFileName());
                 } catch (Exception $e) {
                     $this->getDi()->errorLogTable->logException($e);
                 }
             }
             $et->send($event->getUser());
         }
     }
     if ($event->getDi()->config->get('send_payment_admin')) {
         $et = Am_Mail_Template::load('send_payment_admin', $event->getUser()->lang);
         if ($et) {
             $et->setUser($event->getUser())->setInvoice($event->getInvoice())->setPayment($event->getPayment())->setInvoice_text($event->getInvoice()->render());
             $et->send(Am_Mail_Template::TO_ADMIN);
         }
     }
 }
Beispiel #4
0
 /**
  * Handle payments
  */
 function onPaymentAfterInsert(Am_Event_PaymentAfterInsert $event)
 {
     $this->getDi()->affCommissionRuleTable->processPayment($event->getInvoice(), $event->getPayment());
 }
Beispiel #5
0
 public function onPaymentAfterInsert(Am_Event_PaymentAfterInsert $event)
 {
     $user = $event->getUser();
     if ($this->getConfig('ecommerce_tracking') && ($mc_cid = $this->getVar($user, 'mc_cid')) && ($mc_eid = $this->getVar($user, 'mc_eid'))) {
         $payment = $event->getPayment();
         $invoice = $event->getInvoice();
         $api = $this->getApi();
         $items = array();
         foreach ($invoice->getItems() as $item) {
             $single_item = array('product_id' => $item->item_id, 'product_name' => $item->item_title, 'qty' => $item->qty, 'cost' => $payment->isFirst() ? $item->first_price : $item->second_price);
             $product = $this->getDi()->productTable->load($item->item_id);
             $categories = $product->getCategories();
             if (!empty($categories)) {
                 $category_id = array_pop($categories);
                 $category = $this->getDi()->productCategoryTable->load($category_id);
                 $single_item['category_id'] = $category->pk();
                 $single_item['category_name'] = $category->title;
             } else {
                 $single_item['category_id'] = 0;
                 $single_item['category_name'] = "No Category";
             }
             $items[] = $single_item;
         }
         $api->sendRequest('campaignEcommOrderAdd', array('order' => array('id' => $payment->transaction_id, 'campaign_id' => $mc_cid, 'email_id' => $mc_eid, 'total' => $payment->amount, 'store_id' => $this->getDi()->config->get('site_title'), 'items' => $items)));
     }
 }