コード例 #1
0
ファイル: eway.php プロジェクト: dadigo/simpleinvoices
 public function payment()
 {
     global $config;
     global $logger;
     //set customer,biller and preference if not defined
     if (empty($this->customer)) {
         $this->customer = getCustomer($this->invoice['customer_id'], $this->domain_id);
     }
     if (empty($this->biller)) {
         $this->biller = getBiller($this->invoice['biller_id'], $this->domain_id);
     }
     if (empty($this->preference)) {
         $this->preference = getPreference($this->invoice['preference_id'], $this->domain_id);
     }
     $eway = new ewaylib($this->biller['eway_customer_id'], 'REAL_TIME', false);
     //Eway only accepts amount in cents - so times 100
     $value = $this->invoice['total'] * 100;
     $eway_invoice_total = htmlsafe(trim($value));
     $logger->log("eway total: " . $eway_invoice_total, Zend_Log::INFO);
     $enc = new encryption();
     $key = $config->encryption->default->key;
     $credit_card_number = $enc->decrypt($key, $this->customer['credit_card_number']);
     $eway->setTransactionData("TotalAmount", $eway_invoice_total);
     //mandatory field
     $eway->setTransactionData("CustomerFirstName", $this->customer['name']);
     $eway->setTransactionData("CustomerLastName", "");
     $eway->setTransactionData("CustomerAddress", "");
     $eway->setTransactionData("CustomerPostcode", "");
     $eway->setTransactionData("CustomerInvoiceDescription", "");
     $eway->setTransactionData("CustomerEmail", $this->customer['email']);
     $eway->setTransactionData("CustomerInvoiceRef", $this->invoice['index_name']);
     $eway->setTransactionData("CardHoldersName", $this->customer['credit_card_holder_name']);
     //mandatory field
     $eway->setTransactionData("CardNumber", $credit_card_number);
     //mandatory field
     $eway->setTransactionData("CardExpiryMonth", $this->customer['credit_card_expiry_month']);
     //mandatory field
     $eway->setTransactionData("CardExpiryYear", $this->customer['credit_card_expiry_year']);
     //mandatory field
     $eway->setTransactionData("Option1", "");
     $eway->setTransactionData("Option2", "");
     $eway->setTransactionData("Option3", "");
     $eway->setTransactionData("TrxnNumber", $this->invoice['id']);
     //special preferences for php Curl
     //pass a long set to zero value stops curl from verifying peer's certificate
     $eway->setCurlPreferences(CURLOPT_SSL_VERIFYPEER, 0);
     $ewayResponseFields = $eway->doPayment();
     $this->message = $ewayResponseFields;
     $message = "";
     if ($ewayResponseFields["EWAYTRXNSTATUS"] == "False") {
         $logger->log("Transaction Error: " . $ewayResponseFields["EWAYTRXNERROR"] . "<br>\n", Zend_Log::INFO);
         foreach ($ewayResponseFields as $key => $value) {
             $message .= "\n<br>\$ewayResponseFields[\"{$key}\"] = {$value}";
         }
         $logger->log("Eway message: " . $message . "<br>\n", Zend_Log::INFO);
         //header("Location: trasnactionerrorpage.php");
         //exit();
         $return = 'false';
     } else {
         if ($ewayResponseFields["EWAYTRXNSTATUS"] == "True") {
             $logger->log("Transaction Success: " . $ewayResponseFields["EWAYTRXNERROR"] . "<br>\n", Zend_Log::INFO);
             foreach ($ewayResponseFields as $key => $value) {
                 $message .= "\n<br>\$ewayResponseFields[\"{$key}\"] = {$value}";
             }
             $logger->log("Eway message: " . $message . "<br>\n", Zend_Log::INFO);
             //header("Location: trasnactionsuccess.php");
             //exit();
             $payment = new payment();
             $payment->ac_inv_id = $this->invoice['id'];
             #$payment->ac_inv_id = $_POST['invoice'];
             $payment->ac_amount = $this->invoice['total'];
             #$payment->ac_amount = $ewayResponseFields['EWAYRETURNAMOUNT']/100;
             #$payment->ac_amount = $_POST['mc_gross'];
             $payment->ac_notes = $message;
             $payment->ac_date = date('Y-m-d');
             $payment->online_payment_id = $ewayResponseFields['EWAYTRXNNUMBER'];
             $payment->domain_id = $this->domain_id;
             $payment_type = new payment_type();
             $payment_type->type = "Eway";
             $payment_type->domain_id = $this->domain_id;
             $payment->ac_payment_type = $payment_type->select_or_insert_where();
             $logger->log('Paypal - payment_type=' . $payment->ac_payment_type, Zend_Log::INFO);
             $payment->insert();
             #echo $db->lastInsertID();
             $return = 'true';
         }
     }
     return $return;
 }
