搜索
首页php教程php手册ECSHOP 支付宝无商家支付

此功能用于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);

}
?>
声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn

热AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover

AI Clothes Remover

用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool

Undress AI Tool

免费脱衣服图片

Clothoff.io

Clothoff.io

AI脱衣机

Video Face Swap

Video Face Swap

使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热门文章

热工具

SublimeText3 Mac版

SublimeText3 Mac版

神级代码编辑软件(SublimeText3)

禅工作室 13.0.1

禅工作室 13.0.1

功能强大的PHP集成开发环境

安全考试浏览器

安全考试浏览器

Safe Exam Browser是一个安全的浏览器环境,用于安全地进行在线考试。该软件将任何计算机变成一个安全的工作站。它控制对任何实用工具的访问,并防止学生使用未经授权的资源。

SublimeText3 英文版

SublimeText3 英文版

推荐:为Win版本,支持代码提示!

PhpStorm Mac 版本

PhpStorm Mac 版本

最新(2018.2.1 )专业的PHP集成开发工具