Beispiel #1
0
 /**
  * Display a form which posts to authorize.net's server
  */
 public function paymentForm(\Jazzee\Entity\Applicant $applicant, $amount)
 {
     if (\is_a($this->_controller, 'ApplyPageController')) {
         $time = time();
         $fpSequence = $applicant->getId() . $time;
         $form = new \Foundation\Form();
         $form->newHiddenElement('x_amount', $amount);
         $form->newHiddenElement('x_test_request', $this->_controller->getConfig()->getStatus() == 'PRODUCTION' ? 0 : 1);
         $form->newHiddenElement('x_fp_sequence', $fpSequence);
         $form->newHiddenElement('x_fp_hash', \AuthorizeNetDPM::getFingerprint($this->_paymentType->getVar('gatewayId'), $this->_paymentType->getVar('gatewayKey'), $amount, $fpSequence, $time));
         $form->newHiddenElement('x_fp_timestamp', $time);
         $form->newHiddenElement('x_relay_response', "TRUE");
         $form->newHiddenElement('x_relay_url', $this->_controller->getServerPath() . $this->_controller->getActionPath() . '/../../../../../transaction/' . \urlencode(get_class($this)));
         $form->newHiddenElement('redirect_url', $this->_controller->getServerPath() . $this->_controller->getActionPath());
         $form->newHiddenElement('x_login', $this->_paymentType->getVar('gatewayId'));
         $form->newHiddenElement('x_cust_id', $applicant->getId());
         $form->newHiddenElement('x_customer_ip', $_SERVER['REMOTE_ADDR']);
         $form->newHiddenElement('x_email', $applicant->getEmail());
         $form->newHiddenElement('x_email_customer', 0);
         $form->newHiddenElement('x_description', $this->_paymentType->getVar('description'));
         $form->setAction($this->_paymentType->getVar('testAccount') ? \AuthorizeNetDPM::SANDBOX_URL : \AuthorizeNetDPM::LIVE_URL);
         $field = $form->newField();
         $field->setLegend($this->_paymentType->getName());
         $field->setInstructions("<p><strong>Application Fee:</strong> &#36;{$amount}</p>");
         $element = $field->newElement('TextInput', 'x_card_num');
         $element->setLabel('Credit Card Number');
         $element->addValidator(new \Foundation\Form\Validator\NotEmpty($element));
         $element = $field->newElement('TextInput', 'x_exp_date');
         $element->setLabel('Expiration Date');
         $element->setFormat('mm/yy eg ' . date('m/y'));
         $element->addValidator(new \Foundation\Form\Validator\NotEmpty($element));
         $element = $field->newElement('TextInput', 'x_card_code');
         $element->setLabel('CCV');
         $element->addValidator(new \Foundation\Form\Validator\NotEmpty($element));
         $element = $field->newElement('TextInput', 'x_zip');
         $element->setLabel('Billing Postal Code');
         $element->setInstructions('US Credit Cards which do not provide a postal code will be rejected.');
         $form->newButton('submit', 'Pay with Credit Card');
     } else {
         $form = parent::paymentForm($applicant, $amount);
     }
     return $form;
 }
