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=';
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user