public function submit() { //请求业务参数详细 $req_data = '<direct_trade_create_req><notify_url>' . $this->notify_url . '</notify_url><call_back_url>' . $this->call_back_url . '</call_back_url><seller_account_name>' . $this->seller_email . '</seller_account_name><out_trade_no>' . $this->out_trade_no . '</out_trade_no><subject>' . $this->subject . '</subject><total_fee>' . $this->total_fee . '</total_fee></direct_trade_create_req>'; //必填 //构造要请求的参数数组,无需改动 $para_token = array("service" => "alipay.wap.trade.create.direct", "partner" => trim($this->alipay_config['partner']), "sec_id" => trim($this->alipay_config['sign_type']), "format" => $this->format, "v" => $this->v, "req_id" => $this->req_id, "req_data" => $req_data, "_input_charset" => trim(strtolower($this->alipay_config['input_charset']))); //建立请求 $alipaySubmit = new AlipaySubmit($this->alipay_config); $html_text = $alipaySubmit->buildRequestHttp($para_token); //URLDECODE返回的信息 $html_text = urldecode($html_text); //解析远程模拟提交后返回的信息 $para_html_text = $alipaySubmit->parseResponse($html_text); //获取request_token $request_token = $para_html_text['request_token']; /**************************根据授权码token调用交易接口alipay.wap.auth.authAndExecute**************************/ //业务详细 $req_data = '<auth_and_execute_req><request_token>' . $request_token . '</request_token></auth_and_execute_req>'; //必填 //构造要请求的参数数组,无需改动 $parameter = array("service" => "alipay.wap.auth.authAndExecute", "partner" => trim($this->alipay_config['partner']), "sec_id" => trim($this->alipay_config['sign_type']), "format" => $this->format, "v" => $this->v, "req_id" => $this->req_id, "req_data" => $req_data, "_input_charset" => trim(strtolower($this->alipay_config['input_charset']))); //建立请求 $alipaySubmit = new AlipaySubmit($this->alipay_config); $html_text = $alipaySubmit->buildRequestForm($parameter, 'get', '正在跳转支付页面...'); return '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>支付宝即时到账交易接口接口</title> </head>' . $html_text . ' </body> </html>'; }
public function config($config = null) { $format = "xml"; $req_id = date('Ymdhis'); $merchant_url = ""; $notify_url = $config['NotifyUrl']; $return_url = $config['ReturnUrl']; $seller_email = $config['pay_type_data']['user']['val']; $out_trade_no = $config['code']; $subject = $config['title']; $total_fee = $config['money']; $wapalipay_config_id = trim($config['id']); $wapalipay_config_key = trim($config['key']); $wapalipay_config_input_charset = strtolower('utf-8'); $wapalipay_config_sign_type = strtoupper('MD5'); $wapalipay_config_input_charset = strtolower('utf-8'); $wapalipay_config_cacert = dirname(__FILE__) . DIRECTORY_SEPARATOR . "wapalipay" . DIRECTORY_SEPARATOR . "cacert.pem"; $wapalipay_config_private_key_path = '.' . DIRECTORY_SEPARATOR . 'wapalipay' . DIRECTORY_SEPARATOR . 'rsa_private_key.pem'; $wapalipay_config_ali_public_key_path = '.' . DIRECTORY_SEPARATOR . 'wapalipay' . DIRECTORY_SEPARATOR . 'alipay_public_key.pem'; $wapalipay_config_transport = 'http'; $wapalipay_config = array("partner" => $wapalipay_config_id, "key" => $wapalipay_config_key, "private_key_path" => $wapalipay_config_private_key_path, "ali_public_key_path" => $wapalipay_config_ali_public_key_path, "sign_type" => $wapalipay_config_sign_type, "input_charset" => $wapalipay_config_input_charset, "cacert" => $wapalipay_config_cacert, "transport" => $wapalipay_config_transport); $req_data = '<direct_trade_create_req><notify_url>' . $notify_url . '</notify_url><call_back_url>' . $return_url . '</call_back_url><seller_account_name>' . $seller_email . '</seller_account_name><out_trade_no>' . $out_trade_no . '</out_trade_no><subject>' . $subject . '</subject><total_fee>' . $total_fee . '</total_fee><merchant_url>' . $merchant_url . '</merchant_url></direct_trade_create_req>'; $para_token = array("service" => "alipay.wap.trade.create.direct", "partner" => trim($config['id']), "sec_id" => $wapalipay_config_sign_type, "format" => $format, "v" => "2.0", "req_id" => $req_id, "req_data" => $req_data, "_input_charset" => $wapalipay_config_input_charset); $wapalipaySubmit = new AlipaySubmit($wapalipay_config); $html_text = $wapalipaySubmit->buildRequestHttp($para_token); $html_text = urldecode($html_text); $para_html_text = $wapalipaySubmit->parseResponse($html_text); $request_token = $para_html_text['request_token']; $req_data = '<auth_and_execute_req><request_token>' . $request_token . '</request_token></auth_and_execute_req>'; $parameter = array("service" => "alipay.wap.auth.authAndExecute", "partner" => trim($config['id']), "sec_id" => $wapalipay_config_sign_type, "format" => $format, "v" => "2.0", "req_id" => $req_id, "req_data" => $req_data, "_input_charset" => $wapalipay_config_input_charset); $wapalipaySubmit = new AlipaySubmit($wapalipay_config); $this->url = $wapalipaySubmit->buildRequestForm($parameter, 'get', '确认'); }
public function buildForm($request) { //构造要请求的参数数组,无需改动 $req_id = date('Ymdhis'); $req_data = '<direct_trade_create_req><notify_url>' . $this->notify_url . '</notify_url><call_back_url>' . $this->call_back_url . '</call_back_url><seller_account_name>' . $this->seller_email . '</seller_account_name><out_trade_no>' . $request->out_trade_no . '</out_trade_no><subject>' . $request->subject . '</subject><total_fee>' . $request->total_fee . '</total_fee><merchant_url>' . $this->merchant_url . '</merchant_url></direct_trade_create_req>'; $para_token = array("service" => "alipay.wap.trade.create.direct", "partner" => trim($this->partner), "key" => $this->key, 'sec_id' => $this->sign_type, "format" => $this->format, "v" => $this->v, "req_id" => $req_id, "req_data" => $req_data, "_input_charset" => trim(strtolower($this->_input_charset))); //建立请求 $alipaySubmit = new AlipaySubmit($this->alipay_config); $html_text = $alipaySubmit->buildRequestHttp($para_token); //URLDECODE返回的信息 $html_text = urldecode($html_text); //解析远程模拟提交后返回的信息 $para_html_text = $alipaySubmit->parseResponse($html_text); //获取request_token $request_token = $para_html_text['request_token']; /**************************根据授权码token调用交易接口alipay.wap.auth.authAndExecute**************************/ //业务详细 $req_data = '<auth_and_execute_req><request_token>' . $request_token . '</request_token></auth_and_execute_req>'; //必填 //构造要请求的参数数组,无需改动 $parameter = array("service" => "alipay.wap.auth.authAndExecute", "partner" => trim($this->partner), 'sec_id' => $this->sign_type, "format" => $this->format, "v" => $this->v, "req_id" => $req_id, "req_data" => $req_data, "_input_charset" => trim(strtolower($this->_input_charset))); //建立请求 $alipaySubmit = new AlipaySubmit($this->alipay_config); return $alipaySubmit->buildRequestForm($parameter, "get", "确认"); }
public function pay() { $orderName = htmlentities($_GET['orderName']); $orderid = htmlentities($_GET['orderid']); $from = htmlentities($_GET['from']); if (!$orderName) { $orderName = microtime(); } if (!$orderid) { $orderid = htmlentities($_GET['single_orderid']); } $payHandel = new payHandle($this->token, $from, 'alipay'); $orderInfo = $payHandel->beforePay($orderid); $price = $orderInfo['price']; if ($orderInfo['paid']) { exit('您已经支付过此次订单!'); } if (!$price) { exit('必须有价格才能支付'); } require_once $this->base_path . 'lib/alipay_submit.class.php'; $format = 'xml'; $v = '2.0'; $req_id = date('Ymdhis'); if (($_GET['platform'] || $_GET['pl']) && C('platform_open') && C('platform_alipay_open')) { $query_string_base = 'token=' . $this->token . '|wecha_id=' . $this->wecha_id . '|from=' . $from . '|pl=1'; $query_string_base_notify = 'token||' . $this->token . '|wecha_id||' . $this->wecha_id . '|from||' . $from . '|pl||1'; } else { $query_string_base = 'token=' . $this->token . '|wecha_id=' . $this->wecha_id . '|from=' . $from; $query_string_base_notify = 'token||' . $this->token . '|wecha_id||' . $this->wecha_id . '|from||' . $from; } $notify_url = C('site_url') . '/wxpay/alipaytype_notify_url.php?user_params=' . $query_string_base_notify; $call_back_url = C('site_url') . '/wxpay/alipaytype_call_back_url.php?user_params=' . $query_string_base; $merchant_url = C('site_url') . '/wxpay/alipaytype_break.php'; $out_trade_no = $orderid; $subject = $orderName; $total_fee = $price; $req_data = '<direct_trade_create_req><notify_url>' . $notify_url . '</notify_url><call_back_url>' . $call_back_url . '</call_back_url><seller_account_name>' . trim($this->alipay_config['seller_email']) . '</seller_account_name><out_trade_no>' . $out_trade_no . '</out_trade_no><subject>' . $subject . '</subject><total_fee>' . $total_fee . '</total_fee><merchant_url>' . $merchant_url . '</merchant_url></direct_trade_create_req>'; $para_token = array('service' => 'alipay.wap.trade.create.direct', 'partner' => trim($this->alipay_config['partner']), 'sec_id' => trim($this->alipay_config['sign_type']), 'format' => $format, 'v' => $v, 'req_id' => $req_id, 'req_data' => $req_data, '_input_charset' => trim(strtolower($this->alipay_config['input_charset']))); $alipaySubmit = new AlipaySubmit($this->alipay_config); $html_text = $alipaySubmit->buildRequestHttp($para_token); $html_text = urldecode($html_text); $para_html_text = $alipaySubmit->parseResponse($html_text); $request_token = $para_html_text['request_token']; $req_data = '<auth_and_execute_req><request_token>' . $request_token . '</request_token></auth_and_execute_req>'; $parameter = array('service' => 'alipay.wap.auth.authAndExecute', 'partner' => trim($this->alipay_config['partner']), 'sec_id' => trim($this->alipay_config['sign_type']), 'format' => $format, 'v' => $v, 'req_id' => $req_id, 'req_data' => $req_data, '_input_charset' => trim(strtolower($this->alipay_config['input_charset']))); $alipaySubmit = new AlipaySubmit($this->alipay_config); $html_text = $alipaySubmit->buildRequestForm($parameter, 'get', '确认'); header('Content-type: text/html; charset=utf-8'); echo $html_text; }
/** * 生成支付代码 * @param array $order 订单信息 * @param array $payment 支付方式信息 */ function get_wappay_url($order, $payment) { $order_id = $order['order_id']; $order_desc = $order['order_sn']; $order_sn = $order['order_sn']; $amount = $order['order_amount']; $ecmobile_url = ecmobile_url(); //修正配置文件路径 $this->alipay_config = $this->modify_config_path($this->alipay_config); $format = "xml"; //返回格式 $v = "2.0"; $req_id = date('Ymdhis'); //请求号 $notify_url = $ecmobile_url . "/payment/alipay/wap/notify_url.php"; //服务器异步通知页面路径 $call_back_url = $ecmobile_url . "/payment/wap_callback.php?code=alipay"; //页面跳转同步通知页面路径 $merchant_url = $ecmobile_url . "/payment/wap_merchant.php?code=alipay"; //操作中断返回地址 $seller_email = '*****@*****.**'; //卖家支付宝帐户 $out_trade_no = $order_sn; //商户订单号 $subject = $order_desc; //订单名称 $total_fee = $amount; //付款金额 //请求业务参数详细 $req_data = '<direct_trade_create_req><notify_url>' . $notify_url . '</notify_url><call_back_url>' . $call_back_url . '</call_back_url><seller_account_name>' . $seller_email . '</seller_account_name><out_trade_no>' . $out_trade_no . '</out_trade_no><subject>' . $subject . '</subject><total_fee>' . $total_fee . '</total_fee><merchant_url>' . $merchant_url . '</merchant_url></direct_trade_create_req>'; $para_token = array("service" => "alipay.wap.trade.create.direct", "partner" => trim($this->alipay_config['partner']), "sec_id" => trim($this->alipay_config['sign_type']), "format" => $format, "v" => $v, "req_id" => $req_id, "req_data" => $req_data, "_input_charset" => trim(strtolower($this->alipay_config['input_charset']))); //建立请求 $alipaySubmit = new AlipaySubmit($this->alipay_config); $html_text = $alipaySubmit->buildRequestHttp($para_token); $html_text = urldecode($html_text); //解析远程模拟提交后返回的信息 $para_html_text = $alipaySubmit->parseResponse($html_text); //获取request_token $request_token = $para_html_text['request_token']; if ($request_token) { //业务详细 $req_data = '<auth_and_execute_req><request_token>' . $request_token . '</request_token></auth_and_execute_req>'; //构造要请求的参数数组,无需改动 $parameter = array("service" => "alipay.wap.auth.authAndExecute", "partner" => trim($this->alipay_config['partner']), "sec_id" => trim($this->alipay_config['sign_type']), "format" => $format, "v" => $v, "req_id" => $req_id, "req_data" => $req_data, "_input_charset" => trim(strtolower($this->alipay_config['input_charset']))); //建立请求 $alipaySubmit = new AlipaySubmit($this->alipay_config); $url = $alipaySubmit->alipay_gateway_new . $alipaySubmit->buildRequestParaToString($parameter); return $url; } else { return false; } }
public function submit($param) { $this->format = 'xml'; $this->v = '2.0'; $this->req_id = date('Ymdhis'); $this->notify_url = MOBILE_SITE_URL . '/api/payment/alipay/notify_url.php'; $this->call_back_url = MOBILE_SITE_URL . '/api/payment/alipay/call_back_url.php'; $this->seller_email = $param['alipay_account']; //v3-b11 $this->out_trade_no = $param['order_sn'] . '-' . $param['order_type']; $this->subject = $param['order_sn']; $this->total_fee = $param['order_amount']; $this->alipay_config = array('partner' => $param['alipay_partner'], 'key' => $param['alipay_key'], 'private_key_path' => 'key/rsa_private_key.pem', 'ali_public_key_path' => 'key/alipay_public_key.pem', 'sign_type' => 'MD5', 'input_charset' => 'utf-8', 'cacert' => getcwd() . '\\cacert.pem', 'transport' => 'http'); //请求业务参数详细 $req_data = '<direct_trade_create_req><notify_url>' . $this->notify_url . '</notify_url><call_back_url>' . $this->call_back_url . '</call_back_url><seller_account_name>' . $this->seller_email . '</seller_account_name><out_trade_no>' . $this->out_trade_no . '</out_trade_no><subject>' . $this->subject . '</subject><total_fee>' . $this->total_fee . '</total_fee></direct_trade_create_req>'; //必填 //构造要请求的参数数组,无需改动 $para_token = array("service" => "alipay.wap.trade.create.direct", "partner" => trim($this->alipay_config['partner']), "sec_id" => trim($this->alipay_config['sign_type']), "format" => $this->format, "v" => $this->v, "req_id" => $this->req_id, "req_data" => $req_data, "_input_charset" => trim(strtolower($this->alipay_config['input_charset']))); //建立请求 $alipaySubmit = new AlipaySubmit($this->alipay_config); $html_text = $alipaySubmit->buildRequestHttp($para_token); //URLDECODE返回的信息 $html_text = urldecode($html_text); //解析远程模拟提交后返回的信息 $para_html_text = $alipaySubmit->parseResponse($html_text); //获取request_token $request_token = $para_html_text['request_token']; /**************************根据授权码token调用交易接口alipay.wap.auth.authAndExecute**************************/ //业务详细 $req_data = '<auth_and_execute_req><request_token>' . $request_token . '</request_token></auth_and_execute_req>'; //必填 //构造要请求的参数数组,无需改动 $parameter = array("service" => "alipay.wap.auth.authAndExecute", "partner" => trim($this->alipay_config['partner']), "sec_id" => trim($this->alipay_config['sign_type']), "format" => $this->format, "v" => $this->v, "req_id" => $this->req_id, "req_data" => $req_data, "_input_charset" => trim(strtolower($this->alipay_config['input_charset']))); //建立请求 $alipaySubmit = new AlipaySubmit($this->alipay_config); $html_text = $alipaySubmit->buildRequestForm($parameter, 'get', '正在跳转支付页面...'); return '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>支付宝即时到账交易接口接口</title> </head>' . $html_text . ' </body> </html>'; }
/** * 生成支付代码 * @param array $order 订单信息 * @param array $payment 支付方式信息 */ function get_code($order, $payment) { if (!defined('EC_CHARSET')) { $charset = 'utf-8'; } else { $charset = EC_CHARSET; } $alipay_config = array(); $alipay_config['partner'] = $payment['alipay_partner']; //安全检验码,以数字和字母组成的32位字符 //如果签名方式设置为“MD5”时,请设置该参数 $alipay_config['key'] = $payment['alipay_key']; //商户的私钥(后缀是.pen)文件相对路径 //如果签名方式设置为“0001”时,请设置该参数 //$alipay_config['private_key_path'] = 'key/rsa_private_key.pem'; //支付宝公钥(后缀是.pen)文件相对路径 //如果签名方式设置为“0001”时,请设置该参数 // $alipay_config['ali_public_key_path']= 'key/alipay_public_key.pem'; //签名方式 不需修改 $alipay_config['sign_type'] = 'MD5'; //字符编码格式 目前支持 gbk 或 utf-8 $alipay_config['input_charset'] = 'utf-8'; $alipay_config['cacert'] = ''; // $alipay_config['cacert'] = ROOT_PATH .'mobile/includes/modules/cacert.pem'; //ca证书路径地址,用于curl中ssl校验 //请保证cacert.pem文件在当前文件夹目录中 //$alipay_config['cacert'] = getcwd().'\\cacert.pem'; //访问模式,根据自己的服务器是否支持ssl访问,若支持请选择https;若不支持请选择http $alipay_config['transport'] = 'http'; require_once ROOT_PATH . "includes/modules/lib/alipay_submit.class.php"; $format = "xml"; //必填,不需要修改 //返回格式 $v = "2.0"; //必填,不需要修改 //请求号 $req_id = date('Ymdhis'); //必填,须保证每次请求都是唯一 //**req_data详细信息** //服务器异步通知页面路径 $notify_url = $GLOBALS['hhs']->url() . 'alipay/notify_url.php'; //需http://格式的完整路径,不允许加?id=123这类自定义参数 //页面跳转同步通知页面路径 $call_back_url = $GLOBALS['hhs']->url() . 'alipay/alipay.php'; $seller_email = $payment['alipay_account']; //必填 //商户订单号 $out_trade_no = $order['order_sn'] . time(); //商户网站订单系统中唯一订单号,必填 //订单名称 $subject = $order['order_sn']; //必填 //付款金额 $total_fee = $order['order_amount']; //必填 //请求业务参数详细 $req_data = '<direct_trade_create_req><notify_url>' . $notify_url . '</notify_url><call_back_url>' . $call_back_url . '</call_back_url><seller_account_name>' . $seller_email . '</seller_account_name><out_trade_no>' . $out_trade_no . '</out_trade_no><subject>' . $subject . '</subject><total_fee>' . $total_fee . '</total_fee></direct_trade_create_req>'; //构造要请求的参数数组,无需改动 $para_token = array("service" => "alipay.wap.trade.create.direct", "partner" => trim($alipay_config['partner']), "sec_id" => trim($alipay_config['sign_type']), "format" => $format, "v" => $v, "req_id" => $req_id, "req_data" => $req_data, "_input_charset" => trim(strtolower($alipay_config['input_charset']))); //建立请求 $alipaySubmit = new AlipaySubmit($alipay_config); $html_text = $alipaySubmit->buildRequestHttp($para_token); //URLDECODE返回的信息 $html_text = urldecode($html_text); //解析远程模拟提交后返回的信息 $para_html_text = $alipaySubmit->parseResponse($html_text); //获取request_token $request_token = $para_html_text['request_token']; /**************************根据授权码token调用交易接口alipay.wap.auth.authAndExecute**************************/ //业务详细 $req_data = '<auth_and_execute_req><request_token>' . $request_token . '</request_token></auth_and_execute_req>'; //必填 //构造要请求的参数数组,无需改动 $parameter = array("service" => "alipay.wap.auth.authAndExecute", "partner" => trim($alipay_config['partner']), "v" => $v, "sec_id" => trim($alipay_config['sign_type']), "format" => $format, "req_id" => $req_id, "req_data" => $req_data, "_input_charset" => trim(strtolower($alipay_config['input_charset']))); //建立请求 $alipaySubmit = new AlipaySubmit($alipay_config); $html_text = $alipaySubmit->buildRequestForm($parameter, 'get', '确认'); //var_dump($html_text); return $html_text; return $html_text; }
public function dopay() { if (!$this->token) { echo 'token不能为空'; exit; } if (!$this->order) { $name = "Product"; $back = U($name . "/my", array('token' => $this->token, 'wecha_id' => $this->wecha_id)); $this->error('订单不能为空', U($name . $back)); } $order = $this->order; $product = $this->product; $alipay_config = $this->alipay_config; //返回格式 $format = "xml"; //必填,不需要修改 //返回格式 $v = "2.0"; //必填,不需要修改 //请求号 $req_id = date('Ymdhis'); //必填,须保证每次请求都是唯一 //服务器异步通知页面路径 $notify_url = C('site_url') . '/api/malipay/notify_url.php'; //需http://格式的完整路径,不允许加?id=123这类自定义参数 //页面跳转同步通知页面路径 $call_back_url = C('site_url') . '/api/malipay/call_back_url.php'; //需http://格式的完整路径,不允许加?id=123这类自定义参数 //卖家支付宝帐户 //$seller_email = $_POST['WIDseller_email']; $seller_email = $this->pay_m_alipay_config['name']; //必填 //商户订单号 //$out_trade_no = $_POST['WIDout_trade_no']; $out_trade_no = $order['sn']; //商户网站订单系统中唯一订单号,必填 //订单名称 //$subject = $_POST['WIDsubject']; $subject = $product['name']; //必填 //付款金额 //$total_fee = $_POST['WIDtotal_fee']; $total_fee = $order['price']; //必填 //请求业务参数详细 $req_data = '<direct_trade_create_req><notify_url>' . $notify_url . '</notify_url><call_back_url>' . $call_back_url . '</call_back_url><seller_account_name>' . $seller_email . '</seller_account_name><out_trade_no>' . $out_trade_no . '</out_trade_no><subject>' . $subject . '</subject><total_fee>' . $total_fee . '</total_fee></direct_trade_create_req>'; //必填 /************************************************************/ //构造要请求的参数数组,无需改动 $para_token = array("service" => "alipay.wap.trade.create.direct", "partner" => trim($alipay_config['partner']), "sec_id" => trim($alipay_config['sign_type']), "format" => $format, "v" => $v, "req_id" => $req_id, "req_data" => $req_data, "_input_charset" => trim(strtolower($alipay_config['input_charset']))); //建立请求 $alipaySubmit = new AlipaySubmit($alipay_config); $html_text = $alipaySubmit->buildRequestHttp($para_token); //URLDECODE返回的信息 $html_text = urldecode($html_text); //解析远程模拟提交后返回的信息 $para_html_text = $alipaySubmit->parseResponse($html_text); //获取request_token $request_token = $para_html_text['request_token']; /**************************根据授权码token调用交易接口alipay.wap.auth.authAndExecute**************************/ //业务详细 $req_data = '<auth_and_execute_req><request_token>' . $request_token . '</request_token></auth_and_execute_req>'; //必填 //构造要请求的参数数组,无需改动 $parameter = array("service" => "alipay.wap.auth.authAndExecute", "partner" => trim($alipay_config['partner']), "sec_id" => trim($alipay_config['sign_type']), "format" => $format, "v" => $v, "req_id" => $req_id, "req_data" => $req_data, "_input_charset" => trim(strtolower($alipay_config['input_charset']))); //建立请求 $alipaySubmit = new AlipaySubmit($alipay_config); $html_text = $alipaySubmit->buildRequestForm($parameter, 'get', '正确为您跳转到支付宝支付界面!'); echo $html_text; }
public function orderWapPay($orderGlideId) { $orderPayGlideService = utils::getService('orderPayGlide'); $orderGlideInfo = $orderPayGlideService->find($orderGlideId); $alipay_config = utils::c('aliwappay'); $format = "xml"; $v = "2.0"; $req_id = date('Ymdhis'); $notify_url = utils::c('siteUrl') . '/mobile/order/ali-pay-notify'; $call_back_url = utils::c('siteUrl') . '/mobile/order/ali-pay-back'; $merchant_url = utils::c('siteUrl') . '/mobile/order'; $out_trade_no = $orderGlideInfo['glide_nums']; $subject = '宅配订单' . $orderGlideInfo['glide_nums']; $total_fee = $orderGlideInfo['total']; $req_data = '<direct_trade_create_req><notify_url>' . $notify_url . '</notify_url><call_back_url>' . $call_back_url . '</call_back_url><seller_account_name>' . trim($alipay_config['seller_email']) . '</seller_account_name><out_trade_no>' . $out_trade_no . '</out_trade_no><subject>' . $subject . '</subject><total_fee>' . $total_fee . '</total_fee><merchant_url>' . $merchant_url . '</merchant_url></direct_trade_create_req>'; $para_token = array("service" => "alipay.wap.trade.create.direct", "partner" => trim($alipay_config['partner']), "sec_id" => trim($alipay_config['sign_type']), "format" => $format, "v" => $v, "req_id" => $req_id, "req_data" => $req_data, "_input_charset" => trim(strtolower($alipay_config['input_charset']))); $alipaySubmit = new AlipaySubmit($alipay_config); $html_text = $alipaySubmit->buildRequestHttp($para_token); $html_text = urldecode($html_text); $para_html_text = $alipaySubmit->parseResponse($html_text); $request_token = $para_html_text['request_token']; $req_data = '<auth_and_execute_req><request_token>' . $request_token . '</request_token></auth_and_execute_req>'; $parameter = array("service" => "alipay.wap.auth.authAndExecute", "partner" => trim($alipay_config['partner']), "sec_id" => trim($alipay_config['sign_type']), "format" => $format, "v" => $v, "req_id" => $req_id, "req_data" => $req_data, "_input_charset" => trim(strtolower($alipay_config['input_charset']))); $alipaySubmit = new AlipaySubmit($alipay_config); $htmlText = $alipaySubmit->buildRequestForm($parameter, 'get', '支付宝支付'); return $htmlText; }
$out_trade_no = $pay['out_trade_no']; $total_fee = $pay['total_fee']; //必填 //请求业务参数详细 $req_data = '<direct_trade_create_req><notify_url>' . $notify_url . '</notify_url><call_back_url>' . $call_back_url . '</call_back_url><seller_account_name>' . $seller_email . '</seller_account_name><out_trade_no>' . $out_trade_no . '</out_trade_no><subject>' . $subject . '</subject><total_fee>' . $total_fee . '</total_fee></direct_trade_create_req>'; //必填 /************************************************************/ //构造要请求的参数数组,无需改动 $para_token = array("service" => "alipay.wap.trade.create.direct", "partner" => trim($alipay_config['partner']), "sec_id" => trim($alipay_config['sign_type']), "format" => $format, "v" => $v, "req_id" => $req_id, "req_data" => $req_data, "_input_charset" => trim(strtolower($alipay_config['input_charset']))); //建立请求 $alipaySubmit = new AlipaySubmit($alipay_config); $html_text = $alipaySubmit->buildRequestHttp($para_token); //URLDECODE返回的信息 $html_text = urldecode($html_text); //解析远程模拟提交后返回的信息 $para_html_text = $alipaySubmit->parseResponse($html_text); //获取request_token $request_token = $para_html_text['request_token']; /**************************根据授权码token调用交易接口alipay.wap.auth.authAndExecute**************************/ //业务详细 $req_data = '<auth_and_execute_req><request_token>' . $request_token . '</request_token></auth_and_execute_req>'; //必填 //构造要请求的参数数组,无需改动 $parameter = array("service" => "alipay.wap.auth.authAndExecute", "partner" => trim($alipay_config['partner']), "sec_id" => trim($alipay_config['sign_type']), "format" => $format, "v" => $v, "req_id" => $req_id, "req_data" => $req_data, "_input_charset" => trim(strtolower($alipay_config['input_charset']))); //print_r($parameter); exit; //建立请求 $alipaySubmit = new AlipaySubmit($alipay_config); $html_text = $alipaySubmit->buildRequestForm($parameter, 'get', '页面跳转中,如果未跳转点此'); echo $html_text; ?> </body>
public function aliPay(Request $request) { require_once app_path() . "/Tool/Alipay/alipay.config.php"; require_once app_path() . "/Tool/Alipay/lib/alipay_submit.class.php"; //返回格式 $format = "xml"; //必填,不需要修改 //返回格式 $v = "2.0"; //必填,不需要修改 //请求号 $req_id = date('Ymdhis'); //必填,须保证每次请求都是唯一 //**req_data详细信息** //服务器异步通知页面路径 $notify_url = "http://" . $_SERVER['HTTP_HOST'] . '/service/pay/ali_notify'; //需http://格式的完整路径,不允许加?id=123这类自定义参数 //页面跳转同步通知页面路径 $call_back_url = "http://" . $_SERVER['HTTP_HOST'] . '/service/pay/ali_result'; //需http://格式的完整路径,不允许加?id=123这类自定义参数 //http://127.0.0.1:8800/WS_WAP_PAYWAP-PHP-UTF-8/call_back_url.php //操作中断返回地址 $merchant_url = "http://" . $_SERVER['HTTP_HOST'] . '/service/pay/ali_merchant'; //用户付款中途退出返回商户的地址。需http://格式的完整路径,不允许加?id=123这类自定义参数 //卖家支付宝帐户 $seller_email = '*****@*****.**'; //必填 //商户订单号 $out_trade_no = $_POST['order_no']; //商户网站订单系统中唯一订单号,必填 Log::info('out_trade_no:' . $out_trade_no); //订单名称 $subject = $_POST['name']; //必填 //付款金额 $total_fee = $_POST['total_price']; //必填 //请求业务参数详细 $req_data = '<direct_trade_create_req><notify_url>' . $notify_url . '</notify_url><call_back_url>' . $call_back_url . '</call_back_url><seller_account_name>' . $seller_email . '</seller_account_name><out_trade_no>' . $out_trade_no . '</out_trade_no><subject>' . $subject . '</subject><total_fee>' . $total_fee . '</total_fee><merchant_url>' . $merchant_url . '</merchant_url></direct_trade_create_req>'; //必填 /************************************************************/ //构造要请求的参数数组,无需改动 $para_token = array("service" => "alipay.wap.trade.create.direct", "partner" => trim($alipay_config['partner']), "sec_id" => trim($alipay_config['sign_type']), "format" => $format, "v" => $v, "req_id" => $req_id, "req_data" => $req_data, "_input_charset" => trim(strtolower($alipay_config['input_charset']))); //建立请求 $alipaySubmit = new \AlipaySubmit($alipay_config); $html_text = $alipaySubmit->buildRequestHttp($para_token); //URLDECODE返回的信息 $html_text = urldecode($html_text); //解析远程模拟提交后返回的信息 $para_html_text = $alipaySubmit->parseResponse($html_text); //获取request_token $request_token = $para_html_text['request_token']; /**************************根据授权码token调用交易接口alipay.wap.auth.authAndExecute**************************/ //业务详细 $req_data = '<auth_and_execute_req><request_token>' . $request_token . '</request_token></auth_and_execute_req>'; //必填 //构造要请求的参数数组,无需改动 $parameter = array("service" => "alipay.wap.auth.authAndExecute", "partner" => trim($alipay_config['partner']), "sec_id" => trim($alipay_config['sign_type']), "format" => $format, "v" => $v, "req_id" => $req_id, "req_data" => $req_data, "_input_charset" => trim(strtolower($alipay_config['input_charset']))); //建立请求 $alipaySubmit = new \AlipaySubmit($alipay_config); $html_text = $alipaySubmit->buildRequestForm($parameter, 'get', '确认'); return $html_text; }
function pay_order() { $order_sn = $this->uri->segment(3); require_once "walipay/alipay.config.php"; require_once "walipay/lib/alipay_submit.class.php"; $alipay_config_temp = $this->tickets->select('payment', array('name' => 'alipay')); $alipay_con = $alipay_config_temp[0]; /**************************调用授权接口alipay.wap.trade.create.direct获取授权码token**************************/ //返回格式 $format = "xml"; //必填,不需要修改 //返回格式 $v = "2.0"; //必填,不需要修改 //请求号 $req_id = date('Ymdhis'); //必填,须保证每次请求都是唯一 //操作中断返回地址 $merchant_url = base_url() . "mobile_return_url.php"; //用户付款中途退出返回商户的地址。需http://格 $notify_url = base_url() . "wechat/notify_url"; //需http://格式的完整路径,不允许加?id=123这类自定义参数 //页面跳转同步通知页面路径 $call_back_url = base_url() . "return_url.php"; //需http://格式的完整路径,不能加?id=123这类自定义参数,不能写成http://localhost/ $o = $this->tickets->select('orders', array('to_order_sn' => $order_sn)); //卖家支付宝帐户 $seller_email = $alipay_con->payname; //'*****@*****.**'; //必填 //商户订单号 $out_trade_no = $order_sn; //商户网站订单系统中唯一订单号,必填 $req_id = date('Ymdhis'); $this->tickets->update('orders', array('to_alipay_sn' => $req_id), array('to_order_sn' => $order_sn)); //订单名称 $subject = $o[0]->to_receiver . '新订单'; //付款金额 $total_fee = $o[0]->to_order_amount; //必填 //请求业务参数详细 $req_data = '<direct_trade_create_req><notify_url>' . $notify_url . '</notify_url><call_back_url>' . $call_back_url . '</call_back_url><seller_account_name>' . $seller_email . '</seller_account_name><out_trade_no>' . $out_trade_no . '</out_trade_no><subject>' . $subject . '</subject><total_fee>' . $total_fee . '</total_fee><merchant_url>' . $merchant_url . '</merchant_url></direct_trade_create_req>'; //必填 /************************************************************/ $alipay_config['partner'] = $alipay_con->app_id; $alipay_config['key'] = $alipay_con->app_secret; //构造要请求的参数数组,无需改动 $para_token = array("service" => "alipay.wap.trade.create.direct", "partner" => trim($alipay_config['partner']), "sec_id" => trim($alipay_config['sign_type']), "format" => $format, "v" => $v, "req_id" => $req_id, "req_data" => $req_data, "_input_charset" => trim(strtolower($alipay_config['input_charset']))); //建立请求 $alipaySubmit = new AlipaySubmit($alipay_config); $html_text = $alipaySubmit->buildRequestHttp($para_token); //URLDECODE返回的信息 $html_text = urldecode($html_text); //解析远程模拟提交后返回的信息 $para_html_text = $alipaySubmit->parseResponse($html_text); //获取request_token $request_token = $para_html_text['request_token']; /**************************根据授权码token调用交易接口alipay.wap.auth.authAndExecute**************************/ //业务详细 $req_data = '<auth_and_execute_req><request_token>' . $request_token . '</request_token></auth_and_execute_req>'; //必填 //构造要请求的参数数组,无需改动 $parameter = array("service" => "alipay.wap.auth.authAndExecute", "partner" => trim($alipay_config['partner']), "sec_id" => trim($alipay_config['sign_type']), "format" => $format, "v" => $v, "req_id" => $req_id, "req_data" => $req_data, "_input_charset" => trim(strtolower($alipay_config['input_charset']))); //建立请求 $alipaySubmit = new AlipaySubmit($alipay_config); $html_text = $alipaySubmit->buildRequestForm($parameter, 'get', '确认'); $data['text'] = $html_text; $this->load->view('main/pay_channel', $data); }
public function wapalipay() { vendor('Malipay.alipay_submit', '', '.class.php'); $alipay_config = $this->wapalipay_config; $order = $this->order; //返回格式 $format = "xml"; $v = "2.0"; $req_id = date('Ymdhis'); $notify_url = C('site_url') . '/index.php/Wap/Pay/wapalipay_notify_url'; $call_back_url = C('site_url') . '/index.php/Wap/Pay/wapalipay_call_back_url'; $seller_email = $alipay_config['seller_email']; $out_trade_no = $order['orderid']; $subject = $order['ordername']; $total_fee = $order['price']; //请求业务参数详细 $req_data = '<direct_trade_create_req><notify_url>' . $notify_url . '</notify_url><call_back_url>' . $call_back_url . '</call_back_url><seller_account_name>' . $seller_email . '</seller_account_name><out_trade_no>' . $out_trade_no . '</out_trade_no><subject>' . $subject . '</subject><total_fee>' . $total_fee . '</total_fee></direct_trade_create_req>'; //构造要请求的参数数组,无需改动 $para_token = array("service" => "alipay.wap.trade.create.direct", "partner" => trim($alipay_config['partner']), "sec_id" => trim($alipay_config['sign_type']), "format" => $format, "v" => $v, "req_id" => $req_id, "req_data" => $req_data, "_input_charset" => trim(strtolower($alipay_config['input_charset']))); //建立请求 $alipaySubmit = new AlipaySubmit($alipay_config); $html_text = $alipaySubmit->buildRequestHttp($para_token); //URLDECODE返回的信息 $html_text = urldecode($html_text); //解析远程模拟提交后返回的信息 $para_html_text = $alipaySubmit->parseResponse($html_text); //获取request_token $request_token = $para_html_text['request_token']; /**************************根据授权码token调用交易接口alipay.wap.auth.authAndExecute**************************/ //业务详细 $req_data = '<auth_and_execute_req><request_token>' . $request_token . '</request_token></auth_and_execute_req>'; //必填 //构造要请求的参数数组,无需改动 $parameter = array("service" => "alipay.wap.auth.authAndExecute", "partner" => trim($alipay_config['partner']), "sec_id" => trim($alipay_config['sign_type']), "format" => $format, "v" => $v, "req_id" => $req_id, "req_data" => $req_data, "_input_charset" => trim(strtolower($alipay_config['input_charset']))); //建立请求 $alipaySubmit = new AlipaySubmit($alipay_config); $html_text = $alipaySubmit->buildRequestForm($parameter, 'get', '正确为您跳转到支付宝支付界面!'); echo '正在跳转到支付宝进行支付...<div style="display:none">' . $html_text . '</div>'; }
function ali_pay() { import('@.ORG.Alipay.alipay_submit'); $args = func_get_args(); if (!$args[0] || !$args[1] || !$args[2]) { //0订单编号,商品描述,2订单金额, return false; } $path = C('Alipay_path'); $config = (require $_SERVER['DOCUMENT_ROOT'] . $path . "config.php"); //返回格式 $format = "xml"; //必填,不需要修改 //返回格式 $v = "2.0"; //必填,不需要修改 //请求号 $req_id = date('Ymdhis'); //必填,须保证每次请求都是唯一 //**req_data详细信息** //服务器异步通知页面路径 $notify_url = "http://" . $_SERVER['HTTP_HOST'] . '/alipay/notify_url.php'; //需http://格式的完整路径,不允许加?id=123这类自定义参数 //页面跳转同步通知页面路径 $call_back_url = "http://" . $_SERVER['HTTP_HOST'] . '/alipay/call_back.php'; //需http://格式的完整路径,不允许加?id=123这类自定义参数 //操作中断返回地址 $merchant_url = "http://" . $_SERVER['HTTP_HOST'] . '/alipay/call_back.php'; //用户付款中途退出返回商户的地址。需http://格式的完整路径,不允许加?id=123这类自定义参数 //商户订单号 $out_trade_no = $args[0]; //商户网站订单系统中唯一订单号,必填 //订单名称 $subject = $args[1]; //必填 //付款金额 $total_fee = $args[2]; //必填 //请求业务参数详细 $req_data = '<direct_trade_create_req><notify_url>' . $notify_url . '</notify_url><call_back_url>' . $call_back_url . '</call_back_url><seller_account_name>' . trim($alipay_config['seller_email']) . '</seller_account_name><out_trade_no>' . $out_trade_no . '</out_trade_no><subject>' . $subject . '</subject><total_fee>' . $total_fee . '</total_fee><merchant_url>' . $merchant_url . '</merchant_url></direct_trade_create_req>'; //必填 //var_dump($req_data);die(); /************************************************************/ //构造要请求的参数数组,无需改动 $para_token = array("service" => "alipay.wap.trade.create.direct", "partner" => trim($alipay_config['partner']), "sec_id" => trim($alipay_config['sign_type']), "format" => $format, "v" => $v, "req_id" => $req_id, "req_data" => $req_data, "_input_charset" => trim(strtolower($alipay_config['input_charset']))); //建立请求 $alipaySubmit = new AlipaySubmit($alipay_config); $html_text = $alipaySubmit->buildRequestHttp($para_token); //URLDECODE返回的信息 $html_text = urldecode($html_text); //解析远程模拟提交后返回的信息 $para_html_text = $alipaySubmit->parseResponse($html_text); //获取request_token $request_token = $para_html_text['request_token']; /**************************根据授权码token调用交易接口alipay.wap.auth.authAndExecute**************************/ //业务详细 $req_data = '<auth_and_execute_req><request_token>' . $request_token . '</request_token></auth_and_execute_req>'; //必填 //构造要请求的参数数组,无需改动 $parameter = array("service" => "alipay.wap.auth.authAndExecute", "partner" => trim($alipay_config['partner']), "sec_id" => trim($alipay_config['sign_type']), "format" => $format, "v" => $v, "req_id" => $req_id, "req_data" => $req_data, "_input_charset" => trim(strtolower($alipay_config['input_charset']))); //建立请求 $alipaySubmit = new AlipaySubmit($alipay_config); $html_text = $alipaySubmit->buildRequestForm($parameter, 'get', '确认'); echo $html_text; }
public function index() { $this->CsdjUser->User_Login(); $id = (int) $this->uri->segment(4); //订单ID if ($id == 0) { msg_url(L('pay_01'), spacelink('pay')); } $row = $this->CsdjDB->get_row('pay', '*', $id); if (!$row || $row->uid != $_SESSION['cscms__id']) { msg_url(L('pay_02'), spacelink('pay')); } if (defined('MOBILE')) { //手机支付 require_once CSCMSPATH . "pay/alipay_wap/alipay.config.php"; require_once CSCMSPATH . "pay/alipay_wap/lib/alipay_submit.class.php"; $format = "xml"; $v = "2.0"; $req_id = date('Ymdhis'); $notify_url = site_url("pay/alipay/notify_url"); $call_back_url = site_url("pay/alipay/return_url"); $merchant_url = site_url("user/pay/lists"); $seller_email = CS_Alipay_Name; $out_trade_no = $row->dingdan; $subject = L('pay_03', array($_SESSION['cscms__name'])); $total_fee = $row->rmb; $req_data = '<direct_trade_create_req><notify_url>' . $notify_url . '</notify_url><call_back_url>' . $call_back_url . '</call_back_url><seller_account_name>' . $seller_email . '</seller_account_name><out_trade_no>' . $out_trade_no . '</out_trade_no><subject>' . $subject . '</subject><total_fee>' . $total_fee . '</total_fee><merchant_url>' . $merchant_url . '</merchant_url></direct_trade_create_req>'; //构造要请求的参数数组,无需改动 $para_token = array("service" => "alipay.wap.trade.create.direct", "partner" => trim($alipay_config['partner']), "sec_id" => trim($alipay_config['sign_type']), "format" => $format, "v" => $v, "req_id" => $req_id, "req_data" => $req_data, "_input_charset" => trim(strtolower($alipay_config['input_charset']))); //建立请求 $alipaySubmit = new AlipaySubmit($alipay_config); $html_text = $alipaySubmit->buildRequestHttp($para_token); $html_text = urldecode($html_text); $para_html_text = $alipaySubmit->parseResponse($html_text); $request_token = $para_html_text['request_token']; $req_data = '<auth_and_execute_req><request_token>' . $request_token . '</request_token></auth_and_execute_req>'; //构造要请求的参数数组,无需改动 $parameter = array("service" => "alipay.wap.auth.authAndExecute", "partner" => trim($alipay_config['partner']), "sec_id" => trim($alipay_config['sign_type']), "format" => $format, "v" => $v, "req_id" => $req_id, "req_data" => $req_data, "_input_charset" => trim(strtolower($alipay_config['input_charset']))); //建立请求 $alipaySubmit = new AlipaySubmit($alipay_config); $html_text = $alipaySubmit->buildRequestForm($parameter, 'get', L('pay_04')); echo $html_text; } elseif (CS_Alipay_JK == 1) { //双功能 require_once CSCMSPATH . "pay/alipay_trade/alipay.config.php"; require_once CSCMSPATH . "pay/alipay_trade/lib/alipay_submit.class.php"; $payment_type = "1"; $notify_url = site_url("pay/alipay/notify_url"); $return_url = site_url("pay/alipay/return_url"); $seller_email = CS_Alipay_Name; $out_trade_no = $row->dingdan; $subject = L('pay_03', array($_SESSION['cscms__name'])); $price = $row->rmb; $quantity = "1"; $logistics_fee = "0.00"; $logistics_type = "EXPRESS"; $logistics_payment = "SELLER_PAY"; $body = $subject; $show_url = ''; $receive_name = ''; $receive_address = ''; $receive_zip = ''; $receive_phone = ''; $receive_mobile = ''; //构造要请求的参数数组,无需改动 $parameter = array("service" => "trade_create_by_buyer", "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, "price" => $price, "quantity" => $quantity, "logistics_fee" => $logistics_fee, "logistics_type" => $logistics_type, "logistics_payment" => $logistics_payment, "body" => $body, "show_url" => $show_url, "receive_name" => $receive_name, "receive_address" => $receive_address, "receive_zip" => $receive_zip, "receive_phone" => $receive_phone, "receive_mobile" => $receive_mobile, "_input_charset" => trim(strtolower($alipay_config['input_charset']))); //建立请求 $alipaySubmit = new AlipaySubmit($alipay_config); $html_text = $alipaySubmit->buildRequestForm($parameter, "get", L('pay_02')); echo $html_text; } elseif (CS_Alipay_JK == 2) { //即时到账 require_once CSCMSPATH . "pay/alipay_direct/alipay.config.php"; require_once CSCMSPATH . "pay/alipay_direct/lib/alipay_submit.class.php"; $payment_type = "1"; $notify_url = site_url("pay/alipay/notify_url"); $return_url = site_url("pay/alipay/return_url"); $seller_email = CS_Alipay_Name; $out_trade_no = $row->dingdan; $subject = L('pay_03', array($_SESSION['cscms__name'])); $total_fee = $row->rmb; $body = $subject; $show_url = ''; $anti_phishing_key = ''; $exter_invoke_ip = ''; //构造要请求的参数数组,无需改动 $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']))); //建立请求 $alipaySubmit = new AlipaySubmit($alipay_config); $html_text = $alipaySubmit->buildRequestForm($parameter, "get", L('pay_02')); echo $html_text; } else { //手动充值 echo ' <FORM accept-charset="gbk" action="https://shenghuo.alipay.com/send/payment/fill.htm" method="post" id="form1" name="form1" onsubmit="document.charset=\'gbk\';"> <INPUT type="hidden" name="optEmail" value="' . CS_Alipay_Name . '"> <INPUT type="hidden" name="payAmount" value="' . $row->rmb . '"> <INPUT type="hidden" name="title" value="' . get_bm('utf-8', 'gbk', L('pay_03', array($_SESSION['cscms__name']))) . '"> <INPUT type="hidden" name="memo" value="' . get_bm('utf-8', 'gbk', L('pay_05') . $_SESSION['cscms__name'] . L('pay_06') . $row->dingdan) . '"> <script language="javascript">document.form1.submit();</script> </form>'; } }
public function doalipayWap() { //echo "<pre>";var_dump( $_SERVER );echo "</pre>"; //返回格式 $format = "xml"; //必填,不需要修改//返回格式 $v = "2.0"; //这里我们通过TP的C函数把配置项参数读出,赋给$alipay_config; $alipay_config = C('alipay_config'); /**************************请求参数**************************/ $payment_type = C('alipay_config.sign_type'); //支付类型 //必填,不能修改 $notify_url = C('alipay.notify_urlWap'); //服务器异步通知页面路径 $return_url = C('alipay.return_urlWap'); //页面跳转同步通知页面路径 $merchant_url = C('alipay.merchant_urlWap'); //操作中断返回地址 $seller_email = C('alipay.seller_email'); //卖家支付宝帐户必填 $out_trade_no = $_POST['trade_no']; //商户订单号 通过支付页面的表单进行传递,注意要唯一! $subject = $_POST['ordsubject']; //订单名称 //必填 通过支付页面的表单进行传递 $total_fee = $_POST['ordtotal_fee']; //付款金额 //必填 通过支付页面的表单进行传递 $body = $_POST['ordbody']; //订单描述 通过支付页面的表单进行传递 $show_url = $_POST['ordshow_url']; //商品展示地址 通过支付页面的表单进行传递 $anti_phishing_key = ""; //防钓鱼时间戳 //若要使用请调用类文件submit中的query_timestamp函数 //$exter_invoke_ip = get_client_ip();//var_dump($exter_invoke_ip);die(); //客户端的IP地址 $exter_invoke_ip = $_SERVER["REMOTE_ADDR"]; //var_dump($exter_invoke_ip);die(); //客户端的IP地址 /************************************************************/ //对前台传过来的价钱数据做判断 $orderId = $out_trade_no; $oOb = M("order"); $orderArr = $oOb->field("count(*) as num")->where("orderId='{$orderId}'")->select(); $num = $orderArr[0]['num']; if ($num == 0) { $coOb = M("cardorder"); $arr = $coOb->where("orderId='{$orderId}'")->select(); //var_dump($arr); $realPrice = $arr[0]['price'] - $arr[0]['discount'] - $arr[0]['yhqPrice']; //var_dump($total_fee); var_dump($realPrice); die; if ($total_fee != $realPrice) { header("location:index.php?m=Member&a=payFail"); } } else { $arr = $oOb->where("orderId='{$orderId}'")->select(); $realPrice = $arr[0]['price'] - $arr[0]['discount'] - $arr[0]['yhq']; if ($total_fee != $realPrice) { header("location:index.php?m=Member&a=payFail"); } } $call_back_url = $return_url; //请求业务参数详细 $req_data = '<direct_trade_create_req><notify_url>' . $notify_url . '</notify_url><call_back_url>' . $call_back_url . '</call_back_url><seller_account_name>' . $seller_email . '</seller_account_name><out_trade_no>' . $out_trade_no . '</out_trade_no><subject>' . $subject . '</subject><total_fee>' . $total_fee . '</total_fee><merchant_url>' . $merchant_url . '</merchant_url></direct_trade_create_req>'; //echo "req_data";var_dump($req_data);echo "----------------------------------"; //必填 //构造要请求的参数数组,无需改动 $para_token = array("service" => "alipay.wap.trade.create.direct", "partner" => trim($alipay_config['partner']), "sec_id" => $payment_type, "format" => $format, "v" => $v, "req_id" => $out_trade_no, "req_data" => trim($req_data), "_input_charset" => trim(strtolower($alipay_config['input_charset']))); //echo "<pre>";var_dump($para_token);echo "</pre>";die(); //建立请求 $alipaySubmit = new AlipaySubmit($alipay_config); $html_text = $alipaySubmit->buildRequestHttp($para_token); //var_dump($html_text);die(); //URLDECODE返回的信息 $html_text = urldecode($html_text); //echo "<pre>";var_dump($html_text);echo "</pre>";die(); //解析远程模拟提交后返回的信息 $para_html_text = $alipaySubmit->parseResponse($html_text); //var_dump($para_html_text);die; //获取request_token $request_token = $para_html_text['request_token']; //var_dump($request_token); /**************************根据授权码token调用交易接口alipay.wap.auth.authAndExecute**************************/ //业务详细 $req_data = '<auth_and_execute_req><request_token>' . $request_token . '</request_token></auth_and_execute_req>'; //必填 $parameter = array("service" => "alipay.wap.auth.authAndExecute", "partner" => trim($alipay_config['partner']), "sec_id" => $payment_type, "format" => $format, "v" => $v, "req_id" => $out_trade_no, "req_data" => trim($req_data), "_input_charset" => trim(strtolower($alipay_config['input_charset']))); //var_dump($parameter);die(); $parameter1 = paraFilter($parameter); $parameter2 = argSort($parameter); //建立请求 $alipaySubmit = new AlipaySubmit($alipay_config); $mysign = $alipaySubmit->buildRequestMysign($parameter2); $parameter2['sign'] = $mysign; //echo "<pre>";var_dump($parameter2);echo "</pre>";die(); $html_text = $alipaySubmit->buildRequestForm($parameter2, "get", "确认"); echo $html_text; }
public function startAlipay() { $order_sn = $this->_get('order_sn'); $token = $this->_get('token'); Log::record($token . ':' . $order_sn); if (empty($order_sn) || empty($token)) { Log::record('startAlipay: ' . print_r($_GET, true)); Log::save(); $this->error('请输入订单号'); } $order = M('b2c_order')->where(array('sn' => $order_sn, 'token' => $token, 'status' => 1))->find(); if (!$order) { $this->error('订单号不正确'); } $shop = M('b2c_shop')->where(array('token' => $token))->find(); if (!$shop) { $this->error('商城不存在'); } $alipay = M('b2c_payment')->where(array('token' => $token, 'pay_code' => 'alipay'))->find(); $alipay_config = array(); if (is_string($alipay['pay_config'])) { $store = unserialize($alipay['pay_config']); $alipay_config['pay_account'] = $store['pay_account']; //合作身份者id,以2088开头的16位纯数字 $alipay_config['partner'] = $store['alipay_pid']; //安全检验码,以数字和字母组成的32位字符 //如果签名方式设置为“MD5”时,请设置该参数 $alipay_config['key'] = $store['alipay_key']; //商户的私钥(后缀是.pen)文件相对路径 //如果签名方式设置为“0001”时,请设置该参数 //$alipay_config['private_key_path'] = getcwd()."/Conf/Wap/key/".$shop['token']."_rsa_private_key.pem"; //支付宝公钥(后缀是.pen)文件相对路径 //如果签名方式设置为“0001”时,请设置该参数 //$alipay_config['ali_public_key_path']= getcwd().'/Conf/Wap/key/'.$shop['token'].'_alipay_public_key.pem'; //签名方式 不需修改 $alipay_config['sign_type'] = 'MD5'; //'0001'; //字符编码格式 目前支持 gbk 或 utf-8 $alipay_config['input_charset'] = 'utf-8'; //ca证书路径地址,用于curl中ssl校验 //请保证cacert.pem文件在当前文件夹目录中 $alipay_config['cacert'] = getcwd() . '\\Conf\\Wap\\key\\cacert.pem'; //访问模式,根据自己的服务器是否支持ssl访问,若支持请选择https;若不支持请选择http $alipay_config['transport'] = 'http'; } Log::record('alipay_config Args:' . print_r($alipay_config, true), Log::INFO); //返回格式 $format = "xml"; //必填,不需要修改 //返回格式 $v = "2.0"; //必填,不需要修改 //请求号 $req_id = date('Ymdhis') . str_pad(mt_rand(1, 99999), 5, '0', STR_PAD_LEFT); //必填,须保证每次请求都是唯一 //**req_data详细信息** //服务器异步通知页面路径 $notify_url = C('site_url') . '/index.php/alipay/notify'; //需http://格式的完整路径,不能加?id=123这类自定义参数 //页面跳转同步通知页面路径 $call_back_url = C('site_url') . '/index.php/alipay/return_url'; //需http://格式的完整路径,不允许加?id=123这类自定义参数 //操作中断返回地址 $merchant_url = "http://" . $shop['token'] . ".shop.weixinwz.com/"; //用户付款中途退出返回商户的地址。需http://格式的完整路径,不允许加?id=123这类自定义参数 //卖家支付宝帐户 $seller_email = trim($alipay_config['pay_account']); //必填 //商户订单号 $out_trade_no = $order['sn']; //商户网站订单系统中唯一订单号,必填 //订单名称 $subject = '订单' . $order['sn'] . '支付'; //必填 //付款金额 $total_fee = $order['price']; //必填 //请求业务参数详细 $req_data = '<direct_trade_create_req><notify_url>' . $notify_url . '</notify_url><call_back_url>' . $call_back_url . '</call_back_url><seller_account_name>' . $seller_email . '</seller_account_name><out_trade_no>' . $out_trade_no . '</out_trade_no><subject>' . $subject . '</subject><total_fee>' . $total_fee . '</total_fee><merchant_url>' . $merchant_url . '</merchant_url></direct_trade_create_req>'; //构造要请求的参数数组,无需改动 $para_token = array("service" => "alipay.wap.trade.create.direct", "partner" => trim($alipay_config['partner']), "sec_id" => trim($alipay_config['sign_type']), "format" => $format, "v" => $v, "req_id" => $req_id, "req_data" => $req_data, "_input_charset" => trim(strtolower($alipay_config['input_charset']))); Log::record('para_token Args:' . print_r($para_token, true), Log::INFO); $trade = M('b2c_trade')->where(array('order_sn' => $order_sn, 'token' => $shop['token']))->find(); if ($trade == null) { $time = time(); $data = array('subject' => $subject, 'name' => $order['truename'], 'order_sn' => $out_trade_no, 'price' => $total_fee); $data['create_time'] = $time; $data['update_time'] = $time; $data['token'] = $shop['token']; $ret = M('b2c_trade')->data($data)->add(); } else { if ($trade['trade_no']) { $this->error('已支付'); } } import("@.ORG.AliWapPay.AlipaySubmit"); //建立请求 $alipaySubmit = new AlipaySubmit($alipay_config); $html_text = $alipaySubmit->buildRequestHttp($para_token); //URLDECODE返回的信息 $html_text = urldecode($html_text); //解析远程模拟提交后返回的信息 $para_html_text = $alipaySubmit->parseResponse($html_text); //获取request_token $request_token = $para_html_text['request_token']; Log::record('token:' . print_r($para_html_text, true), Log::INFO); /**************************根据授权码token调用交易接口alipay.wap.auth.authAndExecute**************************/ //业务详细 $req_data = '<auth_and_execute_req><request_token>' . $request_token . '</request_token></auth_and_execute_req>'; //必填 //构造要请求的参数数组,无需改动 $parameter = array("service" => "alipay.wap.auth.authAndExecute", "partner" => trim($alipay_config['partner']), "sec_id" => trim($alipay_config['sign_type']), "format" => $format, "v" => $v, "req_id" => $req_id, "req_data" => $req_data, "_input_charset" => trim(strtolower($alipay_config['input_charset']))); Log::record('AliWapPay Args:' . print_r($parameter, true), Log::INFO); //建立请求 $alipaySubmit = new AlipaySubmit($alipay_config); $html_text = $alipaySubmit->buildRequestForm($parameter, 'get', 'Start to pay'); echo $html_text; }
/** * 支付宝 * @param unknown_type $order_no * @param unknown_type $money 单位(元) * @param unknown_type $typeId 一级支付方式 * @param unknown_type $typeCode 二级支付方式NO */ public static function alipay($order_no, $money, $desc, $typeId = '', $typeCode = '') { $base_path = SIMPHP_ROOT . '/incs/libs/alipay/'; require_once $base_path . "alipay.config.php"; require_once $base_path . "lib/alipay_submit.class.php"; /**************************调用授权接口alipay.wap.trade.create.direct获取授权码token**************************/ //返回格式 $format = "xml"; //必填,不需要修改 //返回格式 $v = "2.0"; //必填,不需要修改 //请求号 $req_id = $order_no; //必填,须保证每次请求都是唯一 //**req_data详细信息** //服务器异步通知页面路径 $notify_url = $alipay_config['notify_url']; //需http://格式的完整路径,不允许加?id=123这类自定义参数 //页面跳转同步通知页面路径 $call_back_url = $alipay_config['return_url']; //需http://格式的完整路径,不允许加?id=123这类自定义参数 //操作中断返回地址 $merchant_url = $alipay_config['merchant_url']; //用户付款中途退出返回商户的地址。需http://格式的完整路径,不允许加?id=123这类自定义参数 //卖家支付宝帐户 $seller_email = $alipay_config['seller_email']; //必填 //商户订单号 $out_trade_no = $order_no; //商户网站订单系统中唯一订单号,必填 //订单名称 $subject = $desc; //必填 //付款金额 $total_fee = $money; //单位(元) //必填 //请求业务参数详细 $req_data = '<direct_trade_create_req><notify_url>' . $notify_url . '</notify_url><call_back_url>' . $call_back_url . '</call_back_url><seller_account_name>' . $seller_email . '</seller_account_name><out_trade_no>' . $out_trade_no . '</out_trade_no><subject>' . $subject . '</subject><total_fee>' . $total_fee . '</total_fee><merchant_url>' . $merchant_url . '</merchant_url></direct_trade_create_req>'; //必填 /************************************************************/ //构造要请求的参数数组,无需改动 $para_token = array("service" => "alipay.wap.trade.create.direct", "partner" => trim($alipay_config['partner']), "sec_id" => trim($alipay_config['sign_type']), "format" => $format, "v" => $v, "req_id" => $req_id, "req_data" => $req_data, "_input_charset" => trim(strtolower($alipay_config['input_charset']))); //建立请求 $alipaySubmit = new AlipaySubmit($alipay_config); $html_text = $alipaySubmit->buildRequestHttp($para_token); //URLDECODE返回的信息 $html_text = urldecode($html_text); //解析远程模拟提交后返回的信息 $para_html_text = $alipaySubmit->parseResponse($html_text); //获取request_token $request_token = $para_html_text['request_token']; /**************************根据授权码token调用交易接口alipay.wap.auth.authAndExecute**************************/ //业务详细 $req_data = '<auth_and_execute_req><request_token>' . $request_token . '</request_token></auth_and_execute_req>'; //必填 //构造要请求的参数数组,无需改动 $parameter = array("service" => "alipay.wap.auth.authAndExecute", "partner" => trim($alipay_config['partner']), "sec_id" => trim($alipay_config['sign_type']), "format" => $format, "v" => $v, "req_id" => $req_id, "req_data" => $req_data, "_input_charset" => trim(strtolower($alipay_config['input_charset']))); //建立请求 $alipaySubmit = new AlipaySubmit($alipay_config); $html_text = $alipaySubmit->buildRequestForm($parameter, 'get', '跳转中...'); //header('Content-type: text/html; charset=utf-8'); return $html_text; }
public function action_alipay() { $GLOBALS['cfg_alipay_pid'] = Common::getSysConf('value', 'cfg_alipay_pid', 0); //pid $GLOBALS['cfg_alipay_key'] = Common::getSysConf('value', 'cfg_alipay_key', 0); //key $GLOBALS['cfg_alipay_account'] = Common::getSysConf('value', 'cfg_alipay_account', 0); //帐号 include PUBLICPATH . '/thirdpay/alipay/alipay.config.php'; include PUBLICPATH . '/thirdpay/alipay/lib/alipay_submit.class.php'; /**************************调用授权接口alipay.wap.trade.create.direct获取授权码token**************************/ //返回格式 $format = "xml"; //必填,不需要修改 //返回格式 $v = "2.0"; //必填,不需要修改 //请求号 $req_id = date('Ymdhis'); //必填,须保证每次请求都是唯一 //**req_data详细信息** //服务器异步通知页面路径 $notify_url = $GLOBALS['cfg_basehost'] . "/shouji/thirdpay/alipay_notifyurl"; //需http://格式的完整路径,不允许加?id=123这类自定义参数 //页面跳转同步通知页面路径 $call_back_url = $GLOBALS['cfg_basehost'] . "/shouji/thirdpay/alipay_backurl"; //需http://格式的完整路径,不允许加?id=123这类自定义参数 //操作中断返回地址 $merchant_url = "http://127.0.0.1:8800/WS_WAP_PAYWAP-PHP-UTF-8/xxxx.php"; //用户付款中途退出返回商户的地址。需http://格式的完整路径,不允许加?id=123这类自定义参数 //卖家支付宝帐户 $seller_email = $GLOBALS['cfg_alipay_account']; //必填 //商户订单号 $out_trade_no = $_POST['ordersn']; //商户网站订单系统中唯一订单号,必填 //订单名称 $subject = $_POST['subject']; //必填 //付款金额 $total_fee = $_POST['price']; //必填 //请求业务参数详细 $req_data = '<direct_trade_create_req><notify_url>' . $notify_url . '</notify_url><call_back_url>' . $call_back_url . '</call_back_url><seller_account_name>' . $seller_email . '</seller_account_name><out_trade_no>' . $out_trade_no . '</out_trade_no><subject>' . $subject . '</subject><total_fee>' . $total_fee . '</total_fee><merchant_url>' . $merchant_url . '</merchant_url></direct_trade_create_req>'; //构造要请求的参数数组,无需改动 $para_token = array("service" => "alipay.wap.trade.create.direct", "partner" => trim($alipay_config['partner']), "sec_id" => trim($alipay_config['sign_type']), "format" => $format, "v" => $v, "req_id" => $req_id, "req_data" => $req_data, "_input_charset" => trim(strtolower($alipay_config['input_charset']))); //建立请求 $alipaySubmit = new AlipaySubmit($alipay_config); $html_text = $alipaySubmit->buildRequestHttp($para_token); //URLDECODE返回的信息 $html_text = urldecode($html_text); //解析远程模拟提交后返回的信息 $para_html_text = $alipaySubmit->parseResponse($html_text); //获取request_token $request_token = $para_html_text['request_token']; /**************************根据授权码token调用交易接口alipay.wap.auth.authAndExecute**************************/ //业务详细 $req_data = '<auth_and_execute_req><request_token>' . $request_token . '</request_token></auth_and_execute_req>'; //必填 //构造要请求的参数数组,无需改动 $parameter = array("service" => "alipay.wap.auth.authAndExecute", "partner" => trim($alipay_config['partner']), "sec_id" => trim($alipay_config['sign_type']), "format" => $format, "v" => $v, "req_id" => $req_id, "req_data" => $req_data, "_input_charset" => trim(strtolower($alipay_config['input_charset']))); //建立请求 $alipaySubmit = new AlipaySubmit($alipay_config); $html_text = $alipaySubmit->buildRequestForm($parameter, 'get', '确认'); echo $html_text; }