function cw_payment_authorize_sim_run_processor($params, $return)
{
    if ($params['payment_data']['processor'] == authorize_sim_addon_name) {
        global $config, $tables, $current_location, $cart, $APP_SESS_ID;
        $addon_name = str_replace("-", "_", authorize_sim_addon_name);
        $asim_api_login_id = $config[$addon_name]['asim_api_login_id'];
        $asim_transaction_key = $config[$addon_name]['asim_transaction_key'];
        $asim_md5_hash = $config[$addon_name]['asim_md5_hash'];
        $asim_mode = $config[$addon_name]['asim_test_live_mode'];
        $asim_currency = $config[$addon_name]['asim_currency'];
        $asim_prefix = intval($config[$addon_name]['asim_prefix']);
        if (empty($asim_api_login_id) || empty($asim_transaction_key)) {
            $top_message = array("content" => "Enter your merchant credentials on settings page before running the payment.", "type" => "E");
            cw_header_location($current_location . "index.php?target=cart&mode=checkout");
        }
        define("AUTHORIZENET_API_LOGIN_ID", $asim_api_login_id);
        define("AUTHORIZENET_TRANSACTION_KEY", $asim_transaction_key);
        define("AUTHORIZENET_SANDBOX", $asim_mode == "live" ? FALSE : TRUE);
        define("AUTHORIZENET_MD5_SETTING", $asim_md5_hash);
        $payment_data = $params['payment_data'];
        $userinfo = $params['userinfo'];
        $doc_ids = $params['doc_ids'];
        $cart =& cw_session_register('cart');
        $time = time();
        $asim_amount = price_format($cart['info']['total']);
        $asim_fp_sequence = $asim_prefix . $time;
        $asim_fp_hash = AuthorizeNetDPM::getFingerprint($asim_api_login_id, $asim_transaction_key, $asim_amount, $asim_fp_sequence, $time);
        $asim_fp_timestamp = $time;
        $asim_relay_url = $current_location . '/index.php?target=' . authorize_sim_addon_target;
        // save $APP_SESS_ID
        $unique_id = strtolower(md5($asim_md5_hash . $asim_api_login_id . $userinfo['email']));
        db_query("INSERT INTO {$tables['payment_data']} (ref_id, session_id) VALUES ('{$unique_id}', '{$APP_SESS_ID}')");
        $card_expire_Month = intval($_POST['card_expire_Month']);
        $card_expire_Year = intval($_POST['card_expire_Year']);
        cw_func_call('cw_payment_create_form', array('url' => AUTHORIZENET_SANDBOX ? AuthorizeNetDPM::SANDBOX_URL : AuthorizeNetDPM::LIVE_URL, 'fields' => array('x_relay_response' => "FALSE", 'x_version' => "3.1", 'x_delim_char' => ",", 'x_delim_data' => "TRUE", 'x_amount' => $asim_amount, 'x_fp_sequence' => $asim_fp_sequence, 'x_fp_hash' => $asim_fp_hash, 'x_fp_timestamp' => $time, 'x_relay_response' => "TRUE", 'x_relay_url' => $asim_relay_url, 'x_login' => $asim_api_login_id, 'x_card_num' => $_POST['card_number'], 'x_exp_date' => date("m/y", mktime(0, 0, 0, $card_expire_Month, 1, $card_expire_Year)), 'x_card_code' => $_POST['card_cvv2'], 'x_first_name' => $_POST['first_name'], 'x_last_name' => $_POST['last_name'], 'x_address' => $_POST['address'], 'x_city' => $_POST['city'], 'x_state' => $_POST['state'], 'x_zip' => $_POST['zipcode'], 'x_country' => $_POST['country'], 'x_email' => $userinfo['email']), 'name' => $payment_data['title']));
        exit;
    }
    return $return;
}
 public function testGenerateFingerprint()
 {
     $this->assertEquals("db88bbebb8f699acdbe70daad897a68a", AuthorizeNetDPM::getFingerprint("123", "123", "123", "123", "123"));
 }
        <form method="post" action="process_sale.php" id="checkout_form">
        <input type="hidden" name="size" value="<?php 
    echo $size;
    ?>
