OSB enhancements to date
This commit is contained in:
@@ -124,6 +124,7 @@ class plg_chout_PAYPAL extends plg_chout_base_PAYPAL {
|
||||
# Read the post from PayPal system and add 'cmd'
|
||||
global $_POST,$C_debug;
|
||||
|
||||
$ret = array();
|
||||
$req = 'cmd=_notify-validate';
|
||||
|
||||
foreach ($_POST as $key => $value) {
|
||||
@@ -131,30 +132,33 @@ class plg_chout_PAYPAL extends plg_chout_base_PAYPAL {
|
||||
$req .= sprintf('&%s=%s',$key,$value);
|
||||
}
|
||||
|
||||
$C_debug->error(__FILE__,__METHOD__,sprintf("%s: %s - Invoice: %s\r\n%s",$this->name,$_POST['txn_type'],$_POST['invoice'],$req));
|
||||
|
||||
# Post back to PayPal system to validate
|
||||
$header = "POST /cgi-bin/webscr HTTP/1.0\r\n";
|
||||
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
|
||||
$header .= sprintf("Content-Length: %s\r\n\r\n",strlen($req));
|
||||
|
||||
$fp = fsockopen($this->getLocation(false,true),80,$errno,$errstr,30);
|
||||
|
||||
# Needed for validation
|
||||
$ret['invoice_id'] = $_POST['invoice'];
|
||||
$ret['transaction_id'] = $_POST['txn_id'];
|
||||
$ret['currency'] = $_POST['mc_currency'];
|
||||
|
||||
if (! empty($_POST['mc_gross']))
|
||||
$ret['amount'] = $_POST['mc_gross'];
|
||||
else
|
||||
$ret['amount'] = $_POST['payment_gross'];
|
||||
|
||||
# Validate
|
||||
$fp = fsockopen($this->getLocation(false,true),80,$errno,$errstr,30);
|
||||
if (! $fp) {
|
||||
$C_debug->error(__FILE__,__METHOD__,sprintf('Unable to connect to %s',$this->getLocation(false,true)));
|
||||
|
||||
} else {
|
||||
$ret['invoice_id'] = $_POST['invoice'];
|
||||
$ret['transaction_id'] = $_POST['txn_id'];
|
||||
$ret['currency'] = $_POST['mc_currency'];
|
||||
|
||||
if (! empty($_POST['mc_gross']))
|
||||
$ret['amount'] = $_POST['mc_gross'];
|
||||
else
|
||||
$ret['amount'] = $_POST['payment_gross'];
|
||||
|
||||
# Get a list of items paid
|
||||
$i = array('item_number','item_name','mc_gross_');
|
||||
foreach ($_POST as $k => $v)
|
||||
foreach ($i as $j)
|
||||
if (preg_match("/^{$j}([0-9]+)/",$k,$m))
|
||||
$ret['items'][$m[1]][$j] = $v;
|
||||
|
||||
fputs($fp,$header.$req);
|
||||
|
||||
while (! feof($fp)) {
|
||||
@@ -174,10 +178,11 @@ class plg_chout_PAYPAL extends plg_chout_base_PAYPAL {
|
||||
case 'VERIFIED':
|
||||
# Get the payment status
|
||||
$ret['status'] = true;
|
||||
switch($_POST['txn_type']) {
|
||||
case 'cart': $ret['status'] = true; break;
|
||||
default: $ret['status'] = false; break;
|
||||
}
|
||||
if (isset($_POST['txn_type']))
|
||||
switch($_POST['txn_type']) {
|
||||
case 'cart': $ret['status'] = true; break;
|
||||
default: $ret['status'] = false; break;
|
||||
}
|
||||
|
||||
if ($ret['status'] != false) {
|
||||
switch($_POST['payment_status']) {
|
||||
@@ -189,11 +194,13 @@ class plg_chout_PAYPAL extends plg_chout_base_PAYPAL {
|
||||
|
||||
# Get the processor details
|
||||
$this->getDetailsName($this->name);
|
||||
$ret['checkout_id'] = $this->checkout_id;
|
||||
$cfg = unserialize($this->flds['plugin_data']);
|
||||
if ($_POST['receiver_email'] == $cfg['email']) {
|
||||
include_once(PATH_MODULES.'checkout/checkout.inc.php');
|
||||
$checkout = new checkout;
|
||||
$checkout->postback($ret);
|
||||
$checkout = new checkout($this->checkout_id);
|
||||
$C_debug->error(__FILE__,__METHOD__,sprintf("Calling checkout %s: with: %s",$this->name,print_r($ret,true)));
|
||||
$checkout->postback($ret,$this->name);
|
||||
}
|
||||
|
||||
fclose($fp);
|
||||
@@ -222,13 +229,19 @@ class plg_chout_PAYPAL extends plg_chout_base_PAYPAL {
|
||||
|
||||
# Postback Function
|
||||
if (empty($VAR) && empty($VAR['do'])) {
|
||||
include_once('../../config.inc.php');
|
||||
require_once('../../config.inc.php');
|
||||
require_once(PATH_ADODB.'adodb.inc.php');
|
||||
require_once(PATH_CORE.'database.inc.php');
|
||||
require_once(PATH_CORE.'setup.inc.php');
|
||||
require_once(PATH_CORE.'list.inc.php');
|
||||
require_once(PATH_CORE.'translate.inc.php');
|
||||
require_once(PATH_MODULES.'module.inc.php');
|
||||
|
||||
$C_debug = new CORE_debugger;
|
||||
$C_translate = new CORE_translate;
|
||||
$C_db = &DB();
|
||||
$C_setup = new CORE_setup;
|
||||
$C_list = new CORE_list;
|
||||
$plg = new plg_chout_PAYPAL;
|
||||
$plg->postback();
|
||||
}
|
||||
|
@@ -40,7 +40,7 @@ abstract class plg_chout_base_PAYPAL extends base_checkout_plugin {
|
||||
$this->success_url = URL.'?_page=invoice:thankyou&_next_page=invoice:user_view&id=';
|
||||
$this->decline_url = URL.'?_page=invoice:checkout_multiple&id=';
|
||||
} else {
|
||||
$this->success_url = URL.'?_page=invoice:thankyou&_next_page=account:account&id=';
|
||||
$this->success_url = URL.'?_page=invoice:thankyou&_next_page=invoice:user_view&id=';
|
||||
$this->decline_url = URL.'?_page=invoice:user_view&id=';
|
||||
}
|
||||
|
||||
|
@@ -122,6 +122,12 @@ that will be used to process all recurring charges... this should be a gateway
|
||||
'desc' => '<b>Step 10:</b> Import the Invoices Items',
|
||||
'depn' => array('invoices')
|
||||
));
|
||||
|
||||
array_push($this->actions,array(
|
||||
'name' => 'payments',
|
||||
'desc' => '<b>Step 11:</b> Import the Payments',
|
||||
'depn' => array('invoices')
|
||||
));
|
||||
}
|
||||
|
||||
protected function pre_services() {
|
||||
@@ -443,6 +449,7 @@ that will be used to process all recurring charges... this should be a gateway
|
||||
foreach ($map as $a => $b)
|
||||
$update[$a] = $rs->fields[$b];
|
||||
|
||||
$update['date_orig'] = time();
|
||||
$update['date_last'] = time();
|
||||
$update['language_id'] = DEFAULT_LANGUAGE;
|
||||
# @todo Work out currency based on country address
|
||||
@@ -1099,5 +1106,124 @@ FROM tblhosting,tblproducts where tblhosting.packageid=tblproducts.id';
|
||||
printf("<script type='text/javascript' language=javascript>setTimeout('document.location=\'?_page=core:blank&offset=%s&action=%s&plugin=%s&do[]=import:do_action\'', 1200);</script>",
|
||||
$VAR['offset']+$this->select_limit,$VAR['action'],$VAR['plugin']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Payments
|
||||
*/
|
||||
protected function payments() {
|
||||
global $VAR,$C_debug;
|
||||
|
||||
# Connect to the remote DB
|
||||
$dbr = &NewADOConnection($this->type);
|
||||
$dbr->Connect($this->host,$this->user,$this->pass,$this->db);
|
||||
|
||||
# Determine the offset for the account
|
||||
if (empty($VAR['offset']))
|
||||
$VAR['offset'] = 0;
|
||||
|
||||
$offset = sprintf('%s,%s',$VAR['offset'],$this->select_limit);
|
||||
$remote_table = 'tblaccounts';
|
||||
$ab_table = 'payment';
|
||||
|
||||
# Select
|
||||
$sql = sprintf('SELECT * FROM %s',$remote_table);
|
||||
$rs = $dbr->SelectLimit($sql,$this->select_limit,$offset);
|
||||
|
||||
if ($rs === false) {
|
||||
$C_debug->alert(sprintf('Query to the table "%s" failed!',$remote_table));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($rs->RecordCount() == 0) {
|
||||
$C_debug->alert('No more records to process!');
|
||||
printf("<script type='text/javascript' language=javascript>setTimeout('document.location=\'?_page=import:import&plugin=%s\'',1500);</script>",$VAR['plugin']);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
# Load Checkout Plugins
|
||||
$db = &DB();
|
||||
$imprs = $db->Execute(sqlSelect($db,'checkout','id,checkout_plugin',''));
|
||||
while (! $imprs->EOF) {
|
||||
$co[$imprs->fields['checkout_plugin']] = $imprs->fields['id'];
|
||||
$imprs->MoveNext();
|
||||
}
|
||||
|
||||
# Load Accounts Imported
|
||||
$imprs = $db->Execute(sqlSelect($db,'import','ab_id,remote_id',sprintf('plugin=::%s:: AND action=::%s:: AND remote_table=::%s::',$this->plugin,'accounts','tblclients')));
|
||||
while (! $imprs->EOF) {
|
||||
$account[$imprs->fields['remote_id']] = $imprs->fields['ab_id'];
|
||||
$imprs->MoveNext();
|
||||
}
|
||||
|
||||
$msg = sprintf('Processing %s Records...<br/>',$rs->RecordCount());
|
||||
|
||||
# If there is a map file, open it
|
||||
$pmap = $this->read_map();
|
||||
|
||||
# Table mapping
|
||||
$map = array();
|
||||
$map['notes'] = 'description';
|
||||
$map['total_amt'] = 'amountin';
|
||||
$map['fees_amt'] = 'fees';
|
||||
|
||||
# Loop through each remote item
|
||||
while (! $rs->EOF) {
|
||||
$msg .= sprintf('<br/>Processing : %s...',$rs->fields['invoiceid']);
|
||||
|
||||
# Start a new transaction for the insert:
|
||||
$db = &DB();
|
||||
$db->StartTrans();
|
||||
|
||||
$update = array();
|
||||
foreach ($map as $a => $b)
|
||||
$update[$a] = $rs->fields[$b];
|
||||
|
||||
$update['account_id'] = $account[$rs->fields['userid']*1];
|
||||
$update['checkout_plugin_id'] = $account[$rs->fields['userid']*1];
|
||||
$update['date_payment'] = strtotime($rs->fields['date']);
|
||||
$update['date_orig'] = strtotime($rs->fields['date']);
|
||||
if ($rs->fields['transid'])
|
||||
$update['checkout_plugin_data'] = serialize(array('transid'=>$rs->fields['transid']));
|
||||
# Get the fixed items in the map table.
|
||||
if (isset($pmap[$ab_table][$rs->fields['gateway']])) {
|
||||
foreach ($pmap[$ab_table][$rs->fields['gateway']] as $field => $value) {
|
||||
if (isset($co[$value]))
|
||||
$update[$field] = $co[$value];
|
||||
else {
|
||||
$update[$field] = sprintf('NOMAP-%s',$rs->fields['gateway']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Import the item
|
||||
$db->Execute($r=sqlInsert($db,$ab_table,$update));
|
||||
$id = $db->Execute($q=sqlSelect($db,$ab_table,'id',$update,'','0,1'));
|
||||
|
||||
# Insert the import record
|
||||
$this->import_transaction($this->plugin,$VAR['action'],$ab_table,$id->fields['id'],$remote_table,$rs->fields['id'],$db);
|
||||
|
||||
$update = array();
|
||||
$update['date_orig'] = strtotime($rs->fields['date']);
|
||||
$update['payment_id'] = $id->fields['id'];
|
||||
$update['invoice_id'] = $rs->fields['invoiceid'];
|
||||
$update['alloc_amt'] = $rs->fields['amountin'];
|
||||
|
||||
$db->Execute($r=sqlInsert($db,'payment_item',$update));
|
||||
$pi = $db->Execute($q=sqlSelect($db,'payment_item','id',$update,'','0,1'));
|
||||
|
||||
$this->import_transaction($this->plugin,$VAR['action'],'payment_item',$pi->fields['id'],'',null,$db);
|
||||
|
||||
# Complete the transaction
|
||||
$db->CompleteTrans();
|
||||
$rs->MoveNext();
|
||||
}
|
||||
|
||||
$C_debug->alert($msg);
|
||||
|
||||
printf("<script type='text/javascript' language=javascript>setTimeout('document.location=\'?_page=core:blank&offset=%s&action=%s&plugin=%s&do[]=import:do_action\'', 1200);</script>",
|
||||
$VAR['offset']+$this->select_limit,$VAR['action'],$VAR['plugin']);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
28
plugins/product/ADSL.php
Normal file
28
plugins/product/ADSL.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* osBilling - Open Billing Software
|
||||
*
|
||||
* Originally authored by Deon George
|
||||
*
|
||||
* @author Deon George <deonATleenooksDOTnet>
|
||||
* @copyright 2009 Deon George
|
||||
* @link http://osb.leenooks.net
|
||||
* @package osBilling
|
||||
* @subpackage Modules:ADSL
|
||||
*/
|
||||
|
||||
require_once PATH_MODULES.'product/base_product_plugin.inc.php';
|
||||
|
||||
/**
|
||||
* This class provides the ability to define ADSL Supplier Products.
|
||||
*
|
||||
* @package osBilling
|
||||
* @subpackage Modules:ADSL
|
||||
*/
|
||||
class plgn_prov_ADSL extends base_product_plugin {
|
||||
# Plugin Name
|
||||
protected $name = 'ADSL';
|
||||
# If this plugin provisions remote services
|
||||
public $remote_based = false;
|
||||
}
|
||||
?>
|
Reference in New Issue
Block a user