print_r($assoc); die; require_once "../includes/subFunctions/banks.ipaygate.php"; $processor = new iPayGate_Client($bankInfo); $sql = "SELECT ss_ID\r\nFROM cs_subscription where ss_billing_type in ('Check');\r\n"; $cnt = 0; $result = mysql_query($sql) or dieLog(mysql_errno() . ": " . mysql_error() . "<BR>"); while ($cs_subscription = mysql_fetch_assoc($result)) { $subs = new transaction_class(false); $subs->pull_subscription($cs_subscription['ss_ID']); $transInfo['ss_billing_check_routing'] = $subs->etelDecSalted($subs->row['subscriptionTable']['ss_billing_check_routing']); $transInfo['ss_billing_check_account'] = $subs->etelDecSalted($subs->row['subscriptionTable']['ss_billing_check_account']); if (!is_numeric($transInfo['ss_billing_check_routing'])) { $transInfo['ss_billing_check_routing'] = etelDec($subs->row['transactionTable']['bankroutingcode']); if (is_numeric($transInfo['ss_billing_check_routing'])) { echo "update cs_subscription set ss_billing_check_routing = '" . $subs->etelEncSalted($transInfo['ss_billing_check_routing']) . "' \r\n\t\t\t\r\n\t\t\twhere ss_ID = '" . $cs_subscription['ss_ID'] . "';<br>"; } else { echo $cs_subscription['ss_ID'] . ' PROBLEM ' . $transInfo['ss_billing_check_account'] . '<BR>'; } } else { } flush(); } die($sqlchange); $sql = "select * from `cs_subscription` left join cs_transactiondetails on ss_transaction_id = transactionId where ss_bank_id in (15,28,29)"; $result = mysql_query($sql) or die($sql); while ($transInfo = mysql_fetch_assoc($result)) { $expDate = explode("/", $transInfo['validupto']); $expYear = $expDate[0]; $expMonth = $expDate[1]; $transInfo['CCnumber'] = etelDec($transInfo['CCnumber']);
function createSubscription() { if ($this->transInfo['ss_account_status'] == 'inactive' && $this->transInfo['ss_rebill_status'] == 'inactive') { return $this->transInfo; } $expD = explode("/", $this->transInfo['validupto']); $expYear = $expD[0]; $expMonth = $expD[1]; $salt = md5(mt_rand(1, 2000000000)); //if($this->transInfo['checkorcard']=='C') $ss_billing_type = 'Check'; //else if($this->transInfo['cardtype'] == 'Visa') $ss_billing_type = 'Visa'; //else if($this->transInfo['cardtype'] == 'Master') $ss_billing_type = 'Mastercard'; //else $ss_billing_type = $this->transInfo['cardtype']; $ss_subscription_ID = $this->transInfo['td_subscription_id']; if (!$ss_subscription_ID) { $ss_subscription_ID = genRefId("subscription", "S"); } $this->transInfo['td_subscription_id'] = $ss_subscription_ID; if (!$this->transInfo['ss_account_status']) { $this->transInfo['ss_account_status'] = 'active'; } if (!$this->transInfo['ss_account_expire_date']) { $this->transInfo['ss_account_expire_date'] = $this->transInfo['td_recur_next_date']; } if (!$this->transInfo['ss_rebill_status']) { $this->transInfo['ss_rebill_status'] = $this->transInfo['td_enable_rebill'] == 1 ? "active" : "inactive"; } if (!$this->transInfo['ss_rebill_status_text']) { $this->transInfo['ss_rebill_status_text'] = ''; } if (!$this->transInfo['ss_rebill_amount']) { $this->transInfo['ss_rebill_amount'] = $this->transInfo['td_recur_charge']; } if (!$this->transInfo['ss_rebill_next_date']) { $this->transInfo['ss_rebill_next_date'] = $this->transInfo['td_recur_next_date']; } //$exists = $this->subscription_exists($this->transInfo['transactionId']); //if($exists) // Why would this happen? -Ari //{ // $sql_action = "UPDATE"; // $sql_where = "WHERE ss_transaction_id = '" . $this->transInfo['transactionId']."'"; //} //else //{ $sql_action = "INSERT INTO"; $sql_where = ""; //} $ss_rebill_status = 'active'; $subscription = "{$sql_action}\r\n\t\t\t\t\t\t\t`cs_subscription`\r\n\t\t\t\t\t\t\tSET\r\n\t\t\t\t\t\t\t `ss_subscription_ID`='" . quote_smart($ss_subscription_ID) . "',\r\n\t\t\t\t\t\t\t `ss_billing_firstname` = '" . quote_smart($this->transInfo['name']) . "',\r\n\t\t\t\t\t\t\t `ss_billing_mi` = '',\r\n\t\t\t\t\t\t\t `ss_billing_lastname` = '" . quote_smart($this->transInfo['surname']) . "',\r\n\t\t\t\t\t\t\t `ss_billing_address` = '" . quote_smart($this->transInfo['address']) . "',\r\n\t\t\t\t\t\t\t `ss_billing_address2` = '',\r\n\t\t\t\t\t\t\t `ss_billing_city` = '" . quote_smart($this->transInfo['city']) . "',\r\n\t\t\t\t\t\t\t `ss_billing_state` = '" . quote_smart($this->transInfo['state']) . "',\r\n\t\t\t\t\t\t\t `ss_billing_country` = '" . quote_smart($this->transInfo['country']) . "',\r\n\t\t\t\t\t\t\t `ss_billing_zipcode` = '" . quote_smart($this->transInfo['zipcode']) . "',\r\n\t\t\t\t\t\t\t `ss_billing_last_ip` = '" . quote_smart($this->transInfo['ipaddress']) . "',\r\n\t\t\t\t\t\t\t `ss_billing_type` = '" . $ss_billing_type . "',\r\n\t\t\t\t\t\t\t `ss_billing_card` = '" . transaction_class::etelEncSalted($this->transInfo['CCnumber'], $salt) . "',\r\n\t\t\t\t\t\t\t `ss_billing_exp` = '" . ($this->transInfo['checkorcard'] == 'H' ? date("Y-m-d", strtotime($expYear . "-" . $expMonth . "-01")) : "") . "',\r\n\t\t\t\t\t\t\t `ss_billing_cvv2` = '" . transaction_class::etelEncSalted($this->transInfo['cvv'], $salt) . "',\r\n\t\t\t\t\t\t\t `ss_billing_check_account` = '" . transaction_class::etelEncSalted($this->transInfo['bankaccountnumber'], $salt) . "',\r\n\t\t\t\t\t\t\t `ss_billing_check_routing` = '" . transaction_class::etelEncSalted($this->transInfo['bankroutingcode'], $salt) . "',\r\n\t\t\t\t\t\t\t `ss_salt` = '{$salt}',\r\n\t\t\t\t\t\t\t `ss_cust_email` = '" . quote_smart($this->transInfo['email']) . "',\r\n\t\t\t\t\t\t\t `ss_cust_phone` = '" . quote_smart($this->transInfo['phonenumber']) . "',\r\n\t\t\t\t\t\t\t `ss_cust_username` = '" . quote_smart($this->transInfo['td_username']) . "',\r\n\t\t\t\t\t\t\t `ss_cust_password` = '" . quote_smart($this->transInfo['td_password']) . "',\r\n\t\t\t\t\t\t\t `ss_rebill_ID` = '" . quote_smart($this->transInfo['td_rebillingID']) . "',\r\n\t\t\t\t\t\t\t `ss_rebill_next_date` = '" . $this->transInfo['ss_rebill_next_date'] . "',\r\n\t\t\t\t\t\t\t `ss_rebill_amount` = '" . $this->transInfo['td_recur_charge'] . "',\r\n\t\t\t\t\t\t\t `ss_rebill_status` = '" . $this->transInfo['ss_rebill_status'] . "',\r\n\t\t\t\t\t\t\t `ss_rebill_status_text` = '" . $this->transInfo['ss_rebill_status_text'] . "',\r\n\t\t\t\t\t\t\t `ss_rebill_attempts` = 0,\r\n\t\t\t\t\t\t\t `ss_rebill_count` = 0,\r\n\t\t\t\t\t\t\t `ss_account_status` = '" . $this->transInfo['ss_account_status'] . "',\r\n\t\t\t\t\t\t\t `ss_account_start_date` = now(),\r\n\t\t\t\t\t\t\t `ss_account_notes` = CONCAT(NOW(), ': Transaction (" . $this->transInfo['reference_number'] . ") Approved. Creating Subscription...\nNext Rebill Date: " . $this->transInfo['td_recur_next_date'] . "'),\r\n\t\t\t\t\t\t\t `ss_account_expire_date` = '" . $this->transInfo['ss_account_expire_date'] . "',\r\n\t\t\t\t\t\t\t `ss_transaction_id` = '" . $this->transInfo['transactionId'] . "',\r\n\t\t\t\t\t\t\t `ss_productdescription` = '" . quote_smart($this->transInfo['productdescription']) . "',\r\n\t\t\t\t\t\t\t `ss_site_ID` = '" . $this->transInfo['td_site_ID'] . "',\r\n\t\t\t\t\t\t\t `ss_user_id` ='" . $this->transInfo['userId'] . "',\r\n\t\t\t\t\t\t\t `ss_bank_id` ='" . $this->transInfo['bank_id'] . "'\r\n\t\t\t\t\t\t\t {$sql_where} \r\n\t\t\t\t\t\t\t"; sql_query_write($subscription) or dieLog(mysql_error()); $this->transInfo['td_ss_ID'] = mysql_insert_id(); return $this->transInfo; }