public static function GetInstance() { if (!isset(self::$instance)) { $className = __CLASS__; self::$instance = new $className(); } return self::$instance; }
private function _SendInvoice() { // restore cart data from session Config::GetInstance()->InitSession(); $payment = new CheckoutController(); MessagePostMerger::GetInstance()->cart = $payment->getCartInstance(); // merge message with cart data and send it $emailer = new DataSaveMailer('email_settings'); $emailer->Save(); FormPage::GetInstance()->SetErrors($emailer->errors); // flags that determine further processing $this->invoiceSent = true; $this->checkedout = true; }
function PrepareConfirmPage() { $this->source = Config::GetInstance()->GetConfig('settings', 'redirect_settings', 'confirmpage'); if (empty($this->source)) { $this->source = false; return; } else { if (empty($this->post)) { return; } } if (Config::GetInstance()->UsePayments()) { // restore cart data from session Config::GetInstance()->InitSession(); $payment = new CheckoutController(); MessagePostMerger::GetInstance()->cart = $payment->getCartInstance(); MessagePostMerger::GetInstance()->setDecimals(Config::GetInstance()->GetConfig('settings', 'payment_settings', 'decimals')); } $this->source = MessagePostMerger::GetInstance()->SubstituteFieldNames($this->source); }
function _Send($spec) { if (!Config::GetInstance()->GetConfig('settings', $this->cfg_section, $spec, 'is_present')) { return; } $this->mailer->ResetFields(); $cfg_spec = Config::GetInstance()->GetConfig('settings', $this->cfg_section, $spec); $cfg_replyto = Config::GetInstance()->GetConfig('settings', $this->cfg_section, $spec, 'replyto'); $cfg_cc = Config::GetInstance()->GetConfig('settings', $this->cfg_section, $spec, 'cc'); $cfg_bcc = Config::GetInstance()->GetConfig('settings', $this->cfg_section, $spec, 'bcc'); $cfg_subject = Config::GetInstance()->GetConfig('settings', $this->cfg_section, $spec, 'custom', 'subject'); $cfg_body = Config::GetInstance()->GetConfig('settings', $this->cfg_section, $spec, 'custom', 'body'); $to = $this->_SubstituteAddress($cfg_spec->to); // In case the email is formatted as Name<*****@*****.**> we need to get the email@domain.com $angle_init = strpos($to, '<'); $angle_end = strpos($to, '>'); if ($angle_init !== false && $angle_end !== false) { $angle_length = $angle_end - $angle_init; $to = substr($to, $angle_init + 1, $angle_length - 1); } if ($to == '' && !empty($cfg_to)) { // happens when the to field is a magic field, but the user didn't fill it in // return without an error return; } else { if ($to == '' || !$this->mailer->SetRecipients($to)) { $this->errors[] = array('err' => _T('Could not send an email because the recipient isn\'t defined.')); writeErrorLog('Can\'t send a mail message when the "to:" field is empty.'); return; } } // set default and update with settings if available $this->mailer->SetFrom($this->default_from); if (isset($cfg_spec->from) && $cfg_spec->from) { $from = $this->_SubstituteAddress($cfg_spec->from); if (!empty($from)) { $this->mailer->SetFrom($from); } } if (isset($cfg_spec->replyto) && $cfg_spec->replyto) { $replyto = $this->_SubstituteAddress($cfg_spec->replyto); if (!empty($replyto)) { $this->mailer->SetReplyTo($replyto); } } if (isset($cfg_spec->cc) && $cfg_spec->cc) { $cc = $this->_SubstituteAddress($cfg_spec->cc); if (!empty($cc)) { $this->mailer->SetCC($cc); } } if (isset($cfg_spec->bcc) && $cfg_spec->bcc) { $bcc = $this->_SubstituteAddress($cfg_spec->bcc); if (!empty($bcc)) { $this->mailer->SetBCC($bcc); } } // subject should not be html-encoded, that is done by the mailer MessagePostMerger::GetInstance()->setDecimals(Config::GetInstance()->GetConfig('settings', 'payment_settings', 'decimals')); $this->mailer->SetSubject(MessagePostMerger::GetInstance()->SubstituteFieldNames($cfg_spec->custom->subject, false)); $this->mailer->SetMessage(MessagePostMerger::GetInstance()->SubstituteFieldNames($cfg_spec->custom->body, false)); if (!$this->mailer->Send()) { $this->errors[] = array('err' => $this->mailer->error); } }
/** * Fill the cart and prepare the page that connects to the payment processor * * @return false on empty cart, string with html-table definition on success. */ public function PreparePayment() { // ensure there isn't anything left from a previous session $this->getCartInstance()->emptyCart(); // translate the form into 'products' include 'fbapp/inc/fieldpricer.inc.php'; $this->products = makeprices($this); if (count($this->products) == 0) { return false; } // add these 'products' to the cart foreach ($this->products as $prd) { $this->cart->addProduct($prd, $prd->quantity, ''); } MessagePostMerger::GetInstance()->cart = $this->getCartInstance(); // build html table to show order (must be a html doc with encoding meta tag or else DomDocument gets upset) $html = '<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">' . '<style>td{margin:5px;}</style></head><body>'; $confirmpayment = Config::GetInstance()->GetConfig('settings', 'payment_settings', 'confirmpayment'); if (!empty($confirmpayment)) { MessagePostMerger::GetInstance()->setDecimals($this->getConfigS('decimals')); $html .= MessagePostMerger::GetInstance()->SubstituteFieldNames($confirmpayment); } else { MessagePostMerger::GetInstance()->GetHtmlCartTable($html); } switch (Config::GetInstance()->GetConfig('settings', 'payment_settings', 'paymenttype')) { case 'invoice': $html .= $this->_getInvoiceButton(); break; case 'redirect': Config::GetInstance()->SetSessionVariableFromPost(CC_FB_URLEMBEDDED); $html .= $this->_getPayPalWPSButton(); // $html .= $this->_getWorldPayButton(); $html .= $this->_getGoogleButton(); $html .= $this->_getAuthNetButton(); $html .= $this->_getToCheckoutButton(); break; case 'sdrive': // not yet implemented } $html .= '</body></html>'; return $html; }