Esempio n. 1
0
 /**
  * Stores the Payments as present in the POST request
  *
  * See {@see Payment::delete()},
  * {@see Payment::add()}, and
  * {@see Payment::update()}.
  */
 static function storePayments()
 {
     $result = NULL;
     if (isset($_GET['delete_payment'])) {
         $payment_id = intval($_GET['delete_payment']);
         $result = Payment::delete($payment_id);
     }
     if (isset($result)) {
         self::$changed = true;
         self::$success &= $result;
     }
     //DBG::log("after Payment::delete: ".self::$success.", changed: ".self::$changed);
     $result = Payment::add();
     if (isset($result)) {
         self::$changed = true;
         self::$success &= $result;
     }
     //DBG::log("after Payment::add: ".self::$success.", changed: ".self::$changed);
     $result = Payment::update();
     if (isset($result)) {
         self::$changed = true;
         self::$success &= $result;
     }
     //DBG::log("after Payment::update: ".self::$success.", changed: ".self::$changed);
     Payment::reset();
     if (empty($_POST['bpayment'])) {
         return;
     }
     // NOTE: All the following could be handled by Payment::settings()
     \Cx\Core\Setting\Controller\Setting::set('payrexx_instance_name', trim(strip_tags(contrexx_input2raw($_POST['payrexx_instance_name']))));
     \Cx\Core\Setting\Controller\Setting::set('payrexx_api_secret', trim(strip_tags(contrexx_input2raw($_POST['payrexx_api_secret']))));
     \Cx\Core\Setting\Controller\Setting::set('payrexx_active', !empty($_POST['payrexx_active']));
     \Cx\Core\Setting\Controller\Setting::set('postfinance_shop_id', trim(strip_tags(contrexx_input2raw($_POST['postfinance_shop_id']))));
     \Cx\Core\Setting\Controller\Setting::set('postfinance_active', !empty($_POST['postfinance_active']));
     //        \Cx\Core\Setting\Controller\Setting::set('postfinance_hash_seed',
     //            trim(strip_tags(contrexx_input2raw($_POST['postfinance_hash_seed']);
     // Replaced by
     \Cx\Core\Setting\Controller\Setting::set('postfinance_hash_signature_in', trim(strip_tags(contrexx_input2raw($_POST['postfinance_hash_signature_in']))));
     \Cx\Core\Setting\Controller\Setting::set('postfinance_hash_signature_out', trim(strip_tags(contrexx_input2raw($_POST['postfinance_hash_signature_out']))));
     \Cx\Core\Setting\Controller\Setting::set('postfinance_authorization_type', trim(strip_tags(contrexx_input2raw($_POST['postfinance_authorization_type']))));
     // OBSOLETE -- Determined by the available cards and the PostFinance
     // backend settings
     //        \Cx\Core\Setting\Controller\Setting::set('postfinance_accepted_payment_methods', $strYellowpayAcceptedPM);
     \Cx\Core\Setting\Controller\Setting::set('postfinance_use_testserver', !empty($_POST['postfinance_use_testserver']));
     // Postfinance Mobile
     \Cx\Core\Setting\Controller\Setting::set('postfinance_mobile_webuser', trim(strip_tags(contrexx_input2raw($_POST['postfinance_mobile_webuser']))));
     \Cx\Core\Setting\Controller\Setting::set('postfinance_mobile_sign', trim(strip_tags(contrexx_input2raw($_POST['postfinance_mobile_sign']))));
     \Cx\Core\Setting\Controller\Setting::set('postfinance_mobile_ijustwanttotest', !empty($_POST['postfinance_mobile_ijustwanttotest']));
     \Cx\Core\Setting\Controller\Setting::set('postfinance_mobile_status', !empty($_POST['postfinance_mobile_status']));
     // Saferpay
     \Cx\Core\Setting\Controller\Setting::set('saferpay_id', trim(strip_tags(contrexx_input2raw($_POST['saferpay_id']))));
     \Cx\Core\Setting\Controller\Setting::set('saferpay_active', !empty($_POST['saferpay_active']));
     \Cx\Core\Setting\Controller\Setting::set('saferpay_finalize_payment', !empty($_POST['saferpay_finalize_payment']));
     \Cx\Core\Setting\Controller\Setting::set('saferpay_use_test_account', !empty($_POST['saferpay_use_test_account']));
     \Cx\Core\Setting\Controller\Setting::set('saferpay_window_option', intval($_POST['saferpay_window_option']));
     // Paypal
     \Cx\Core\Setting\Controller\Setting::set('paypal_account_email', trim(strip_tags(contrexx_input2raw($_POST['paypal_account_email']))));
     \Cx\Core\Setting\Controller\Setting::set('paypal_active', !empty($_POST['paypal_active']));
     \Cx\Core\Setting\Controller\Setting::set('paypal_default_currency', trim(strip_tags(contrexx_input2raw($_POST['paypal_default_currency']))));
     // Datatrans
     \Cx\Core\Setting\Controller\Setting::set('datatrans_merchant_id', trim(strip_tags(contrexx_input2raw($_POST['datatrans_merchant_id']))));
     \Cx\Core\Setting\Controller\Setting::set('datatrans_active', !empty($_POST['datatrans_active']));
     \Cx\Core\Setting\Controller\Setting::set('datatrans_request_type', trim(strip_tags(contrexx_input2raw($_POST['datatrans_request_type']))));
     \Cx\Core\Setting\Controller\Setting::set('datatrans_use_testserver', !empty($_POST['datatrans_use_testserver']));
     // Paymill
     \Cx\Core\Setting\Controller\Setting::set('paymill_active', !empty($_POST['paymill_active']));
     \Cx\Core\Setting\Controller\Setting::set('paymill_use_test_account', !empty($_POST['paymill_use_test_account']));
     \Cx\Core\Setting\Controller\Setting::set('paymill_test_private_key', trim(strip_tags(contrexx_input2raw($_POST['paymill_test_private_key']))));
     \Cx\Core\Setting\Controller\Setting::set('paymill_test_public_key', trim(strip_tags(contrexx_input2raw($_POST['paymill_test_public_key']))));
     \Cx\Core\Setting\Controller\Setting::set('paymill_live_private_key', trim(strip_tags(contrexx_input2raw($_POST['paymill_live_private_key']))));
     \Cx\Core\Setting\Controller\Setting::set('paymill_live_public_key', trim(strip_tags(contrexx_input2raw($_POST['paymill_live_public_key']))));
     // LSV
     \Cx\Core\Setting\Controller\Setting::set('payment_lsv_active', !empty($_POST['payment_lsv_active']));
     // All preceding should be handled by Payment::settings()
 }
