function addDomain($domain)
{
    if (!isSiteAdmin()) {
        print json_encode(array('success' => FALSE, 'errors' => array('domain' => 'Permission denied')));
        return;
    }
    if (!$domain) {
        print json_encode(array('success' => FALSE, 'errors' => array('domain' => 'This field is required')));
        return;
    }
    $domain = strtolower($domain);
    if (!validDomain($domain)) {
        print json_encode(array('success' => FALSE, 'errors' => array('domain' => 'Invalid domain')));
        return;
    }
    if (domainExists($domain)) {
        print json_encode(array('success' => FALSE, 'errors' => array('domain' => 'Domain already exists')));
        return;
    }
    $user = $_SESSION['user'];
    if ($domain == $user['domain']) {
        print json_encode(array('success' => FALSE, 'errors' => array('domain' => 'Can not delete your own domain')));
        return;
    }
    $add = array('domain' => $domain);
    beginTransaction();
    $domain_id = db_insert('virtual_domains', $add, 'domain_id');
    if (!$domain_id) {
        cancelTransaction();
        print json_encode(array('success' => FALSE, 'errors' => array('domain' => 'Unknown error')));
        return;
    }
    $transport = array('subdomain' => 'autoreply', 'domain_id' => $domain_id, 'destination' => 'autoreply:', 'active' => 't');
    $transport_id = db_insert('transport_maps', $transport, 'transport_id');
    if (!$transport_id) {
        cancelTransaction();
        print json_encode(array('success' => FALSE, 'errors' => array('domain' => 'Unknown error')));
        return;
    }
    endTransaction();
    print json_encode(array('success' => true));
}
             $Gresponse->log->LogResponse("Response: " . array_to_json($response));
             break;
         case 'CANCELLED':
             $Gresponse->log->LogResponse("Cancelled " + $data[$root]['google-order-number']['VALUE']);
             $order = db_getOrderByOrderNumber($data[$root]['google-order-number']['VALUE']);
             cancelTransaction($order->id);
             $orderItems = db_getOrderItems($orderid);
             foreach ($orderItems as $orderItem) {
                 db_cancelOrderItem($orderid, $orderItem->itemid);
             }
             $Grequest->SendBuyerMessage($data[$root]['google-order-number']['VALUE'], "Sorry, your order is cancelled by the store", true);
             break;
         case 'CANCELLED_BY_GOOGLE':
             $Gresponse->log->LogResponse("Cancelled by Google " + $data[$root]['google-order-number']['VALUE']);
             $order = db_getOrderByOrderNumber($data[$root]['google-order-number']['VALUE']);
             cancelTransaction($order->id);
             $orderItems = db_getOrderItems($orderid);
             foreach ($orderItems as $orderItem) {
                 db_cancelOrderItem($orderid, $orderItem->itemid);
             }
             $Grequest->SendBuyerMessage($data[$root]['google-order-number']['VALUE'], "Sorry, your order is cancelled by Google", true);
             break;
         default:
             break;
     }
 }
 if ($fulfillmentStateHasChanged) {
     switch ($new_fulfillment_order) {
         case 'NEW':
             break;
         case 'PROCESSING':
示例#3
0
 } else {
     if ($requestMethod == "insertParentAndChild") {
         $childId = insertParentAndChild($conn, $appid, $secret);
         echo insertTransaction($conn, $childId);
     } else {
         if ($requestMethod == "teacherDetails") {
             getTeacherDetails($conn);
         } else {
             if ($requestMethod == "updateParentMobile") {
                 updateParentMobile($conn, $yunpian);
             } else {
                 if ($requestMethod == "myRecord") {
                     getMyRecord($conn);
                 } else {
                     if ($requestMethod == "cancelTransaction") {
                         cancelTransaction($conn);
                     } else {
                         if ($requestMethod == "parseCodeForDisplay") {
                             parseCodeForDisplay($conn);
                         } else {
                             if ($requestMethod == "trandactionDetail") {
                                 getTransactionDetail();
                             } else {
                                 if ($requestMethod == "updateTransaction") {
                                     updateTransaction();
                                 }
                             }
                         }
                     }
                 }
             }
示例#4
0
function addUser($newUser)
{
    $username = $newUser['username'];
    $domainId = $newUser['domainId'];
    $pass = $newUser['pass'];
    $repPass = $newUser['repPass'];
    $name = $newUser['name'];
    $active = $newUser['active'];
    $errors = array();
    $foundError = FALSE;
    if (!$username) {
        $foundError = TRUE;
        $errors['username'] = '******';
    }
    if (!$domainId) {
        $foundError = TRUE;
        $errors['domain'] = 'This field is required';
    }
    if (!$pass) {
        $foundError = TRUE;
        $errors['password'] = '******';
    }
    if (!$repPass) {
        $foundError = TRUE;
        $errors['reppassword'] = '******';
    }
    if (!$active) {
        $foundError = TRUE;
        $errors['active'] = 'This field is required';
    }
    if ($foundError) {
        print json_encode(array('success' => false, 'errors' => $errors));
        return;
    }
    $username = strtolower($username);
    if (!validUserName($username)) {
        $foundError = TRUE;
        $errors['username'] = '******';
    }
    $domain = getDomain($domainId);
    if (!$domain) {
        $foundError = TRUE;
        $errors['domain'] = 'Invalid domain';
    }
    if ($foundError) {
        print json_encode(array('success' => false, 'errors' => $errors));
        return;
    }
    $email = $username . '@' . $domain;
    $errors = array();
    $foundError = FALSE;
    if (userExists($email) || localForwardExists($email)) {
        $foundError = TRUE;
        $errors['username'] = '******';
    }
    if (strlen($pass) < 8) {
        $foundError = TRUE;
        $errors['password'] = '******';
    }
    if ($pass != $repPass) {
        $foundError = TRUE;
        $errors['reppassword'] = '******';
    }
    $adminDomains = getAdminDomains();
    if (!in_array($domain, $adminDomains)) {
        $foundError = TRUE;
        $errors['domain'] = 'Permission denied on domain: ' . $domain;
    }
    // TODO add password complexity requirements here
    if ($foundError) {
        print json_encode(array('success' => false, 'errors' => $errors));
        return;
    }
    if (!$name) {
        $name = '';
    }
    if ($active == 'true') {
        $active = 't';
    } else {
        $active = 'f';
    }
    $sql = 'INSERT INTO virtual_users (' . '    username,' . '    domain_id,' . '    password,' . '    role_id,' . '    description,' . '    active' . '  ) VALUES (?, ?, CRYPT(?, GEN_SALT(\'bf\', 8)), ?, ?, ?)';
    $params = array($username, $domainId, $pass, getRoleId('user'), $name, $active);
    beginTransaction();
    $rs = db_do($sql, $params);
    if (!$rs) {
        cancelTransaction();
        print json_encode(array('success' => false, 'errors' => array('username' => 'Unknown Error')));
        return;
    }
    $userId = getUserId($email);
    if (!$userId) {
        cancelTransaction();
        print json_encode(array('success' => false, 'errors' => array('username' => 'Unknown Error')));
        return;
    }
    $alias = array('username' => $username, 'domain_id' => $domainId, 'destination' => $email, 'active' => $active);
    $aliasId = db_insert('virtual_aliases', $alias, 'alias_id');
    if (!$aliasId) {
        cancelTransaction();
        print json_encode(array('success' => false, 'errors' => array('username' => 'Unknown Error')));
        return;
    }
    $alias['active'] = $active;
    $alias['destination'] = $email . '@autoreply.' . $domain;
    $aliasId = db_insert('virtual_aliases', $alias, 'alias_id');
    if (!$aliasId) {
        cancelTransaction();
        print json_encode(array('success' => false, 'errors' => array('username' => 'Unknown Error')));
        return;
    }
    endTransaction();
    print json_encode(array('success' => true));
}
示例#5
0
 $refundAmount = 0;
 $dbOrder = db_getOrderById($orderid);
 $dbOrder_payment = "";
 $dbOrder_id = "";
 $dbOrder_refund = "";
 $dbOrder_ordernumber = "";
 $dbOrder_userid = "";
 foreach ($dbOrder as $dbO) {
     $dbOrder_payment = $dbO['payment'];
     $dbOrder_id = $dbO['id'];
     $dbOrder_refund = $dbO['refund'];
     $dbOrder_ordernumber = $dbO['ordernumber'];
     $dbOrder_userid = $dbO['userid'];
 }
 $dbOrderItems = db_getOrderItems($orderid);
 $assignmentsResponse = cancelTransaction($orderid);
 //print_r($assignmentResponse);
 //print_r($dbOrderItems);
 $i = 0;
 foreach ($dbOrderItems as $dbOrderItem) {
     $ar = $assignmentsResponse[$i++];
     $subtotal = $dbOrderItem['quantity'] * $dbOrderItem['unitprice'];
     $partialRefund = $subtotal * $ar->percentageReturned / 100;
     $refundAmount = $refundAmount + $partialRefund;
 }
 //Google checkout orders
 if ($dbOrder_payment) {
     if ($refundAmount > 0) {
         db_setOrderRefund($dbOrder_id, $dbOrder_refund + $refundAmount);
         //Refund total or partial item price
         /*jh NOTE:  Discussed with Dr. Sadjadi on 7/6/2015 that we will not use the google request methods for now.