Exemplo n.º 1
0
 /**
  * Display the success page
  * 
  * @return null
  */
 function showSuccessPage()
 {
     $this->_objTpl->setTemplate($this->pageContent, true, true);
     if ($_REQUEST["handler"] == "yellowpay") {
         $orderId = \Yellowpay::getOrderId();
         $this->getSettings();
         if (\Yellowpay::checkin($this->arrSettings["paymentYellowpayShaOut"])) {
             switch (abs($_REQUEST["result"])) {
                 case 2:
                     // fehler aufgetreten
                     $objRegistration = new \Cx\Modules\Calendar\Controller\CalendarRegistration(null);
                     $objRegistration->delete($orderId);
                     $this->_objTpl->touchBlock("cancelMessage");
                     break;
                 case 1:
                     // erfolgreich
                     $objRegistration = new \Cx\Modules\Calendar\Controller\CalendarRegistration(null);
                     $objRegistration->get($orderId);
                     $objRegistration->setPaid(1);
                     $this->_objTpl->touchBlock("successMessage");
                     break;
                 case 0:
                     // abgebrochen
                     $objRegistration = new \Cx\Modules\Calendar\Controller\CalendarRegistration(null);
                     $objRegistration->delete($orderId);
                     $this->_objTpl->touchBlock("cancelMessage");
                     break;
                 default:
                     \Cx\Core\Csrf\Controller\Csrf::redirect("index.php?section=" . $this->moduleName);
                     break;
             }
         } else {
             \Cx\Core\Csrf\Controller\Csrf::redirect("index.php?section=" . $this->moduleName);
             return;
         }
     } else {
         \Cx\Core\Csrf\Controller\Csrf::redirect("index.php?section=" . $this->moduleName);
         return;
     }
 }
