
2.支持因价格调整,多次付款同步发货
3.测试时确保你使用的浏览器没有禁止d窗,因为同步发货是从新窗口打开。
特别提示:很多朋友反映提示错误无法使用,个人分析是支付宝接口对空间有一定
要求:PHP配置环境支持远程XML解析和SSL加密
一、在数据库order_info中添加trade_no 字段
二、修改 admin/order.php 文件
1.查找以下代码
$smarty->assign('action_list', $act_list)
/* 模板赋值 */
$smarty->assign('delivery_order', $delivery_order)
$smarty->assign('goods_list', $goods_list)
$smarty->assign('delivery_id', $delivery_id)// 发货单id
复制代码
2.代码之上添加以下代码
/*判断支付方式是否支付宝*/
$alipay= false
$order = order_info($delivery_order['order_id']) //根据订单ID查询订单信息,返回数组$order
$payment = payment_info($order['pay_id']) //取得支付方式信息
if($payment['pay_code'] == "alipay" &&$delivery_order['status'] == 2 &&!empty($order['trade_no']))
{
$alipay= true
}
$smarty->assign('alipay', $alipay)
复制代码
三、 附件代码直接覆盖 OK 测试一下吧!
标题上加了Ecshop,其实也只是个噱头,增加搜索量而已,本文写的内容并不局限于Ecshop上。API接口,通常是供移动APP端调用的,制作api的前提是必须对业务逻辑和代码逻辑十分熟悉了,不然可能会事倍功半,甚至是中途夭折。首先制作的语言仍旧是PHP,API的返回数据用的是JSON,没有用XML,为什么要用JSON而不用XML,这个问题,懂的人自然懂。先来创建JSON的model。
// 描述:内部使用API JSON类
// 名称:json
// 作者:tiandi
// 版本:0.0.1
// 生成时间:2015.4.23
// 修订时间:2015.4.23
class json {
// status : string : 状态码
// msg : string : 说明
// content: array : 内容
var $status
var $msg
var $content
function json(){
}
function set_status($status) {
$this->status = $status
}
function set_msg($msg) {
$this->msg = $msg
}
function set_content($content) {
$this->content = $content
}
function create_json() {
$arr = array()
$arr['api_status'] = $this->status
$arr['api_msg'] = $this->msg
if($arr['api_status'] == '0') {
array_unshift($this->content,$arr)
echo urldecode(json_encode($this->content))
}
else
{
echo urldecode(json_encode($arr))
}
}
function check_env($request){
//check appid
if(!isset($request['appid'])) {
$this->set_status("99")
$this->set_msg("Need appid.")
echo $this->create_json()
exit
}
elseif(!$this->compare($request['appid'],MY_APPID)) {
$this->set_status("98")
$this->set_msg("Appid is invalid.")
echo $this->create_json()
exit
}
//check timestamp
elseif(!isset($request['timestamp'])) {
$this->set_status("97")
$this->set_msg("Need timestamp.")
echo $this->create_json()
exit
}
//check sign
elseif(!isset($request['sign'])) {
$this->set_status("96")
$this->set_msg("Need sign.")
echo $this->create_json()
exit
}
elseif(!$this->compare($request['sign'],$this->create_sign($request))) {
$this->set_status("95")
$this->set_msg("Sign is invalid.")
echo $this->create_json()
exit
}
}
function compare($str1,$str2) {
if($str1 == "'".$str2."'" || $str1 == $str2 || "'".$str1."'" == $str2)
return true
else
return false
}
/************************** 生成签名 ***************************/
function create_sign($request) {
//签名方法
}
然后用下面方法生成json接口数据,$arr为数据库查询返回的数组。
$json->set_status("0")
$json->set_msg("success")
$json->set_content($arr)
$json->create_json()
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)