function select_or_insert_where() { global $auth_session; global $db; $domain_id = domain_id::get($this->domain_id); if ($this->filter == "date") { $where = "and ap.ac_date between '{$this->start_date}' and '{$this->end_date}'"; } $sql = "SELECT \n pt_id,\n\t\t count(DISTINCT pt_id) as count\n from \n " . TB_PREFIX . "payment_types \n WHERE \n pt_description = :pt_description\n\t\t AND \n\t\t domain_id = :domain_id\n GROUP BY\n pt_id;"; $sth = $db->query($sql, ':pt_description', $this->type, ':domain_id', $domain_id); $pt = $sth->fetch(); if ($pt['count'] == "1") { return $pt['pt_id']; } //add new patmeny type if no Paypal type if ($pt == "") { $new_pt = new payment_type(); $new_pt->pt_description = $this->type; $new_pt->pt_enabled = "1"; $new_pt->insert(); $payment_type = new payment_type(); $payment_type->type = $this->type; $payment_type->domain_id = $domain_id; return $payment_type->select_or_insert_where(); } }
function select_or_insert_where() { global $auth_session; global $db; $domain_id = domain_id::get($this->domain_id); if($this->filter == "date") { $where = "and ap.ac_date between '$this->start_date' and '$this->end_date'"; } $sql = "SELECT pt_id, count(DISTINCT pt_id) as count from ".TB_PREFIX."payment_types WHERE pt_description = :pt_description AND domain_id = :domain_id GROUP BY pt_id;"; $sth = $db->query($sql,':pt_description',$this->type,':domain_id',$domain_id); $pt = $sth->fetch(); if($pt['count'] =="1") { return $pt['pt_id']; } //add new payment type if no Paypal type if($pt =="") { $SI_PAYMENT_TYPES = new SimpleInvoices_Db_Table_PaymentTypes(); $new_payment_type_data = array( 'pt_description' => $this->type, 'pt_enabled' => 1 ); $SI_PAYMENT_TYPES->insert($new_payment_type_data); $payment_type = new payment_type(); $payment_type->type = $this->type; $payment_type->domain_id = $domain_id; return $payment_type->select_or_insert_where(); } }
function select_or_insert_where() { $sql = "SELECT \n pt_id,\n\t\t count(DISTINCT pt_id) as count\n FROM \n " . TB_PREFIX . "payment_types \n WHERE \n pt_description = :pt_description\n\t\t AND \n\t\t domain_id = :domain_id\n\t\t {$where}\n GROUP BY\n pt_id;"; $sth = dbQuery($sql, ':pt_description', $this->type, ':domain_id', $this->domain_id); $pt = $sth->fetch(); if ($pt['count'] == "1") { return $pt['pt_id']; } //add new payment type if no Paypal type if ($pt == '') { $new_pt = new payment_type(); $new_pt->pt_description = $this->type; $new_pt->pt_enabled = "1"; $new_pt->insert(); $payment_type = new payment_type(); $payment_type->type = $this->type; $payment_type->domain_id = $this->domain_id; return $payment_type->select_or_insert_where(); } }
if ($number_of_payments > 0) { $xml_message = 'Online payment for invoices: ' . $_POST['pg_consumerorderid'] . ' has already been entered into Simple Invoices'; $logger->log($xml_message, Zend_Log::INFO); } if ($number_of_payments == '0') { $payment = new payment(); $payment->ac_inv_id = $_POST['pg_consumerorderid']; $payment->ac_amount = $_POST['pg_total_amount']; $payment->ac_notes = $paypal_data; $payment->ac_date = date('Y-m-d'); $payment->online_payment_id = $_POST['pg_consumerorderid']; $payment->domain_id = '1'; $payment_type = new payment_type(); $payment_type->type = "ACH"; $payment_type->domain_id = '1'; $payment->ac_payment_type = $payment_type->select_or_insert_where(); $logger->log('ACH - payment_type=' . $payment->ac_payment_type, Zend_Log::INFO); $payment->insert(); $invoiceobj = new invoice(); $invoice = $invoiceobj->select($_POST['pg_consumerorderid']); $biller = getBiller($invoice['biller_id']); //send email $body = "A PaymentsGateway.com payment of " . $_POST['pg_total_amount'] . " was successfully received into Simple Invoices\n"; $body .= "for invoice: " . $_POST['pg_consumerorderid']; $body .= " from " . $_POST['pg_billto_postal_name_company'] . " on " . date('m/d/Y'); $body .= " at " . date('g:i A') . "\n\nDetails:\n"; $body .= $paypal_data; $email = new email(); $email->notes = $body; $email->to = $biller['email']; $email->from = "*****@*****.**";
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; }