Example #1
0
 function savePaymentMethod()
 {
     global $osC_Language, $osC_ShoppingCart, $osC_Payment, $messageStack, $toC_Json, $osC_Currencies;
     $errors = array();
     $osC_Language->load('account');
     $osC_Language->load('checkout');
     $osC_Language->load('order');
     if (isset($_POST['payment_comments']) && isset($_SESSION['payment_comments']) && empty($_POST['payment_comments'])) {
         unset($_SESSION['comments']);
     } elseif (!empty($_POST['payment_comments'])) {
         $_SESSION['comments'] = osc_sanitize_string($_POST['payment_comments']);
     }
     if (DISPLAY_CONDITIONS_ON_CHECKOUT == '1') {
         if (!isset($_POST['conditions']) || $_POST['conditions'] != '1') {
             $errors[] = $osC_Language->get('error_conditions_not_accepted');
         }
     }
     if ($osC_ShoppingCart->isTotalZero() == false) {
         // load the selected payment module
         require_once 'includes/classes/payment.php';
         $osC_Payment = new osC_Payment(isset($_REQUEST['payment_method']) ? $_REQUEST['payment_method'] : $osC_ShoppingCart->getBillingMethod('id'));
         if (isset($_REQUEST['payment_method'])) {
             $osC_ShoppingCart->setBillingMethod(array('id' => $_REQUEST['payment_method'], 'title' => $GLOBALS['osC_Payment_' . $_REQUEST['payment_method']]->getMethodTitle()));
         }
         if ($osC_Payment->hasActive() && (isset($GLOBALS['osC_Payment_' . $osC_ShoppingCart->getBillingMethod('id')]) === false || isset($GLOBALS['osC_Payment_' . $osC_ShoppingCart->getBillingMethod('id')]) && is_object($GLOBALS['osC_Payment_' . $osC_ShoppingCart->getBillingMethod('id')]) && $GLOBALS['osC_Payment_' . $osC_ShoppingCart->getBillingMethod('id')]->isEnabled() === false)) {
             $errors[] = $osC_Language->get('error_no_payment_module_selected');
         }
         if ($osC_Payment->hasActive()) {
             $osC_Payment->pre_confirmation_check();
         }
         if ($messageStack->size('checkout_payment') > 0) {
             $errors = array_merge($errors, $messageStack->getMessages('checkout_payment'));
         }
     } else {
         $osC_ShoppingCart->resetBillingMethod();
     }
     if (sizeof($errors) > 0) {
         $response = array('success' => false, 'errors' => $errors);
     } else {
         $form = toC_Json_Checkout::_getOrderConfirmationForm();
         $response = array('success' => true, 'form' => $form);
     }
     echo $toC_Json->encode($response);
 }
Example #2
0
 function deleteCoupon()
 {
     global $toC_Json, $osC_Language, $osC_Payment, $osC_ShoppingCart, $osC_Currencies, $osC_Payment;
     $osC_ShoppingCart->deleteCoupon();
     $go_to_payment_form = false;
     if (!$osC_ShoppingCart->isTotalZero() && !$osC_ShoppingCart->hasBillingMethod()) {
         $go_to_payment_form = true;
     }
     $form = toC_Json_Checkout::_getOrderConfirmationForm();
     $response = array('success' => true, 'form' => $form, 'go_to_payment_form' => $go_to_payment_form);
     echo $toC_Json->encode($response);
 }