コード例 #2
0
ファイル: contacts.php プロジェクト: siwiwit/PhreeBooksERP
 public function getContact()
 {
     global $db, $messageStack;
     if ($this->id == '' && !$this->aid == '') {
         $result = $db->Execute("select * from " . TABLE_ADDRESS_BOOK . " where address_id = {$this->aid} ");
         $this->id = $result->fields['ref_id'];
     }
     // Load contact info, including custom fields
     $result = $db->Execute("select * from " . TABLE_CONTACTS . " where id = {$this->id}");
     foreach ($result->fields as $key => $value) {
         $this->{$key} = $value;
     }
     // expand attachments
     $this->attachments = $result->fields['attachments'] ? unserialize($result->fields['attachments']) : array();
     // Load the address book
     $result = $db->Execute("select * from " . TABLE_ADDRESS_BOOK . " where ref_id = {$this->id} order by primary_name");
     $this->address = array();
     while (!$result->EOF) {
         $type = substr($result->fields['type'], 1);
         $this->address_book[$type][] = new objectInfo($result->fields);
         if ($type == 'm') {
             // prefill main address
             foreach ($result->fields as $key => $value) {
                 $this->address[$result->fields['type']][$key] = $value;
             }
         }
         $result->MoveNext();
     }
     // load payment info
     if ($_SESSION['admin_encrypt'] && ENABLE_ENCRYPTION) {
         $result = $db->Execute("select id, hint, enc_value from " . TABLE_DATA_SECURITY . " where module='contacts' and ref_1={$this->id}");
         $encrypt = new encryption();
         while (!$result->EOF) {
             if (!($values = $encrypt->decrypt($_SESSION['admin_encrypt'], $result->fields['enc_value']))) {
                 $error = $messageStack->add('Encryption error - ' . implode('. ', $encrypt->errors), 'error');
             }
             $val = explode(':', $values);
             $this->payment_data[] = array('id' => $result->fields['id'], 'name' => $val[0], 'hint' => $result->fields['hint'], 'exp' => $val[2] . '/' . $val[3]);
             $result->MoveNext();
         }
     }
     // load contacts info
     $result = $db->Execute("select * from " . TABLE_CONTACTS . " where dept_rep_id={$this->id}");
     $this->contacts = array();
     while (!$result->EOF) {
         $cObj = new objectInfo();
         foreach ($result->fields as $key => $value) {
             $cObj->{$key} = $value;
         }
         $addRec = $db->Execute("select * from " . TABLE_ADDRESS_BOOK . " where type='im' and ref_id=" . $result->fields['id']);
         $cObj->address['m'][] = new objectInfo($addRec->fields);
         $this->contacts[] = $cObj;
         //unserialize(serialize($cObj));
         // load crm notes
         $logs = $db->Execute("select * from " . TABLE_CONTACTS_LOG . " where contact_id = " . $result->fields['id'] . " order by log_date desc");
         while (!$logs->EOF) {
             $this->crm_log[] = new objectInfo($logs->fields);
             $logs->MoveNext();
         }
         $result->MoveNext();
     }
     // load crm notes
     $result = $db->Execute("select * from " . TABLE_CONTACTS_LOG . " where contact_id = {$this->id} order by log_date desc");
     while (!$result->EOF) {
         $this->crm_log[] = new objectInfo($result->fields);
         $result->MoveNext();
     }
 }
コード例 #3
0
ファイル: contacts.php プロジェクト: siwiwit/PhreeBooksERP
         }
     } else {
         // just delete the address
         $db->Execute('delete from ' . TABLE_ADDRESS_BOOK . " where address_id = {$id}");
     }
     $message[] = 'The record was successfully deleted!';
     $xml .= xmlEntry('address_id', $id);
     break;
 case 'get_payment':
     $id = $_GET['pID'];
     $result = $db->Execute("select id, hint, enc_value from " . TABLE_DATA_SECURITY . " where id = {$id} limit 1");
     if ($result->RecordCount() < 1) {
         $message[] = sprintf('The record could not be found! Looking for id = %s', $id);
     } else {
         $enc_data = new encryption();
         $data = $enc_data->decrypt($_SESSION['admin_encrypt'], $result->fields['enc_value']);
         $fields = explode(':', $data);
         if (strlen($fields[3]) == 2) {
             $fields[3] = '20' . $fields[3];
         }
         // make sure year is 4 digits
         $xml .= "<PaymentMethod>\n";
         $xml .= xmlEntry("payment_id", $result->fields['id']);
         $xml .= xmlEntry("payment_hint", $result->fields['hint']);
         for ($i = 0; $i < sizeof($fields); $i++) {
             $xml .= xmlEntry("field_" . $i, $fields[$i]);
         }
         $xml .= "</PaymentMethod>\n";
     }
     break;
 case 'rm_payment':
コード例 #4
0
     $idx++;
     if (substr($add_type, 1, 1) == 'm') {
         // pull some special information since it's the main address
         $edit_text = $accounts->fields['primary_name'] . ' (' . $accounts->fields['short_name'] . ')';
         $accounts->fields[$add_type . '_notes'] = $accounts->fields['notes'];
     }
     $accounts->MoveNext();
 }
 // load payment info
 if ($_SESSION['admin_encrypt']) {
     $result = $db->Execute("select id, hint, enc_value from " . TABLE_DATA_SECURITY . " where module='contacts' and ref_1 = " . $id);
     $js_pmt_array = "var js_pmt_array = new Array(" . $result->RecordCount() . ");" . chr(10);
     $cnt = 0;
     $encrypt = new encryption();
     while (!$result->EOF) {
         if (!($values = $encrypt->decrypt($_SESSION['admin_encrypt'], $result->fields['enc_value']))) {
             $messageStack->add('Encryption error - ' . implode('. ', $encrypt->errors), 'error');
             $error = true;
         }
         $val = explode(':', $values);
         $js_pmt_array .= 'js_pmt_array[' . $cnt . '] = new pmtRecord("' . $result->fields['id'] . '", "' . $result->fields['hint'] . '", "' . $val[0] . '", "' . $val[1] . '", "' . $val[2] . '", "' . $val[3] . '", "' . $val[4] . '");' . chr(10);
         $accounts->fields['pmt_values'][] = array('id' => $result->fields['id'], 'name' => $val[0], 'hint' => $result->fields['hint'], 'exp' => $val[2] . '/' . $val[3]);
         $cnt++;
         $result->MoveNext();
     }
 }
 $cInfo = new objectInfo($accounts->fields);
 if ($error) {
     // do this if action was save and error occurred, regen post input
     foreach ($_POST as $key => $value) {
         $cInfo->{$key} = $value;