">
        <?php 
} else {
    ?>
        <form method="post" action="<?php 
    echo AUTHORIZENET_SANDBOX ? AuthorizeNetDPM::SANDBOX_URL : AuthorizeNetDPM::LIVE_URL;
    ?>
" id="checkout_form">
        <?php 
    $time = time();
    $fp_sequence = $time;
    $fp = AuthorizeNetDPM::getFingerprint(AUTHORIZENET_API_LOGIN_ID, AUTHORIZENET_TRANSACTION_KEY, $amount, $fp_sequence, $time);
    $sim = new AuthorizeNetSIM_Form(array('x_amount' => $amount, 'x_fp_sequence' => $fp_sequence, 'x_fp_hash' => $fp, 'x_fp_timestamp' => $time, 'x_relay_response' => "TRUE", 'x_relay_url' => $coffee_store_relay_url, 'x_login' => AUTHORIZENET_API_LOGIN_ID, 'x_test_request' => TEST_REQUEST));
    echo $sim->getHiddenFieldString();
}
?>
      <fieldset>
        <div>
          <label>Credit Card Number</label>
          <input type="text" class="text required creditcard" size="15" name="x_card_num" value="6011000000000012"></input>
        </div>
        <div>
          <label>Exp.</label>
          <input type="text" class="text required" size="4" name="x_exp_date" value="04/15"></input>
        </div>
        <div>
          <label>CCV</label>
 /**
  *show signup details
  * @author vovich, Alex
  * @param int $signupId
  */
 function signupDetails($signupId = null, $activeTab = 'tab-payment')
 {
     $userSession = $this->Session->read('loggedUser');
     $signupDetails = $this->_getSignupDetails($signupId);
     $isFreeSignup = 0;
     if ($signupDetails['Signup']['status'] == 'paid' && $signupDetails['Signup']['total'] + $signupDetails['Signup']['discount'] + $signupDetails['Signup']['2pay'] == 0) {
         $isFreeSignup = 1;
     }
     $userID = $this->getUserID();
     $signupUsers = $this->SignupsUser->find('all', array('conditions' => array('signup_id' => $signupId), 'contain' => 'User'));
     $signupUserIDs = Set::combine($signupUsers, '{n}.SignupsUser.user_id', '{n}.SignupsUser.user_id');
     $signupUsers = Set::combine($signupUsers, '{n}.SignupsUser.user_id', '{n}');
     $this->Access->checkAccess('Signup', 'u', $signupDetails['Signup']['user_id']);
     //pr($signupDetails);
     //Getting packages
     if (!empty($signupDetails['Packagedetails']['package_id'])) {
         $this->Package->recursive = -1;
         $packageInformation = $this->Package->find('first', array('conditions' => array('Package.id' => $signupDetails['Packagedetails']['package_id'])));
         $signupDetails['Package'] = $packageInformation['Package'];
     }
     //get the number of people in team
     if ($signupDetails['Signup']['model'] == 'Event') {
         $Event = ClassRegistry::init('Event');
         $Event->recursive = -1;
         $event = $Event->find('first', array('conditions' => array('id' => $signupDetails['Signup']['model_id'])));
         $peopleinteam = $event['Event']['people_team'];
     } else {
         $peopleinteam = 2;
     }
     //        return $this->returnJSONResult($event);
     // PAYMENT BLOCK
     //Getting payments
     $this->Payment->recursive = 1;
     $payments = $this->Payment->find('all', array('conditions' => array('Payment.user_id' => $signupDetails['Signup']['user_id'], 'Payment.model' => 'Signup', 'Payment.model_id' => $signupDetails['Signup']['id'])));
     if (intval($signupDetails['Signup']['2pay']) > 0) {
         // Authorize.net DPM installation ===========================================================================================
         include_once '../vendors/anet_php_sdk/AuthorizeNet.php';
         $amount = $signupDetails['Signup']['2pay'];
         $time = time();
         $fp_sequence = $time;
         $authorizeNetProperties = array('x_amount' => $amount, 'x_fp_sequence' => $fp_sequence, 'x_fp_timestamp' => $time, 'x_relay_response' => "TRUE", 'x_merchant_email' => ADMIN_EMAIL, 'x_relay_url' => SECURE_SERVER . '/signups/payment_callback', 'x_delim_data' => "TRUE", 'x_delim_char' => ",");
         if (SIGNUP_AUTH_NET_TEST_MODE) {
             $authLogin = SIGNUP_AUTH_NET_TEST_LOGIN_ID;
             $authKey = SIGNUP_AUTH_NET_TEST_TRAN_KEY;
             $authorizeNetProperties['x_test_request'] = 'TRUE';
             $authorizeNetURL = AuthorizeNetDPM::SANDBOX_URL;
         } else {
             $authLogin = SIGNUP_AUTH_NET_LOGIN_ID;
             $authKey = SIGNUP_AUTH_NET_TRAN_KEY;
             $authorizeNetProperties['x_test_request'] = 'FALSE';
             $authorizeNetURL = AuthorizeNetDPM::LIVE_URL;
         }
         $authorizeNetProperties['x_freight'] = '0';
         $authorizeNetProperties['x_po_numz'] = $signupId;
         //additional customer data
         $authorizeNetProperties['x_cust_id'] = $this->getUserID();
         $authorizeNetProperties['x_customer_ip'] = $_SERVER['REMOTE_ADDR'];
         $authorizeNetProperties['x_merchant_email'] = '*****@*****.**';
         $authorizeNetProperties['x_invoice_num'] = $signupId;
         $authorizeNetProperties['x_description'] = $signupDetails[$signupDetails['Signup']['model']]['name'];
         $authorizeNetProperties['x_login'] = $authLogin;
         $authorizeNetProperties['x_email'] = $signupDetails['User']['email'];
         $fp = AuthorizeNetDPM::getFingerprint($authLogin, $authKey, $amount, $fp_sequence, $time);
         $authorizeNetProperties['x_fp_hash'] = $fp;
         foreach ($authorizeNetProperties as $key => $value) {
             $authorizeNetProperties[$key] = addslashes($value);
         }
         $sim = new AuthorizeNetSIM_Form($authorizeNetProperties);
         $authorizeNetHiddens = $sim->getHiddenFieldString();
         // EOF Authorize Net configuration
         if ($this->Session->check('signup_payment_error')) {
             $payment_error = $this->Session->read('signup_payment_error');
             $this->Session->delete('signup_payment_error');
         } else {
             $payment_error = '';
         }
         if ($this->Session->check('last_payment_id')) {
             $last_payment_id = $this->Session->read('last_payment_id');
             $payment = $this->Payment->find('first', array('conditions' => array('Payment.id' => $last_payment_id)));
             $addressID = $payment['Payment']['address_id'];
             $phone = $this->Phone->field('phone', array('id' => $payment['Payment']['phone_id']));
         } else {
             $addressID = 0;
             $phone = '';
         }
         $this->set('authorizeNetHiddens', $authorizeNetHiddens);
         $this->set('authorizeNetURL', $authorizeNetURL);
         $this->set('payment_error', $payment_error);
         // EOF Authorize.net DPM installation ==========================================================================
     }
     // EOF PAYMENT BLOCK
     //Checking Team and Teammates
     $isteamAssigned = false;
     $roomIsCompleted = false;
     $Team = ClassRegistry::init('Team');
     $assigned = array();
     //Changed by Skinny. We need to include the Pending teams, otherwise it's confusing. If the user selects this team,
     //it automatically accepts their participation on the team
     $teams = $Team->getAllUserTeamsIncludingPending($signupDetails['Signup']['user_id'], " Team.* ", $signupDetails[$signupDetails['Signup']['model']]['people_team']);
     if (empty($teams)) {
     } else {
         //Getting assigned teams
         $assigned = $Team->getUserAssignedTeams($signupDetails['Signup']['user_id'], $signupDetails['Signup']['model'], $signupDetails['Signup']['model_id']);
         if (!empty($assigned)) {
             $isteamAssigned = true;
         }
     }
     $teamInfoForSignup = array();
     $teammates = array();
     if (!empty($assigned[0]['Team']['id'])) {
         $teamInfoForSignup = $Team->teamInfoForSignup($assigned[0]['Team']['id'], $signupDetails['Signup']['model'], $signupDetails['Signup']['model_id'], $signupDetails);
         $teammates = $Team->Teammate->find('all', array('conditions' => array('team_id' => $assigned[0]['Team']['id'], 'status' => array('Accepted', 'Creator', 'Pending')), 'contain' => array('User')));
     }
     //Added by Skinny: If this user is Pending on a team that is assigned to the event, we need to give him the opportunity here
     //to accept this.
     $userIsPendingOnTeam = false;
     if ($isteamAssigned) {
         if (empty($teamInfoForSignup['waiting_for_signup']) && empty($teamInfoForSignup['waiting_for_accept'])) {
             $teamIsCompleted = true;
         } else {
             $teamIsCompleted = false;
             foreach ($teamInfoForSignup['waiting_for_accept'] as $userWaitingForAccept) {
                 if ($userWaitingForAccept['id'] == $userID) {
                     $userIsPendingOnTeam = $userWaitingForAccept;
                 }
             }
         }
     } else {
         $teamIsCompleted = false;
     }
     $new_created_team_id = 0;
     if ($this->Session->check('new_created_team_id')) {
         $new_created_team_id = $this->Session->read('new_created_team_id');
         $this->Session->delete('new_created_team_id');
     }
     //EOF checking
     // ROOMS BLOCK
     $roomsCnt = 0;
     if ($signupDetails[$signupDetails['Signup']['model']]['is_room'] == 0 || !$signupDetails['Package']['people_in_room']) {
         $roomIsCompleted = true;
     } else {
         $roomsCnt = $this->SignupRoommate->getCountRooms($signupDetails['Signup']['model'], $signupDetails['Signup']['model_id'], $signupDetails['Signup']['user_id']);
         $roomsStatus = 'incompleted';
         if ($signupDetails['Signup']['for_team']) {
             $neededRooms = $signupDetails[$signupDetails['Signup']['model']]['people_team'] / $signupDetails['Package']['people_in_room'];
         } else {
             $neededRooms = 1;
         }
         $rooms = $this->SignupRoom->getSignupRooms($signupUserIDs, $signupDetails['Signup']['model'], $signupDetails['Signup']['model_id']);
         $roomInfo = array();
         $roomIsCompleted = false;
         $roomIsPending = false;
         // CREATE ROOM BLOCK
         $showCreateRoomBlock = true;
         if ($neededRooms <= count($rooms)) {
             $roomIsCompleted = true;
             $showCreateRoomBlock = false;
         }
         $showFindInviters = false;
         foreach ($rooms as $room) {
             if (isset($room['users'][$signupDetails['Signup']['user_id']])) {
                 $showCreateRoomBlock = false;
                 if ($room['status'] == 'Pending') {
                     $roomIsCompleted = false;
                     $roomIsPending = true;
                 }
             }
             if ($room['people_in_room'] > count($room['roommates'])) {
                 $showFindInviters = true;
                 $roomIsCompleted = false;
             }
         }
         if ($signupDetails['Signup']['for_team'] && !$showCreateRoomBlock && !$roomIsCompleted) {
             $waitingForTemmatesRoom = true;
         } else {
             $waitingForTemmatesRoom = false;
         }
         if ($showCreateRoomBlock) {
             //working with questions
             $questions = $this->Question->find('all', array('conditions' => array('model' => 'Room_for_' . strtolower($signupDetails['Signup']['model']), 'model_id' => $signupDetails['Signup']['model_id'])));
             $this->set('questions', $questions);
         }
         $this->set('showFindInviters', $showFindInviters);
         $this->set('waitingForTemmatesRoom', $waitingForTemmatesRoom);
         $this->set('showCreateRoomBlock', $showCreateRoomBlock);
         // EOF CREATE ROOM BLOCK
         $this->set('rooms', $rooms);
     }
     // EOF ROOMS BLOCK
     if (!empty($signupDetails[$signupDetails['Signup']['model']]['signup_required'])) {
         $this->set('cheepestPackage', $this->Package->getCheepesPackage($signupDetails['Signup']['model'], $signupDetails['Signup']['model_id']));
     }
     if ($signupDetails['Signup']['status'] != 'paid') {
         /*pass to the view countries and states*/
         $countries_states = $this->Address->setCountryStates();
         $this->set('countries', $countries_states['countries']);
         $this->set('states', $countries_states['states']);
         //Getting  address
         $this->Address->recursive = -1;
         $addresses = $this->Address->find('list', array('fields' => array('id', 'address'), 'conditions' => array('model' => 'User', 'model_id' => $userSession['id'], 'is_deleted <>' => 1), 'order' => 'id DESC'));
         $addresses = array('0' => "Custom address") + $addresses;
         $this->set('addressesIds', $addresses);
     }
     if ($userID == 2) {
         //Configure::write('debug', '1');
         //echo $neededRooms;
         //pr($signupDetails);
     }
     $this->set('peopleinteam', $peopleinteam);
     $teams = Set::combine($teams, '{n}.Team.id', '{n}.Team.name');
     $this->set('cardtypes', array('Visa' => 'Visa', 'MasterCard' => 'MasterCard'));
     $this->set('team', $assigned);
     $this->set('userIsPendingOnTeam', $userIsPendingOnTeam);
     //Checking accession for the changing packages
     $this->set('canChangePackage', $this->Access->getAccess('SignupChangePackage', 'r', $signupDetails['Signup']['user_id']));
     $this->set('canUpgradePackage', $this->Access->getAccess('SignupUpgradePackage', 'r', $signupDetails['Signup']['user_id']));
     $this->set('userRole', 'creator');
     $this->set('roomsCnt', $roomsCnt);
     $this->set('isFreeSignup', $isFreeSignup);
     $this->set('new_created_team_id', $new_created_team_id);
     $this->set(compact('roomsCnt', 'roomIsCompleted', 'roomIsPending', 'activeTab', 'teamIsCompleted', 'isteamAssigned', 'teamInfoForSignup', 'signupUsers', 'userID', 'payments', 'signupDetails', 'signupId', 'teams', 'signupDetails', 'phone', 'addressID', 'teammates'));
 }