<?php
require_once("alipay_config.php");

$parameter = array(
"service" => "create_direct_pay_by_user", //交易类型，必填实物交易＝trade_create_by_buyer（需要填写物流） 虚拟物品交易＝create_digital_goods_trade_p 捐赠＝create_donate_trade_p 快速付款=create_direct_pay_by_user
"partner" =>$partner,                                               //合作商户号
"return_url" =>$return_url,  //同步返回
"notify_url" =>$notify_url,  //异步返回
"_input_charset" => $_input_charset,                                //字符集，默认为GBK
"subject" => $array['subject'],                           //商品名称，必填
"body" => $array['body'],                              //商品描述，必填
"out_trade_no" => $array['predeposit_r_id'],          //商品外部交易号，必填,每次测试都须修改
//"price" => $array['online_amount'],                                 //商品单价，必填
"total_fee" => $array['online_amount'],                                 //交易金额
"discount"=>"",                                    //折扣        
"payment_type"=> 2,                               // 商品支付类型 1 ＝商品购买 2＝服务购买 3＝网络拍卖 4＝捐赠 5＝邮费补偿 6＝奖金
"quantity" => 1,                                 //商品数量，必填
"show_url" => $array['url'],            		//商品相关网站
"logistics_type"=>'VIRTUAL',                  //物流类型：VIRTUAL＝虚拟物品 POST＝平邮 EMS＝EMS EXPRESS＝其他快递公司
"logistics_fee"=> 0,                          //物流费用
"logistics_payment"=>'SELLER_PAY',                //物流支付类型: SELLER_PAY=卖家支付 BUYER_PAY=买家支付 BUYER_PAY_AFTER_RECEIVE=货到付款
"seller_email" => $array['email'],                //卖家邮箱，必填
);

//print_r($array);exit;
//根据交易流水号产生链接
if($array['payment_trade'] != ''){
	$link = "https://www.alipay.com/trade/query_trade_detail.htm?trade_no=".$array['payment_trade']."&dt_from=";
}else{
	require_once("alipay_service.php");
	$alipay = new alipay_service($parameter,$security_code,$sign_type);
	$link=$alipay->create_url();
}
header("location: $link");exit;
?>

