demon |
Moderator |

 |
|
Joined: Sep 22, 2010 |
Posts: 485 |
|
|
|
 |
 |
 |
|
Code: | <?php
if(!defined('DATALIFEENGINE') or !defined('BUYSYSTEM'))
{
die("Hacking attempt!");
}
$mod_info = array (
'idname'=>'paypal',
'name'=>'PayPal',
);
$mod_return = false;
if ( $mod_action == "init") {
$mod_return = $mod_info;
}else
if ( $mod_action == "config") {
$mod_return['name'] = $mod_info['name'];
$mod_return['content'] = "";
global $buy_config_payments,$user_group_array,$buy_payments_array;
$type = $mod_info['idname'];
if ($buy_config_payments and (array_key_exists($type,$buy_config_payments) and is_array($buy_config_payments[$type]))) {
$main_config = $buy_config_payments[$type];
}else {
$main_config = array(
'enable'=>"0",
'desc'=>$mod_info['name'],
'email'=>"my@email.ru",
'cur'=>"usd",
);
}
$mod_return['content'] .= "<tr><td colspan=\"2\" height=\"30\">
<b>PayPal</b> [ <a href=\"https://paypal.com/\" target=\"_blank\">Ñéò</a> ]
</td></tr><tr><td colspan=\"2\"><div class=\"unterline\"></div></td></tr>";
$mod_return['content'] .=showRow("Ðáîò ñèñòåìû","Ïðîèçâîäèòü îïëòó ÷åðåç ýòó ñèñòåìó",makeDropDown(array("1"=>"Âêë.","0"=>"Âûêë."),"buy_config_payments[{$type}][enable]","{$main_config['enable']}"));
$mod_return['content'] .=showRow("Íèìåíîâíèå","Íèìåíîâíèå ñèñòåìû","<input class=edit type=text style=\"text-align: center;\" name='buy_config_payments[{$type}][desc]' value='{$main_config['desc']}' size=40>");
$mod_return['content'] .=showRow("Ëîãîòèï","Ëîãîòèï ñèñòåìû","<input class=edit type=text style=\"text-align: center;\" name='buy_config_payments[{$type}][icon]' value='{$main_config['icon']}' size=40>");
$mod_return['content'] .=showRow("Email ïðîäâö","","<input class=edit type=text style=\"text-align: center;\" name='buy_config_payments[{$type}][email]' value='{$main_config['email']}' size=40>");
$mod_return['content'] .=showRow("Ñêèäê/Íöåíê","Íöåíê èëè ñêèäê äëÿ öåíû îïëòû â % îò ñòîèìîñòè. Äííûì ïðìåòðîì ìîæíî êîìïåíñèðîâòü % ç îïëòó ÷åðåç áèëëèíãè<br /><i>0</i> èëè <i>100</i> - áåç íöåíêè. áîëåå 100 - íöåíê, ìåíåå 100 - ñêèäê","<input class=edit type=text style=\"text-align: center;\" name='buy_config_payments[{$type}][premium]' value='{$main_config['premium']}' size=40>");
$mod_return['content'] .=showRow("Âëþò","Äííûé ïîêçòåëü íåñ¸ò èíôîðìòèâíûé õðêòåð.","<input readonly class=edit type=text style=\"text-align: center;\" name='buy_config_payments[{$type}][cur]' value='{$main_config['cur']}' size=40>");
}else
if ( $mod_action == "class") {
class tpaymentss {
var $_name = 'paypal';
var $cur = 'usd';
var $purse = 0;
var $secret = '';
var $template =
"<form id=\"sendform\" name=\"sendform\" action=\"https://www.paypal.com/cgi-bin/webscr\" method=\"post\" style=\"buy_form\">
<input type=\"hidden\" name=\"cmd\" value=\"_xclick\">
<input type=\"hidden\" name=\"business\" value=\"{purse}\">
<input type=\"hidden\" name=\"item_name\" value=\"{desc}\">
<input type=\"hidden\" name=\"item_number\" value=\"{order_id}\">
<input type=\"hidden\" name=\"amount\" value=\"{summ}\">
<input type=\"hidden\" name=\"no_shipping\" value=\"1\">
<input type=\"hidden\" name=\"return\" value=\"{url_success}\">
<input type=\"hidden\" name=\"cancel_return\" value=\"{url_fail}\">
<input type=\"hidden\" name=\"notify_url\" value=\"{url_result}\">
<input type=\"hidden\" name=\"rm\" value=\"2\">
<input type=\"hidden\" name=\"currency_code\" value=\"USD\">
<input type=\"hidden\" name=\"custom\" value=\"{sign}\">
<input type=\"submit\" value=\"Next\" />
</form>";
function _sign() {
$params = func_get_args();
$prehash = implode("",$params);
return md5($prehash);
}
function _get_currency() {
return $this->cur;
}
function tpaymentss() {
global $buy_config_payments,$config;
$this->purse = $buy_config_payments[$this->_name]['email'];
$this->secret = $buy_config_payments[$this->_name]['secret'];
$this->cur = $buy_config_payments[$this->_name]['cur'];
$this->template = str_replace('{purse}',$this->purse,$this->template);
$this->template = str_replace('{cur}',strtoupper($this->cur),$this->template);
if ($config['allow_alt_url'] == "yes") {
$this->template = str_replace('{url_success}',$config['http_home_url']."buy/paypal/success.html",$this->template);
$this->template = str_replace('{url_fail}',$config['http_home_url']."buy/paypal/fail.html",$this->template);
$this->template = str_replace('{url_result}',$config['http_home_url']."buy/paypal/result.html",$this->template);
}else {
$this->template = str_replace('{url_success}',$config['http_home_url']."index.php?do=buy&act=success&type=paypal",$this->template);
$this->template = str_replace('{url_fail}',$config['http_home_url']."index.php?do=buy&act=fail&type=paypal",$this->template);
$this->template = str_replace('{url_result}',$config['http_home_url']."engine/buy.php?act=result&type=paypal",$this->template);
}
}
function initform($order_id,$summ,$desc) {
global $SYSTEM_TRUE,$config;
$template = $this->template;
$template = str_replace('{order_id}',$order_id,$template);
$template = str_replace('{summ}',$summ,$template);
$template = str_replace('{desc}',$desc,$template);
$sign = $this->_sign($order_id,$summ,DBHOST,DBUSER,DBPASS);
$template = str_replace('{sign}',$sign,$template);
return $template;
}
function result() {
global $_REQUEST;
$result = array(
'order_id'=>intval($_REQUEST["item_number"]),
'order_res'=>intval($_REQUEST["txn_id"]),
'buy_type'=>$this->_name,
'amount'=>floatstr($_REQUEST["mc_gross"]),
'buy_info'=>array (
'first name'=>$_REQUEST["first_name"],
'last name'=>$_REQUEST["last_name"],
'email'=>$_REQUEST["payer_email"],
'payer id'=>$_REQUEST["payer_id"],
'payment type'=>$_REQUEST["payment_type"],
),
'error'=>"",
'result'=>false,
);
if ( function_exists('curl_init') ) {
$postdata = "";
foreach ($_POST as $key=>$value)
$postdata .= $key."=".urlencode(stripslashes($value))."&";
$postdata .= "cmd=_notify-validate";
$curl = curl_init("https://www.paypal.com/cgi-bin/webscr");
curl_setopt ($curl,CURLOPT_HEADER,0);
curl_setopt ($curl,CURLOPT_POST,1);
curl_setopt ($curl,CURLOPT_POSTFIELDS,$postdata);
curl_setopt ($curl,CURLOPT_SSL_VERIFYPEER,0);
curl_setopt ($curl,CURLOPT_RETURNTRANSFER,1);
curl_setopt ($curl,CURLOPT_SSL_VERIFYHOST,1);
$response = curl_exec ($curl);
curl_close ($curl);
}else
$response = "VERIFIED";
if (strcasecmp("VERIFIED",$response)!=0) {
$result['error'] = buy_lang('buypaypal_error_3',array($response));
}else
if ($_REQUEST["txn_type"]!="web_accept")
$result['error'] = buy_lang('buypaypal_error_2',array($_REQUEST['txn_type']));
else
if (strcasecmp("Completed",$_REQUEST["payment_status"])!=0)
$result['error'] = buy_lang('buy_error_status',array( $_REQUEST["pending_reason"].' - '.$_REQUEST["payment_status"] ));
else
if ($_REQUEST["business"]!=$this->purse) {
$result['error'] = buy_lang('buypaypal_error_1',array($_REQUEST['business']));
}else {
$reference = $this->_sign($result['order_id'],$result['amount'],DBHOST,DBUSER,DBPASS);
if (strcasecmp($_REQUEST["custom"],$reference)!=0) {
$result['error'] = buy_lang('buy_error_hash',array($_REQUEST['custom']));
}
}
return $result;
}
function success($fail = false) {
global $_REQUEST;
if (isset($_REQUEST["item_number"]))
return intval($_REQUEST["item_number"]);
else
return false;
}
}
}
;
?> |
|
|