예제 #1
0
 function SetEdgilToken($client_id, $customer, $credit_card, $gateway, $order_id, $is_recurring = FALSE)
 {
     $CI =& get_instance();
     $this->loadObject($gateway);
     $data = new Java("com.edgil.ecco.eccoapi.CardholderData");
     // build customer data
     $customer_id = $customer['customer_id'];
     // can we put an address on Edgil's records?
     if (!empty($customer['address_1']) and !empty($customer['city']) and !empty($customer['state']) and !empty($customer['postal_code'])) {
         $address = $customer['address_1'];
         if (isset($customer['address_2']) and !empty($customer['address_2'])) {
             $address .= ' ' . $customer['address_2'];
         }
         $data->setAddress($address, $customer['city'], $customer['state'], $customer['postal_code']);
     }
     // set name
     $data->setName($customer['first_name'], $customer['last_name']);
     $data->setAccountNumber($credit_card['card_num']);
     $data->setExpirationDate($credit_card['exp_month'], $credit_card['exp_year']);
     $this->ECCOClient->certifyECCO($this->pass, $this->pass, $this->alias, "ECCO");
     $this->ECCOClient->logon($gateway['login_id'], $gateway['password']);
     $status = $this->ECCOClient->requestCreateToken($data, FALSE);
     if ($status == $this->ECCOStatusCodes->SUCCESS) {
         $token = $data->getToken();
         $CI->load->model('charge_data_model');
         $token_name = 'customer_' . $customer_id;
         if ($is_recurring == TRUE) {
             $token_name .= '_recur_' . $order_id;
         } else {
             $token_name .= '_charge_' . $order_id;
         }
         $CI->charge_data_model->Save($token_name, 'token', $token);
         $return = $token;
     } else {
         $return = FALSE;
     }
     $this->ECCOClient->logoff();
     return $return;
 }