Home > php教程 > php手册 > ECSHOP 支付宝无商家支付

ECSHOP 支付宝无商家支付

WBOY
Release: 2016-06-06 19:32:30
Original
1374 people have browsed it

此功能用于ECSHOP无支付宝商家账号支付、并实现支付结果回写ECSHOP。此功能的目的是让那些无法申请支付宝商家支付接口的用户,可以通过支付宝进行收款,从而绕过支付宝商家认证。功能特点如下,1、抓取远程邮箱的支付宝交易记录。2、提取支付宝交易记录中的交

此功能用于ECSHOP无支付宝商家账号支付、并实现支付结果回写ECSHOP。此功能的目的是让那些无法申请支付宝商家支付接口的用户,可以通过支付宝进行收款,从而绕过支付宝商家认证。功能特点如下,1、抓取远程邮箱的支付宝交易记录。2、提取支付宝交易记录中的交易信息。3、将此交易信息匹配ECSHOP数据库中已存在订单,若匹配成功则直接修改订单状态、并且更新账户余额状态。最终完成无支付宝商家支付。
卓流应用网(http://360cd.cn/) 专业的ECMALL、ECSHOP二次开发及服务
<?php
header("Content-type:text/html;charset=utf-8");
//error_reporting(0);
define('IN_ECS', true);

require(dirname(dirname(__FILE__)) . '/includes/init.php');
//require(dirname(dirname(__FILE__)) . '/includes/lib_common.php');
global $db,$ecs;

include("mail.php");
include(ROOT_PATH."data/zconfig.php");

$user=$recive_info['email'];
$pwd=$recive_info['pwd'];
$pop=$recive_info['host'];
$port=$recive_info['port'];

$obj = new receiveMail($user,$pwd,$user,$pop,'pop3',$port,false);
$obj->connect();         //If connection fails give error message and exit
$tot = $obj->getTotalMails(); //Total Mails in Inbox Return integer value
$mail_list=array();
for($i=$tot;$i>0;$i--)
{

	    $head=$obj->getHeaders($i);  
		if($head['from']=='service@mail.alipay.com' )
		{
		  $mail_list[]= getInfo($obj->getBody($i));  
		}
	
}
$obj->close_mailbox();   
$result= updateOrder($mail_list);
if($result)
{
echo "<a href='/mail/index.php?order=".$_GET['order']."'>支付未完成点此查看</a>";
}else{
echo "<a href='/user.php'>支付成功点此跳转</a>";
}

function updateOrder($mail_list)
{
  global $db,$ecs;
  if(is_array($mail_list) && count($mail_list))
  {
    foreach($mail_list as $mail)
	{
	 if(!empty($mail['order']) && !empty($mail['price']))
	 {
	    $order=str_replace(":",'',$mail['order']);
		
	    $account = array();
        $account = $db->getRow("SELECT * FROM " .$ecs->table('user_account'). " WHERE out_sn = '".trim($order)."'");
		if(is_array($account) && count($account))
		{
		  $price=str_replace("元",'',$mail['price']);
		   $price=str_replace(":",'',$price);
		  if(floatval($price)==floatval($account['amount']) && $account['is_paid']==0 )
		  {
		    update_user_account($account['id'], $account['amount'], '系统自动充值', 1);
		    log_account_change($account['user_id'], $account['amount'], 0, 0, 0, $_LANG['surplus_type_1'], ACT_DRAWING);
             return 1;
		  }else{
		    return 0;
		  }
		}else{
		  return 0;
		}	
		
	 }	
	}
	
  }
  return 0;
 
}



function update_user_account($id, $amount, $admin_note, $is_paid)
{
    $sql = "UPDATE " .$GLOBALS['ecs']->table('user_account'). " SET ".
           "admin_user  = '$_SESSION[admin_name]', ".
           "amount      = '$amount', ".
           "paid_time   = '".gmtime()."', ".
           "admin_note  = '$admin_note', ".
           "is_paid     = '$is_paid' WHERE id = '$id'";
    return $GLOBALS['db']->query($sql);
}

function getInfo($content)
{
       $content=strip_tags($content);
		$name_start=stripos($content,'商品名称');		
		$name_end=stripos($content,'交易对方');		
		$price_start=stripos($content,'购买总价');		
		$price_end=stripos($content,'卖家折扣');
		if($name_start && $name_end && $price_end && $price_start)
		{
		   $name_len=$name_end-($name_start+12);
		   $price_len=$price_end-($price_start+12);
		
			$name=substr($content,$name_start+12,$name_len);
			$price=substr($content,$price_start+12,$price_len);
		}

	return array('order'=>$name,'price'=>$price);

}
?>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template