Exemplo n.º 2
0
 /**
  * Evaluate and register the payment result.
  * If the transaction was successful an email will be sent to the customer and administrator.
  *
  * @access      private
  */
 private function registerPaymentResult()
 {
     global $_ARRAYLANG, $_CONFIG, $objDatabase;
     $objSettingsYellowpay = new SettingsYellowpay($objDatabase);
     $arrYellowpay = $objSettingsYellowpay->get();
     //evaluate payment result
     $status = '';
     $orderId = \Yellowpay::getOrderId();
     $arrTransaction = $this->objTransaction->get(array($orderId));
     if (\Yellowpay::checkin($arrYellowpay['sha_out'])) {
         if (abs($_REQUEST['result']) == 1) {
             $status = self::CONFIRMED;
             if ($arrTransaction[0]['status'] == self::WAITING || $arrTransaction[0]['status'] == $status) {
                 $this->arrStatusMessages['ok'][] = $_ARRAYLANG['TXT_CHECKOUT_TRANSACTION_WAS_SUCCESSFUL'];
             }
             if ($arrTransaction[0]['status'] == $status) {
                 return;
             }
         } else {
             if ($_REQUEST['result'] == 0 || abs($_REQUEST['result']) == 2) {
                 $status = self::CANCELLED;
                 if ($arrTransaction[0]['status'] == self::WAITING || $arrTransaction[0]['status'] == $status) {
                     $this->arrStatusMessages['error'][] = $_ARRAYLANG['TXT_CHECKOUT_TRANSACTION_WAS_CANCELLED'];
                 }
                 if ($arrTransaction[0]['status'] == $status) {
                     return;
                 }
             } else {
                 $this->arrStatusMessages['error'][] = $_ARRAYLANG['TXT_CHECKOUT_INVALID_TRANSACTION_STATUS'];
                 return;
             }
         }
     } else {
         $this->arrStatusMessages['error'][] = $_ARRAYLANG['TXT_CHECKOUT_SECURITY_CHECK_ERROR'];
         return;
     }
     if ($arrTransaction[0]['status'] == self::WAITING) {
         //update transaction status
         $this->objTransaction->updateStatus($orderId, $status);
         //send confirmation email (if the payment was successful)
         if ($status == self::CONFIRMED) {
             $arrTransaction = $this->objTransaction->get(array($orderId));
             if (!empty($arrTransaction[0])) {
                 //prepare transaction data for output
                 $arrTransaction[0]['time'] = date('j.n.Y G:i:s', $arrTransaction[0]['time']);
                 switch ($arrTransaction[0]['status']) {
                     case self::WAITING:
                         $arrTransaction[0]['status'] = $_ARRAYLANG['TXT_CHECKOUT_STATUS_WAITING'];
                         break;
                     case self::CONFIRMED:
                         $arrTransaction[0]['status'] = $_ARRAYLANG['TXT_CHECKOUT_STATUS_CONFIRMED'];
                         break;
                     case self::CANCELLED:
                         $arrTransaction[0]['status'] = $_ARRAYLANG['TXT_CHECKOUT_STATUS_CANCELLED'];
                         break;
                 }
                 $arrTransaction[0]['invoice_currency'] = $this->arrCurrencies[$arrTransaction[0]['invoice_currency']];
                 $arrTransaction[0]['invoice_amount'] = number_format($arrTransaction[0]['invoice_amount'], 2, '.', '\'');
                 switch ($arrTransaction[0]['contact_title']) {
                     case self::MISTER:
                         $arrTransaction[0]['contact_title'] = $_ARRAYLANG['TXT_CHECKOUT_CONTACT_TITLE_MISTER'];
                         break;
                     case self::MISS:
                         $arrTransaction[0]['contact_title'] = $_ARRAYLANG['TXT_CHECKOUT_CONTACT_TITLE_MISS'];
                         break;
                 }
                 //get mail templates
                 $objSettingsMail = new SettingsMails($objDatabase);
                 $arrAdminMail = $objSettingsMail->getAdminMail();
                 $arrCustomerMail = $objSettingsMail->getCustomerMail();
                 //fill up placeholders in mail templates
                 $arrPlaceholders = array('DOMAIN_URL' => ASCMS_PROTOCOL . '://' . $_CONFIG['domainUrl'] . ASCMS_PATH_OFFSET, 'TRANSACTION_ID' => $arrTransaction[0]['id'], 'TRANSACTION_TIME' => $arrTransaction[0]['time'], 'TRANSACTION_STATUS' => $arrTransaction[0]['status'], 'INVOICE_NUMBER' => $arrTransaction[0]['invoice_number'], 'INVOICE_CURRENCY' => $arrTransaction[0]['invoice_currency'], 'INVOICE_AMOUNT' => $arrTransaction[0]['invoice_amount'], 'CONTACT_TITLE' => $arrTransaction[0]['contact_title'], 'CONTACT_FORENAME' => $arrTransaction[0]['contact_forename'], 'CONTACT_SURNAME' => $arrTransaction[0]['contact_surname'], 'CONTACT_COMPANY' => $arrTransaction[0]['contact_company'], 'CONTACT_STREET' => $arrTransaction[0]['contact_street'], 'CONTACT_POSTCODE' => $arrTransaction[0]['contact_postcode'], 'CONTACT_PLACE' => $arrTransaction[0]['contact_place'], 'CONTACT_COUNTRY' => $arrTransaction[0]['contact_country'], 'CONTACT_PHONE' => $arrTransaction[0]['contact_phone'], 'CONTACT_EMAIL' => $arrTransaction[0]['contact_email']);
                 foreach ($arrPlaceholders as $placeholder => $value) {
                     $arrAdminMail['title'] = str_replace('[[' . $placeholder . ']]', contrexx_raw2xhtml($value), $arrAdminMail['title']);
                     $arrAdminMail['content'] = str_replace('[[' . $placeholder . ']]', contrexx_raw2xhtml($value), $arrAdminMail['content']);
                     $arrCustomerMail['title'] = str_replace('[[' . $placeholder . ']]', contrexx_raw2xhtml($value), $arrCustomerMail['title']);
                     $arrCustomerMail['content'] = str_replace('[[' . $placeholder . ']]', contrexx_raw2xhtml($value), $arrCustomerMail['content']);
                 }
                 //send mail to administrator and customer
                 $this->sendConfirmationMail($_CONFIG['contactFormEmail'], $arrAdminMail);
                 $this->sendConfirmationMail($arrTransaction[0]['contact_email'], $arrCustomerMail);
             }
         }
         exit;
     }
 }