用于防钓鱼,调用接口query_timestamp来获取时间戳的处理函数
注意:该功能PHP5环境及以上支持,因此必须服务器、本地电脑中装有支持DOMDocument、SSL的PHP配置环境。建议本地调试时使用PHP开发软件
return 时间戳字符串
public query_timestamp ( ) |
private function creditpay ($order, $good, $orderPrice, $bank) { $alipay_config = $this->payConfig(); $payment_type = 1; $notify_url = "http://www.51linpai.com/order/payed"; //页面跳转同步通知页面路径 $return_url = "http://www.51linpai.com/order/payed"; if ($this->debug) { $return_url = "http://www.51linpai.com:8000/order/payed"; } else { $return_url = "http://www.51linpai.com/order/payed"; } //商户网站订单系统中唯一订单号 $out_trade_no = $order->code; //订单名称 $subject = $good->name . ' * ' . $order->num; //订单金额 $total_fee = 0.1;// $orderPrice->final_price; //订单描述 $body = '测试订单描述'; //商品展示地址 $show_url = "http://www.51linpai.com/goods?gid={$good->id}"; //支付方式 $paymethod = "bankPay"; //默认网银 $defaultbank = $bank; //客户端ip地址 $exter_invoke_ip = $_SERVER['REMOTE_ADDR']; $parameter = array( "service" => "create_direct_pay_by_user", "partner" => trim($alipay_config['partner']), "seller_email" => trim($alipay_config['seller_email']), "payment_type" => $payment_type, "notify_url" => $notify_url, "return_url" => $return_url, "out_trade_no" => $out_trade_no, "subject" => $subject, "total_fee" => $total_fee, "body" => $body, "show_url" => $show_url, "paymethod" => $paymethod, "defaultbank" => $defaultbank, "exter_invoke_ip" => $exter_invoke_ip, "_input_charset" => trim(strtolower($alipay_config['input_charset'])) ); $alipaySubmit = new \AlipaySubmit($alipay_config); $parameter['anti_phishing_key'] = $alipaySubmit->query_timestamp(); $html_text = $alipaySubmit->buildRequestForm($parameter,"get", "<h2>正在跳转到支付页面...</h2>"); return $html_text; }
$return_url = $livsnsurl . "/livsns/api/payments/payments/return_url.php"; //需http://格式的完整路径,不能加?id=123这类自定义参数,不能写成http://localhost/ //卖家支付宝帐户 $seller_email = $WIDseller_email; //必填 //商户订单号 $out_trade_no = $WIDout_trade_no; //商户网站订单系统中唯一订单号,必填 //订单名称 $subject = $WIDsubject; //必填 //付款金额 $total_fee = $WIDtotal_fee; //必填 //订单描述 $body = $WIDbody; //商品展示地址 $show_url = $WIDshow_url; //需以http://开头的完整路径,例如:http://www.xxx.com/myorder.html //防钓鱼时间戳 $anti_phishing_key = $alipaySubmit->query_timestamp(); //若要使用请调用类文件submit中的query_timestamp函数 //客户端的IP地址 $exter_invoke_ip = $exter_invoke_ip; //非局域网的外网IP地址,如:221.0.0.1 /************************************************************/ //构造要请求的参数数组,无需改动 $parameter = array("service" => "create_direct_pay_by_user", "partner" => trim($alipay_config['partner']), "payment_type" => $payment_type, "notify_url" => $notify_url, "return_url" => $return_url, "seller_email" => $seller_email, "out_trade_no" => $out_trade_no, "subject" => $subject, "total_fee" => $total_fee, "body" => $body, "show_url" => $show_url, "anti_phishing_key" => $anti_phishing_key, "exter_invoke_ip" => $exter_invoke_ip, "_input_charset" => trim(strtolower($alipay_config['input_charset']))); //建立请求 $html_text = $alipaySubmit->buildRequestForm($parameter, "get", "确认"); echo $html_text;