Esempio n. 2
0
    $debtObj = new Debt();
    $debtObj->setOwed_to($user_id);
    $debtObj->setPayment_id($payment_id);
    $total = 0;
    for ($i = 0; $i < count($_POST["user_id"]); $i++) {
        $debtObj->setOwed_by($_POST['user_id'][$i]);
        $debt_total = $_POST['drinks_owed'][$i] + $_POST['food_owed'][$i];
        $total += $debt_total;
        $debtObj->setAmount($debt_total);
        $debtObj->create();
        //echo "<p>" . $_POST['user_id'][$i] . " owes " . $_COOKIE['user_id'] . " &pound;" . $_POST['drinks_owed'][$i] . " for drinks and &pound;" . $_POST['food_owed'][$i] . " for food for a total of &pound;" . $total . "</p>";
    }
    $paymentObj->setId($payment_id);
    $paymentObj->setTotal($total);
    $paymentObj->setDate($_POST['date']);
    $paymentObj->update();
    header("Location: dashboard.php");
    exit;
} else {
    // Get list of users for form
    $user_arr = User::getAll();
    // Built debt form input
    $userObj = new User();
    $debt_form = "<select name='user_id[]'>\n";
    $debt_form .= "<option>Select a user</option>\n";
    foreach ($user_arr as $user_id) {
        $userObj->setId($user_id);
        $userObj->load();
        $debt_form .= "<option value='{$user_id}'>" . $userObj->getName() . "</option>\n";
    }
    $debt_form .= "</select>\n";
 /**
  * @expectedException         Everypay\Exception\RuntimeException
  * @expectedExceptionMessage  Resource Payments does not support method Everypay\Payment::update
  */
 public function testPaymentUpdate()
 {
     $token = 'pmt_4KQ2DD15gs2w8RS4M2MhBz1Q';
     $payment = Payment::update($token, []);
 }
Esempio n. 4
0
 /**
  * @expectedException         Everypay\Exception\RuntimeException
  * @expectedExceptionMessage  Resource Payments does not support method Everypay\Payment::update
  * @group                     ecommerce
  * @group                     3dsecure
  */
 public function testPaymentUpdate()
 {
     //applicable both in local and remote mode
     $token = 'pmt_4KQ2DD15gs2w8RS4M2MhBz1Q';
     $payment = Payment::update($token, array());
 }
Esempio n. 5
0
function showPayment()
{
    global $connector;
    $student = new Student();
    $student->setConnector($connector);
    $payment = new Payment();
    $payment->setConnector($connector);
    if (isset($_POST['operation'])) {
        list($operation, $params) = explode("#", $_POST['operation']);
        switch ($operation) {
            case 'selectStudent':
                $result['edit'] = $payment->getById($params);
                if (!isset($result['edit']->student_id)) {
                    $result['edit']->student_id = $params;
                }
                break;
            case 'delete':
                $error_msg = $payment->delete($params);
                break;
            case 'edit':
                $result['edit'] = $payment->getById($params);
                break;
            case 'editChanges':
                $payment->storeFormValues($_POST);
                $error_msg = $payment->update();
                break;
            case 'saveChanges':
                $payment->storeFormValues($_POST);
                $payment->setConnector($connector);
                $error_msg = $payment->insert();
                break;
            default:
                $error_msg = "Operazione non valida";
        }
        if ($error_msg != "") {
            $result["errorMessage"] = $error_msg;
        } elseif ($operation != 'edit' && $operation != 'selectStudent') {
            $result["statusMessage"] = "Operazione completata!";
        }
    }
    $result['students'] = $student->getList("cognome");
    $result['payments'] = $payment->getList();
    $page = "payment.php";
    include_once BASE_PATH . "template.php";
}