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', '确认'); }
/** * 构造确认发货接口 * @param $para_temp 请求参数数组 * @return 获取支付宝的返回XML处理结果 */ function send_goods_confirm_by_platform($para_temp) { //获取支付宝的返回XML处理结果 $alipaySubmit = new AlipaySubmit(); $html_text = $alipaySubmit->sendPostInfo($para_temp, $this->alipay_gateway_new, $this->aliapy_config); return $html_text; }
public function recharge() { $amount = intval($this->_post('amount')); if (!$amount) { $amount = intval($this->_get('amount')); } // $buyDiscount = 0; if (isset($_GET['discountpriceid'])) { $thisPrice = M('Agent_price')->where(array('id' => intval($_GET['discountpriceid'])))->find(); $buyDiscount = 1; $amount = $thisPrice['price']; } if (!$amount) { $this->error('请填写金额'); } import("@.ORG.Alipay.AlipaySubmit"); //支付类型 $payment_type = "1"; //必填,不能修改 //服务器异步通知页面路径 $notify_url = C('site_url') . U('Agent/Pay/notify'); //需http://格式的完整路径,不能加?id=123这类自定义参数 //页面跳转同步通知页面路径 $return_url = C('site_url') . U('Agent/Pay/return_url', array('discountpriceid' => intval($_GET['discountpriceid']))); //需http://格式的完整路径,不能加?id=123这类自定义参数,不能写成http://localhost/ //卖家支付宝帐户 $seller_email = trim(C('alipay_name')); //商户订单号 $out_trade_no = $this->thisAgent['id'] . '_' . time(); //商户网站订单系统中唯一订单号,必填 //订单名称 if ($buyDiscount) { $subject = '购买优惠套餐' . $thisPrice['name'] . '(ID:' . $thisPrice['id'] . ')'; } else { $subject = '充值' . $amount . '元'; } //必填 //付款金额 $total_fee = $amount; $body = $subject; //商品展示地址 $show_url = C('site_url') . U('Agent/Basic/expenseRecords'); //需以http://开头的完整路径,例如:http://www.xxx.com/myorder.html //防钓鱼时间戳 $anti_phishing_key = ""; //若要使用请调用类文件submit中的query_timestamp函数 //客户端的IP地址 $exter_invoke_ip = ""; //非局域网的外网IP地址,如:221.0.0.1 $body = $subject; $data = M('Agent_expenserecords')->data(array('agentid' => $this->thisAgent['id'], 'des' => $subject, 'time' => time(), 'orderid' => $out_trade_no, 'amount' => $total_fee))->add(); $show_url = rtrim(C('site_url'), '/'); //构造要请求的参数数组,无需改动 $parameter = array("service" => "create_direct_pay_by_user", "partner" => trim(C('alipay_pid')), "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('utf-8'))); //建立请求 $alipaySubmit = new AlipaySubmit($this->setconfig()); $html_text = $alipaySubmit->buildRequestForm($parameter, "get", "确认支付"); echo $html_text; }
function trade_create_by_buyer($para_temp) { $button_name = "确认"; $alipaySubmit = new AlipaySubmit(); $html_text = $alipaySubmit->buildForm($para_temp, $this->alipay_gateway_new, "get", $button_name, $this->aliapy_config); return $html_text; }
public function AliPay($data){ $alipay_config['partner'] = $this->partner; $alipay_config['seller_email'] = $this->seller_email; $alipay_config['key'] = $this->paykey; $alipay_config['sign_type'] = strtoupper('MD5');//签名方式 $alipay_config['input_charset']= strtolower('utf-8');//字符编码 //$alipay_config['cacert'] = getcwd().'\\cacert.pem'; $alipay_config['transport'] = 'http'; $parameter = array( "service" => "create_direct_pay_by_user", "partner" => trim($alipay_config['partner']), "seller_email" => trim($alipay_config['seller_email']), "payment_type" => '1', "notify_url" => $this->notify_url, "return_url" => $this->return_url, "out_trade_no" => $this->orderid, "subject" => $this->subject, "total_fee" => $this->price, "body" => $this->message, "show_url" => $this->show_url, "anti_phishing_key" => $this->anti_key, "exter_invoke_ip" => $this->exter_ip, "_input_charset" => trim(strtolower($alipay_config['input_charset'])) ); //建立请求 $alipaySubmit = new AlipaySubmit($alipay_config); $html_text = $alipaySubmit->buildRequestForm($parameter,"get", $this->waitword); return $html_text; }
public function send($trade_no, $logistics_name, $invoice_no) { require_once "lib/alipay_submit.class.php"; $alipaySubmit = new AlipaySubmit($this->config); $parameter = array("service" => "send_goods_confirm_by_platform", "partner" => trim($this->config['partner']), "trade_no" => $trade_no, "logistics_name" => $logistics_name, "invoice_no" => $invoice_no, "transport_type" => 'EXPRESS', "_input_charset" => trim(strtolower($alipay_config['input_charset']))); $html_text = $alipaySubmit->buildRequestHttp($parameter); }
public function post() { if ($this->_get('price') == false || $this->_get('uname') == false) { $this->error('价格和用户名必须填写'); } import("@.ORG.Alipay.AlipaySubmit"); $payment_type = "1"; $notify_url = C('site_url') . U('User/Alipay/notify'); $return_url = C('site_url') . U('User/Alipay/return_url', array('uid' => intval($_GET['uid']))); $seller_email = trim(C('alipay_name')); $out_trade_no = $this->_get('uid') . '_' . time(); $subject = '充值vip' . $this->_get('group') . '会员' . $this->_get('num') . '个月'; $total_fee = (int) $this->_get('price'); $body = 'vip高级会员服务费'; $show_url = C('site_url') . U('Home/Index/price'); $anti_phishing_key = ""; $exter_invoke_ip = ""; $body = $subject; $data = M('Indent')->data(array('uid' => intval($_GET['uid']), 'month' => intval($this->_get('num')), 'title' => $subject, 'uname' => $this->_get('uname'), 'gid' => $this->_get('groupid'), 'create_time' => time(), 'indent_id' => $out_trade_no, 'price' => $total_fee))->add(); $show_url = rtrim(C('site_url'), '/'); $parameter = array("service" => "create_direct_pay_by_user", "partner" => trim(C('alipay_pid')), "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('utf-8'))); $alipaySubmit = new AlipaySubmit($this->setconfig()); $html_text = $alipaySubmit->buildRequestForm($parameter, "get", "确认"); echo $html_text; }
public function alipayapi() { // $username = Auth::user()->username; // $password = Input::get('password'); // $userPassword = Auth::user()->password; // if (! Auth::validate(array('username'=>$username, 'password'=>$password))) { // return Redirect::back() // ->with('message', 'wrong-credential'); // } // dd(public_path()); // require_once("alipay.config.php"); // require_once("lib/alipay_submit.class.php"); require_once public_path() . "/alipay/alipay.config.php"; require_once public_path() . "/alipay/lib/alipay_submit.class.php"; /**************************请求参数**************************/ //商户订单号,商户网站订单系统中唯一订单号,必填 $out_trade_no = $_POST['WIDout_trade_no']; //订单名称,必填 $subject = $_POST['WIDsubject']; //付款金额,必填 $total_fee = $_POST['WIDtotal_fee']; //商品描述,可空 $body = $_POST['WIDbody']; /************************************************************/ //构造要请求的参数数组,无需改动 $parameter = array("service" => $alipay_config['service'], "partner" => $alipay_config['partner'], "seller_id" => $alipay_config['seller_id'], "payment_type" => $alipay_config['payment_type'], "notify_url" => $alipay_config['notify_url'], "return_url" => $alipay_config['return_url'], "anti_phishing_key" => $alipay_config['anti_phishing_key'], "exter_invoke_ip" => $alipay_config['exter_invoke_ip'], "out_trade_no" => $out_trade_no, "subject" => $subject, "total_fee" => $total_fee, "body" => $body, "_input_charset" => trim(strtolower($alipay_config['input_charset']))); //建立请求 $alipaySubmit = new AlipaySubmit($alipay_config); $html_text = $alipaySubmit->buildRequestForm($parameter, "get", "确认"); echo $html_text; }
public function _alipayto(){ //支付信息 $alipaySubmit = new AlipaySubmit($alipay_config); //$anti_phishing_key = $alipaySubmit->query_timestamp(); $payment_type = "1"; $exter_invoke_ip = $_SERVER['REMOTE_ADDR']; $out_trade_no = $row['pay_order_id']; $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'])) ); //var_dump($parameter);exit; //建立请求 //$alipaySubmit = new AlipaySubmit($alipay_config); $html_text = $alipaySubmit->buildRequestForm($parameter,"get", "确认"); echo $html_text; //echo '提交成功'; }
function get_code($ologin) { $aliapy_config['partner'] = $ologin['alipaylogin_id']; $aliapy_config['key'] = $ologin['alipaylogin_key']; $aliapy_config['return_url'] = ologin::url(basename(__FILE__,'.php')); $aliapy_config['sign_type'] = 'MD5'; $aliapy_config['input_charset']= 'utf-8'; $aliapy_config['transport'] = 'http'; //require_once("alipayauth/alipay_service.class.php"); require_once("alipayauth/alipay_submit.class.php"); $parameter = array( "service" => "alipay.auth.authorize", "target_service" => 'user.auth.quick.login', "partner" => trim($aliapy_config['partner']), "_input_charset" => trim(strtolower($aliapy_config['input_charset'])), "return_url" => trim($aliapy_config['return_url']), "anti_phishing_key" => '', "exter_invoke_ip" => '', ); ini_set("display_errors","On"); //var_dump($aliapy_config);exit; $alipayService = new AlipaySubmit($aliapy_config); $login_url = $alipayService->buildRequestForm($parameter,"get", ""); //file_put_contents('logs.txt',$login_url);exit; //var_dump($login_url);exit; echo $login_url;exit; return $login_url; }
/** * @brief 开始向接口发送数据 * @param $data array 订单和配送数据 */ public function send($data) { require_once dirname(__FILE__) . "/lib/alipay_submit.class.php"; /* if(isset($data['seller_id']) && $data['seller_id'] > 0 ){ //获取商户的支付配置信息 $sellPay = new IModel("seller_payment"); $sellers = $sellPay->getObj("seller_id = ".$data['seller_id']); if(empty($sellers)){ return false; } } */ $alipay_config = array('partner' => Payment::getConfigParam($data['pay_type'], 'M_PartnerId'), 'key' => Payment::getConfigParam($data['pay_type'], 'M_PartnerKey'), 'sign_type' => strtoupper('MD5'), 'input_charset' => strtolower('utf-8'), 'cacert' => getcwd() . '/cacert.pem', 'transport' => 'http'); //支付宝交易号 $trade_no = $data['trade_no']; //必填 //物流公司名称 $logistics_name = $data['freight_type']; //必填 //物流发货单号 $invoice_no = $data['delivery_code']; //物流运输类型 三个值可选:POST(平邮)、EXPRESS(快递)、EMS(EMS) $transport_type = 'EXPRESS'; //构造要请求的参数数组,无需改动 $parameter = array("service" => "send_goods_confirm_by_platform", "partner" => trim($alipay_config['partner']), "trade_no" => $trade_no, "logistics_name" => $logistics_name, "invoice_no" => $invoice_no, "transport_type" => $transport_type, "_input_charset" => trim(strtolower('utf-8'))); //建立请求 $alipaySubmit = new AlipaySubmit($alipay_config); $html_text = $alipaySubmit->buildRequestHttp($parameter); }
public function outPayForUrl($order, $notify_url, $return_url) { $alipaySubmit = new AlipaySubmit($this->config); //支付类型 $payment_type = "1"; //卖家支付宝帐户 $seller_email = $this->config['account']; //必填 //商户订单号 $out_trade_no = $order['ordersn']; //商户网站订单系统中唯一订单号,必填 //订单名称 $subject = $order['ordertitle']; //必填 //付款金额 $total_fee = $order['orderprice']; //必填 //订单描述 $body = $order['orderdescribe']; //商品展示地址 $show_url = 'index.php?item-app-order&ordersn=' . $order['ordersn']; //需以http://开头的完整路径,例如:http://www.xxx.com/myorder.html //防钓鱼时间戳 $anti_phishing_key = ""; //若要使用请调用类文件submit中的query_timestamp函数 //客户端的IP地址 $exter_invoke_ip = ""; //非局域网的外网IP地址,如:221.0.0.1 //构造要请求的参数数组,无需改动 $parameter = array("service" => "trade_create_by_buyer", "partner" => trim($this->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, "logistics_type" => 'EXPRESS', "logistics_fee" => 0, "logistics_payment" => 'SELLER_PAY', "price" => $total_fee, "quantity" => 1, "body" => $body, "show_url" => $show_url, "anti_phishing_key" => $anti_phishing_key, "exter_invoke_ip" => $exter_invoke_ip, "_input_charset" => trim(strtolower($this->config['input_charset']))); $url = $alipaySubmit->alipay_gateway_new . $alipaySubmit->buildRequestParaToString($parameter); unset($alipaySubmit); return $url; }
public function pay() { $price = $_GET['price']; $orderName = $_GET['orderName']; if (!$orderName) { $orderName = microtime(); } $orderid = $_GET['orderid']; if (!$orderid) { $orderid = $_GET['single_orderid']; } $alipayConfig = $this->alipayConfig; if (!$price) { exit('必须有价格才能支付'); } import("@.ORG.Alipay.AlipaySubmit"); $payment_type = "1"; $notify_url = C('site_url') . '/index.php?g=Wap&m=Alipay&a=notify_url'; $return_url = C('site_url') . '/index.php?g=Wap&m=Alipay&a=return_url'; $seller_email = trim($alipayConfig['name']); $out_trade_no = $orderid; $subject = $orderName; $total_fee = floatval($price); $body = $orderName; $show_url = C('site_url') . U('Home/Index/price'); $anti_phishing_key = ""; $exter_invoke_ip = ""; $body = $subject; $show_url = rtrim(C('site_url'), '/'); $parameter = array("service" => "create_direct_pay_by_user", "partner" => trim($alipayConfig['pid']), "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('utf-8'))); $alipaySubmit = new AlipaySubmit($this->setconfig()); $html_text = $alipaySubmit->buildRequestForm($parameter, "get", "进行支付"); echo '正在跳转到支付宝进行支付...<div style="display:none">' . $html_text . '</div>'; }
public function doalipay() { $recorder = M('Recorder'); $rid = $_GET['rid']; $map['id'] = $rid; $map['userid'] = session('userid'); $recinfo = $recorder->where($map)->find(); if ($recinfo) { //这里我们通过TP的C函数把配置项参数读出,赋给$alipay_config; $alipay_config = C('alipay_config'); $payment_type = "1"; //支付类型 //必填,不能修改 $notify_url = C('alipay.notify_url'); //服务器异步通知页面路径 $return_url = C('alipay.return_url'); //页面跳转同步通知页面路径 $seller_email = C('alipay.seller_email'); //卖家支付宝帐户必填 $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" => $recinfo['order_sn'], "subject" => '我爱换驾共享豆充值', "total_fee" => '0.01', "body" => '共享豆充值', "show_url" => '', "anti_phishing_key" => "", "exter_invoke_ip" => "", "_input_charset" => trim(strtolower($alipay_config['input_charset']))); $alipaySubmit = new \AlipaySubmit($alipay_config); echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8">'; $html_text = $alipaySubmit->buildRequestForm($parameter, "post", "确认"); echo $html_text; } }
function alipay_link($params) { #支付宝接口配置 $type = $params['T']; $alipay_config['input_charset'] = 'utf-8'; $alipay_config['sign_type'] = "MD5"; $alipay_config['transport'] = $params['ssl'] ? "https" : "http"; $alipay_config['partner'] = $params['partnerID']; $alipay_config['key'] = $params['security_code']; $alipay_config['seller_email'] = $params['seller_email']; $debug = $params["debug"]; #系统变量 $invoiceid = $params['invoiceid']; $description = $params["description"]; $amount = $params['amount']; # Format: ##.## $currency = $params['currency']; # Currency Code $companyname = $params['companyname']; $systemurl = $params['systemurl']; $currency = $params['currency']; $alipay_config['return_url'] = $systemurl . "/modules/gateways/callback/alipay_return.php"; $alipay_config['notify_url'] = $systemurl . "/modules/gateways/callback/alipay_callback.php"; switch ($type) { case "1": $service_name = "create_direct_pay_by_user"; break; case "2": $service_name = "create_partner_trade_by_buyer"; break; case "3": $service_name = "trade_create_by_buyer"; break; default: } //基本参数 $parameter = array("service" => $service_name, "partner" => trim($alipay_config['partner']), "_input_charset" => trim(strtolower($alipay_config['input_charset'])), "return_url" => trim($alipay_config['return_url']), "sign_type" => trim($alipay_config['sign_type']), "notify_url" => trim($alipay_config['notify_url'])); //业务参数 $parameter["subject"] = "{$companyname} 订单[ {$invoiceid} ]"; $parameter["body"] = $description; $parameter["out_trade_no"] = $invoiceid; $parameter["price"] = $amount; $parameter["quantity"] = "1"; $parameter["payment_type"] = "1"; $parameter["seller_email"] = trim($alipay_config['seller_email']); if ($type != "1") { $parameter["logistics_fee"] = "0"; $parameter["logistics_type"] = "EXPRESS"; $parameter["logistics_payment"] = "SELLER_PAY"; } $img = $systemurl . "/modules/gateways/callback/alipay.png"; $alipaySubmit = new AlipaySubmit($alipay_config); $html_text = $alipaySubmit->buildRequestForm($parameter, "get", "确认"); if ($debug) { $msg = "订单: {$invoiceid} 生成支付表单 {$html_text}"; logResult($msg); } $code = $html_text . "</form><a href='#' onclick=\"document.forms['alipaysubmit'].submit();\"><img src='{$img}' alt='点击使用支付宝支付'> </a>"; return $code; }
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 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 pay($runValidation = true) { if ($runValidation && !$this->validate()) { return false; } if ($this->_order->status !== Order::STATUS_UNPAID) { return false; } try { switch ($this->platform) { case self::PLATFORM_ALIPAY: require_once Yii::getAlias('@vendor') . '/payment/alipay/alipay.config.php'; require_once Yii::getAlias('@vendor') . '/payment/alipay/lib/alipay_submit.class.php'; $parameter = ['service' => 'create_direct_pay_by_user', 'partner' => trim($alipay_config['partner']), 'seller_email' => trim($alipay_config['seller_email']), 'payment_type' => '1', 'notify_url' => Url::to(['/payment/alipay-order-notify'], true), 'return_url' => Url::to(['/payment/alipay-order-return'], true), 'out_trade_no' => $this->_order->order_sn, 'subject' => '订单支付', 'total_fee' => $this->_order->real_fee, 'body' => '笑e购(xiaoego.com)订单,订单号:' . $this->_order->order_sn, 'show_url' => Url::to(['/order/detail', 'order' => $this->_order->order_sn], true), 'anti_phishing_key' => '', 'exter_invoke_ip' => '', '_input_charset' => trim(strtolower($alipay_config['input_charset']))]; //建立请求 $alipaySubmit = new \AlipaySubmit($alipay_config); $htmlText = $alipaySubmit->buildRequestForm($parameter, 'post', ''); break; default: throw new InvalidValueException(); } return $htmlText; } catch (\Exception $e) { return false; } }
public function doalipay() { //echo "<pre>";var_dump( $_SERVER );echo "</pre>"; //这里我们通过TP的C函数把配置项参数读出,赋给$alipay_config; $alipay_config = C('alipay_config'); /**************************请求参数**************************/ $payment_type = "1"; //支付类型 //必填,不能修改 $notify_url = C('alipay.notify_url'); //服务器异步通知页面路径 $return_url = C('alipay.return_url'); //页面跳转同步通知页面路径 $seller_email = C('alipay.seller_email'); //卖家支付宝帐户必填 $out_trade_no = $_POST['trade_no']; //商户订单号 通过支付页面的表单进行传递,注意要唯一! $subject = $_POST['ordsubject']; //订单名称 //必填 通过支付页面的表单进行传递 $total_fee = $_POST['ordtotal_fee']; //付款金额 //必填 通过支付页面的表单进行传递 //对前台传过来的价钱数据做判断 $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"); } } $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地址 /************************************************************/ //构造要请求的参数数组,无需改动 $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']))); //var_dump($parameter);die(); //建立请求 $alipaySubmit = new AlipaySubmit($alipay_config); $html_text = $alipaySubmit->buildRequestForm($parameter, "post", "确认"); echo $html_text; }
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; }
public function pay() { //参数数据 $price = $_GET['price']; $orderName = $_GET['orderName']; if (!$orderName) { $orderName = microtime(); } $orderid = $_GET['orderid']; if (!$orderid) { $orderid = $_GET['single_orderid']; //单个订单 } // $alipayConfig = $this->alipayConfig; // if (!$price) { exit('必须有价格才能支付'); } import("@.ORG.Alipay.AlipaySubmit"); //支付类型 $payment_type = "1"; //必填,不能修改 //服务器异步通知页面路径 $notify_url = C('site_url') . '/index.php?g=Wap&m=Alipaytype&a=notify_url'; //需http://格式的完整路径,不能加?id=123这类自定义参数 //页面跳转同步通知页面路径 $return_url = C('site_url') . '/index.php?g=Wap&m=Alipaytype&a=return_url&token=' . $_GET['token'] . '&wecha_id=' . $_GET['wecha_id'] . '&from=' . $_GET['from']; //需http://格式的完整路径,不能加?id=123这类自定义参数,不能写成http://localhost/ //卖家支付宝帐户 $seller_email = trim($alipayConfig['name']); //商户订单号 $out_trade_no = $orderid; //商户网站订单系统中唯一订单号,必填 //订单名称 $subject = $orderName; //必填 //付款金额 $total_fee = floatval($price); $body = $orderName; //商品展示地址 $show_url = C('site_url') . U('Home/Index/price'); //需以http://开头的完整路径,例如:http://www.xxx.com/myorder.html //防钓鱼时间戳 $anti_phishing_key = ""; //若要使用请调用类文件submit中的query_timestamp函数 //客户端的IP地址 $exter_invoke_ip = ""; //非局域网的外网IP地址,如:221.0.0.1 $body = $subject; $show_url = rtrim(C('site_url'), '/'); //构造要请求的参数数组,无需改动 $parameter = array("service" => "create_direct_pay_by_user", "partner" => trim($alipayConfig['pid']), "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('utf-8'))); //建立请求 $alipaySubmit = new AlipaySubmit($this->setconfig()); $html_text = $alipaySubmit->buildRequestForm($parameter, "get", "进行支付"); echo '正在跳转到支付宝进行支付...<div style="display:none">' . $html_text . '</div>'; }
/** * 构造快捷登录接口 * @param $para_temp 请求参数数组 * @return 表单提交HTML信息 */ function alipay_auth_authorize($para_temp) { //设置按钮名称 $button_name = ""; //生成表单提交HTML文本信息 $alipaySubmit = new AlipaySubmit(); $html_text = $alipaySubmit->buildForm($para_temp, $this->alipay_gateway_new, "get", $button_name, $this->aliapy_config); return $html_text; }
/** * 构造快捷登录用户物流地址查询接口 * @param $para_temp 请求参数数组 * @return 表单提交HTML信息 */ function user_logistics_address_query($para_temp) { //设置按钮名称 $button_name = "确认"; //生成表单提交HTML文本信息 $alipaySubmit = new AlipaySubmit(); $html_text = $alipaySubmit->buildForm($para_temp, $this->alipay_gateway_new, "get", $button_name, $this->aliapy_config); return $html_text; }
function createAlipayUrl(array $alipayConfig, array $parameter) { $alipayConfig = getAlipayConfig($alipayConfig); $parameter = array_merge(array('service' => 'create_direct_pay_by_user', 'partner' => trim($alipayConfig['partner']), 'seller_email' => trim($alipayConfig['seller_email']), 'payment_type' => 1, 'notify_url' => '', 'return_url' => '', 'out_trade_no' => time(), 'subject' => '支付订单', 'total_fee' => 0.01, 'body' => '', 'show_url' => '', 'anti_phishing_key' => '', 'exter_invoke_ip' => '', '_input_charset' => trim(strtolower($alipayConfig['input_charset']))), $parameter); $alipaySubmit = new AlipaySubmit($alipayConfig); $url = $alipaySubmit->alipay_gateway_new; $url .= $alipaySubmit->buildRequestParaToString($parameter); return $url; }
/** * 构造即时到帐接口 * @param $para_temp 请求参数数组 * @return 表单提交HTML信息 */ function create_direct_pay_by_user($para_temp) { //设置按钮名称 $button_name = "确认"; //生成表单提交HTML文本信息 $alipaySubmit = new AlipaySubmit(); $html_text = $alipaySubmit->buildForm($para_temp, $this->alipay_gateway_new, "get", $button_name, $this->aliapy_config); return $html_text; }
function createAlipayUrl(array $alipayConfig, array $parameter) { $alipayConfig = getAlipayConfig($alipayConfig); $parameter = array_merge(array("service" => "create_direct_pay_by_user", "partner" => trim($alipayConfig['partner']), "seller_email" => trim($alipayConfig['seller_email']), "payment_type" => 1, "notify_url" => '', "return_url" => '', "out_trade_no" => time(), "subject" => '支付订单', "total_fee" => 0.01, "body" => '', "show_url" => '', "anti_phishing_key" => '', "exter_invoke_ip" => '', "_input_charset" => trim(strtolower($alipayConfig['input_charset']))), $parameter); $alipaySubmit = new AlipaySubmit($alipayConfig); $url = $alipaySubmit->alipay_gateway_new; $url .= $alipaySubmit->buildRequestParaToString($parameter); return $url; }
public function buildRequest($req) { include __DIR__ . '/mobiAlipay/lib/alipay_submit.class.php'; //构造要请求的参数数组 $parameter = array("service" => "alipay.wap.create.direct.pay.by.user", "partner" => trim($this->mobiAlipayConfig['partner']), "seller_id" => trim($this->mobiAlipayConfig['seller_id']), "payment_type" => '1', "notify_url" => trim($this->mobiAlipayConfig['notify_url']), "return_url" => trim($this->mobiAlipayConfig['return_url']), "out_trade_no" => $req['order_sn'], "subject" => $req['body'], "total_fee" => $req['order_paied'], "body" => $req['desc'], "_input_charset" => trim(strtolower($this->mobiAlipayConfig['input_charset']))); //建立请求 $alipaySubmit = new AlipaySubmit($this->mobiAlipayConfig); echo $alipaySubmit->buildRequestForm($parameter, 'get', ''); }
/** * 获取支付代码 * * @author andery * @param array $order_info 待支付的订单信息 * @return string */ public function get_html($order_info) { // 构造要请求的参数数组 $parameter = array("service" => "create_direct_pay_by_user", "partner" => trim($this->_config['partner']), "payment_type" => '1', "notify_url" => $this->_config['notify_url'], "return_url" => $this->_config['return_url'], "seller_email" => $this->_config['seller_email'], "_input_charset" => 'utf-8', "out_trade_no" => $order_info['order_id'], "subject" => $order_info['subject'], "total_fee" => $order_info['total_fee'], "body" => $order_info['body'], "show_url" => $order_info['show_url'], "anti_phishing_key" => '', "exter_invoke_ip" => ''); require_once "alipay/alipay_submit.class.php"; $alipaySubmit = new AlipaySubmit($this->_config); $html = $alipaySubmit->buildRequestForm($parameter, "get", "确认"); return $html; }
public function send($post) { require_once "lib/alipay_submit.class.php"; $parameter = array("service" => "send_goods_confirm_by_platform", "partner" => trim($this->alipay_config['partner']), "_input_charset" => trim(strtolower($this->alipay_config['input_charset'])), "trade_no" => $post['trade_no'], "logistics_name" => "无需物流", "invoice_no" => "", "transport_type" => "DIRECT", "create_transport_type" => "DIRECT", "seller_ip" => ""); $this->alipay_config['cacert'] = $this->cacert; $alipaySubmit = new AlipaySubmit($this->alipay_config); $html_text = $alipaySubmit->buildRequestHttp($parameter); return $html_text; }
public function refund($refundInfo = array()) { $parameter = array("service" => "refund_fastpay_by_platform_pwd", "partner" => trim($this->alipay_config['partner']), "notify_url" => $this->notify_url, "seller_email" => $this->alipay_config['seller_email'], "refund_date" => $refundInfo['refund_date'], "batch_no" => $refundInfo['batch_no'], "batch_num" => $refundInfo['batch_num'], "detail_data" => $refundInfo['detail_data'], "_input_charset" => trim(strtolower($this->alipay_config['input_charset']))); //建立请求 $alipaySubmit = new AlipaySubmit($this->alipay_config); $html_text = $alipaySubmit->buildRequestForm($parameter, "get", "确认"); //$html_text = $alipaySubmit->buildRequestHttp($parameter); echo $html_text; }