Beispiel #1
0
 private function _PreparePayment()
 {
     Config::GetInstance()->InitSession();
     $payment = new CheckoutController();
     // make a cart out of the form
     if (($html = $payment->PreparePayment()) === false) {
         // an empty cart is allowed if there are no required payment fields
         // but in that case any emails must be send now, because the checkout page won't be there
         FormPage::GetInstance()->SendEmails(true);
         return false;
     }
     // ensure the merger has access to cart details
     MessagePostMerger::GetInstance()->cart = $payment->getCartInstance();
     // saveCartToDB generates a new id if none was specified
     $transactid = $payment->saveCartToDB();
     // associate our transaction id to the form
     FormPage::GetInstance()->SaveTransactionId($transactid);
     // prepare the page with cart info to show the user
     $userdom = new DOMDocument('1.0', 'UTF-8');
     $userdom->loadHTML($html);
     $xpath = new DOMXpath($userdom);
     $msgnode = $xpath->query('//body')->item(0);
     FormPage::GetInstance()->PrepareInlineMessage($msgnode, true);
     // save cart to session, needed if emails are send from the confirmation screen
     $payment->saveCartToSession();
     // send any emails, now that cart data has been made available
     FormPage::GetInstance()->SendEmails();
     // save the checkout page and the post data (needed it after payment)
     Config::GetInstance()->SetSessionVariable('code', FormPage::GetInstance()->source);
     Config::GetInstance()->SetSessionVariable('post', FormPage::GetInstance()->post);
     ob_end_clean();
     header('Location: ' . getUrl('action=checkout'));
     exit(0);
 }