function alipay_link($params) { $_input_charset = "utf-8"; //字符编码格式 目前支持 GBK 或 utf-8 $sign_type = "MD5"; //加密方式 系统默认(不要修改) $transport = "https"; //访问模式,你可以根据自己的服务器是否支持ssl访问而选择http以及https访问模式(系统默认,不要修改) # Gateway Specific Variables $gatewayPID = $params['partnerID']; $gatewaySELLER_EMAIL = $params['seller_email']; $gatewaySECURITY_CODE = $params['security_code']; $TEST_MODE = $params['testmode']; # Invoice Variables $invoiceid = $params['invoiceid']; $description = $params["description"]; $amount = $params['amount']; # Format: ##.## $currency = $params['currency']; # Currency Code # System Variables $companyname = $params['companyname']; $systemurl = $params['systemurl']; $currency = $params['currency']; $notify_url = $systemurl . "/modules/gateways/callback/alipay.php"; $return_url = $systemurl; $parameter = array("service" => "create_direct_pay_by_user", "partner" => $gatewayPID, "return_url" => $systemurl . "/modules/gateways/callback/alipay_return.php", "notify_url" => $systemurl . "/modules/gateways/callback/alipay_callback.php", "_input_charset" => $_input_charset, "subject" => "{$companyname} 订单 {$invoiceid}", "body" => $description, "out_trade_no" => $invoiceid, "total_fee" => $amount, "payment_type" => "1", "show_url" => $systemurl, "seller_email" => $gatewaySELLER_EMAIL); $alipay = new alipay_service($parameter, $gatewaySECURITY_CODE, $sign_type); $link = $alipay->create_url(); $img = $systemurl . "/modules/gateways/callback/alipay.gif"; //这个图片要先存放好. $code = "<a href='{$link}'><img src='{$img}' alt='点击使用支付宝支付'></a>"; return $code; }
function makeurl(&$pay) { global $mcharset, $cms_abs; $parameter = array("service" => "create_direct_pay_by_user", "partner" => $pay->partner, "return_url" => $pay->return_url, "notify_url" => $pay->notify_url, "_input_charset" => $mcharset, "subject" => $pay->subject, "body" => $pay->content, "out_trade_no" => $pay->order_sn, "price" => $pay->totalfee, "payment_type" => '1', "show_url" => $cms_abs, "seller_email" => $pay->account); $alipay = new alipay_service($parameter, $pay->keyt, 'MD5', $mcharset, 'http'); return $alipay->create_url(); }
public function getPayItemList($pageNo, $pageSize, $startTime, $endTime) { /*{{{*/ DBC::requireTrue(XDateTime::getSecondDiffDesc($endTime, $startTime) < 3600, "查询时间不能超过一天"); $parameter = array("service" => "account.page.query", "partner" => $this->partner, "_input_charset" => $this->_input_charset, "page_no" => $pageNo, "page_size" => $pageSize, "gmt_start_time" => $startTime, "gmt_end_time" => $endTime, "logon_id" => "", "trade_no" => "", "merchant_out_order_no" => "", "deposit_bank_no" => "", "trans_code" => ""); $alipay = new alipay_service($parameter, $this->security_code, $this->sign_type); $url = $alipay->create_url(); return $url; }
public function index() { $data['button_confirm'] = $this->language->get('button_confirm'); $data['button_back'] = $this->language->get('button_back'); $data['return'] = HTTPS_SERVER . 'index.php?route=checkout/success'; if ($this->request->get['route'] != 'checkout/guest_step_3') { $data['cancel_return'] = HTTPS_SERVER . 'index.php?route=checkout/payment'; } else { $data['cancel_return'] = HTTPS_SERVER . 'index.php?route=checkout/guest_step_2'; } $this->load->library('encryption'); $encryption = new Encryption($this->config->get('config_encryption')); $data['custom'] = $encryption->encrypt($this->session->data['order_id']); if ($this->request->get['route'] != 'checkout/guest_step_3') { $data['back'] = HTTPS_SERVER . 'index.php?route=checkout/payment'; } else { $data['back'] = HTTPS_SERVER . 'index.php?route=checkout/guest_step_2'; } $this->load->model('checkout/order'); $order_id = $this->session->data['order_id']; $order_info = $this->model_checkout_order->getOrder($order_id); $seller_email = $this->config->get('alipay_seller_email'); $security_code = $this->config->get('alipay_security_code'); $trade_type = $this->config->get('alipay_trade_type'); $partner = $this->config->get('alipay_partner'); $currency_code = 'CNY'; $item_name = $this->config->get('config_name'); $full_name = $order_info['payment_fullname']; $total = $order_info['total']; $currency_value = $this->currency->getValue($currency_code); $amount = $total * $currency_value; $amount = number_format($amount, 2, '.', ''); $_input_charset = "utf-8"; $sign_type = "MD5"; $transport = "http"; $notify_url = HTTP_SERVER . 'catalog/controller/payment/alipay_callback.php'; $return_url = HTTPS_SERVER . 'index.php?route=checkout/success'; $show_url = ""; $parameter = array("service" => $trade_type, "partner" => $partner, "return_url" => $return_url, "notify_url" => $notify_url, "_input_charset" => $_input_charset, "subject" => $item_name . ' Order:' . $order_id, "body" => 'Owner ' . $full_name, "out_trade_no" => $order_id, "price" => $amount, "payment_type" => "1", "quantity" => "1", "logistics_fee" => '0.00', "logistics_payment" => 'BUYER_PAY', "logistics_type" => 'EXPRESS', "show_url" => $show_url, "seller_email" => $seller_email); $alipay = new alipay_service($parameter, $security_code, $sign_type); $action = $alipay->build_url(); $data['action'] = $action; //$this->id = 'payment'; // Save payment url address for pay later. $this->model_checkout_order->setOrderPaymentUrl($order_id, $action); // log_result("Alipay test 111111111111"); if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/payment/alipay.tpl')) { return $this->load->view($this->config->get('config_template') . '/template/payment/alipay.tpl', $data); } else { return $this->load->view('default/template/payment/alipay.tpl', $data); } }
function get_code($order, $payment) { global $_CFG; if (!is_array($order) || !is_array($payment)) { return false; } $partner = trim($payment['partnerid']); $key = trim($payment['ytauthkey']); $seller_email = trim($payment['parameter1']); $notify_url = $order['n_url']; $return_url = $order['v_url']; $show_url = $_CFG['site_domain'] . $_CFG['site_dir']; $mainname = $_CFG['site_name']; $sign_type = "MD5"; $_input_charset = "GBK"; $transport = "http"; $out_trade_no = $order['oid']; //请与贵网站订单系统中的唯一订单号匹配 $subject = "订单号:" . $out_trade_no; $body = $order['remark1']; $total_fee = intval($order['v_amount']); //扩展功能参数——默认支付方式 $pay_mode = $_POST['pay_bank']; if ($pay_mode == "directPay") { $paymethod = "directPay"; $defaultbank = ""; } else { $paymethod = "bankPay"; $defaultbank = $pay_mode; } $anti_phishing_key = ''; //防钓鱼时间戳 $exter_invoke_ip = ''; //获取客户端的IP地址,建议:编写获取客户端IP地址的程序 $extra_common_param = ''; //自定义参数,可存放任何内容(除=、&等特殊字符外),不会显示在页面上 $buyer_email = ''; //默认买家支付宝账号 $royalty_type = ""; //提成类型,该值为固定值:10,不需要修改 $royalty_parameters = ""; $parameter = array("service" => "create_direct_pay_by_user", "payment_type" => "1", "partner" => $partner, "seller_email" => $seller_email, "return_url" => $return_url, "notify_url" => $notify_url, "_input_charset" => $_input_charset, "show_url" => $show_url, "out_trade_no" => $out_trade_no, "subject" => $subject, "body" => $body, "total_fee" => $total_fee, "paymethod" => $paymethod, "defaultbank" => $defaultbank, "anti_phishing_key" => $anti_phishing_key, "exter_invoke_ip" => $exter_invoke_ip, "buyer_email" => $buyer_email, "extra_common_param" => $extra_common_param, "royalty_type" => $royalty_type, "royalty_parameters" => $royalty_parameters); $alipay = new alipay_service($parameter, $key, $sign_type); $sHtmlText = $alipay->build_form(); $sHtmlText .= "<input type=\"button\" class=\"but130lan intrgration_but\" value=\"确认支付\" onclick=\"document.forms['alipaysubmit'].submit()\"/>"; return $sHtmlText; }
function espresso_display_alipay($payment_data) { extract($payment_data); global $org_options; $alipay_settings = get_option('event_espresso_alipay_settings'); require_once "alipay_service.php"; require_once "alipay_config.php"; $parameter = array("service" => "create_forex_trade", "partner" => $partner, "return_url" => $return_url, "notify_url" => $notify_url, "_input_charset" => $_input_charset, "subject" => stripslashes_deep($event_name), "body" => stripslashes_deep($event_name), "out_trade_no" => time(), "total_fee" => '0.01', "currency" => "USD"); $alipay = new alipay_service($parameter, $security_code, $sign_type); //echo "<pre>", print_r( $parameter ), "</pre>"; $link = $alipay->create_url(); $link_anchor = isset($alipay_settings['button_url']) ? "<li><img src='" . $alipay_settings['button_url'] . "' alt='" . __('Pay using Alipay', 'event espresso') . "' />" : __('Pay using Alipay', 'event espresso'); print <<<EOT <br/> <a href= {$link} target= "">{$link_anchor}</a></li> EOT; }
function espresso_display_alipay($payment_data) { extract($payment_data); global $org_options; $alipay_settings = get_option('event_espresso_alipay_settings'); require_once "alipay_service.php"; require_once "alipay_config.php"; $parameter = array("service" => "create_forex_trade", "partner" => $partner, "return_url" => $return_url, "notify_url" => $notify_url, "_input_charset" => $_input_charset, "subject" => stripslashes_deep($event_name), "body" => stripslashes_deep($event_name), "out_trade_no" => time(), "total_fee" => '0.01', "currency" => "USD"); $alipay = new alipay_service($parameter, $security_code, $sign_type); //echo "<pre>", print_r( $parameter ), "</pre>"; $link = $alipay->create_url(); $link_anchor = isset($alipay_settings['button_url']) ? "<img src='" . $alipay_settings['button_url'] . "' alt='" . __('Pay using Alipay', 'event espresso') . "' />" : __('Pay using Alipay', 'event espresso'); $ee_images_url = EVENT_ESPRESSO_PLUGINFULLURL; print <<<EOT \t\t <div id="alipay-payment-option-dv" class="off-site-payment-gateway payment-option-dv"> \t\t\t<img class="off-site-payment-gateway-img" width="16" height="16" src="{$ee_images_url}/images/icons/external-link.png" alt="click to visit this payment gateway"> \t\t\t<a class="payment-option-lnk" href= {$link} target= "">{$link_anchor}</a> \t\t</div> EOT; }
function index_f() { $sn = $this->trans_lib->safe("sn"); $paycode = "alipay"; $pass = $this->trans_lib->safe("pass"); $rs = $this->payment_m->get_one_code($paycode); if (!$rs) { error($this->lang["alipay_not_rs"], $this->url("checkout,info", "sn=" . $sn . "&pass="******"user_id"]) { if (!$pass || $pass != $order_rs["pass"]) { error($this->lang["alipay_not_popedom"], $this->url("index")); } } else { if ($_SESSION["user_id"] != $order_rs["uid"]) { error($this->lang["alipay_not_popedom"], $this->url("index")); } } $this->tpl->assign("order_rs", $order_rs); if ($order_rs["pay_status"]) { error($this->lang["alipay_paystatus_ok"], $this->url("checkout,info", "sn=" . $sn . "&pass="******"price"] < 0.001) { error($this->lang["alipay_free"], $this->url("checkout,info", "sn=" . $sn . "&pass="******"id"]); //判断是否是客 //加载alipay付款类 $return_url = $this->sys_config["siteurl"] . site_url("alipay,return", "sn=" . $sn . "&pass="******"pass"]); $show_url = $this->sys_config["siteurl"] . site_url("checkout,info", "sn=" . $sn . "&pass="******"pass"]); $notify_url = $this->sys_config["siteurl"] . site_url("alipay,notify", "sn=" . $sn . "&pass="******"pass"]); $order_rs["pdate"] = date("Y-m-d H:i:s", $order_rs["postdate"]); $parameter = array("service" => "create_direct_pay_by_user", "partner" => $f_rs["partner"], "return_url" => $return_url, "notify_url" => $notify_url, "_input_charset" => $f_rs["charset"], "subject" => sys_eval($this->lang["alipay_order_title"], $order_rs), "body" => sys_eval($this->lang["alipay_order_body"], $order_rs), "out_trade_no" => $order_rs["sn"], "total_fee" => floatval($order_rs["price"]), "payment_type" => "1", "seller_email" => $f_rs["seller_email"], "show_url" => $show_url); include_once LIBS . "payment/alipay_service.php"; //加载alipay_server操作类 $alipay = new alipay_service($parameter, $f_rs["code"], "MD5"); $link = $alipay->create_url(); sys_header($link); }
<?php defined('IN_DESTOON') or exit('Access Denied'); require DT_ROOT . '/api/pay/' . $bank . '/service.class.php'; require DT_ROOT . '/api/pay/' . $bank . '/config.inc.php'; $parameter = array('service' => $service_type, 'partner' => $partner, 'return_url' => $return_url, 'notify_url' => $notify_url, '_input_charset' => $_input_charset, 'subject' => $DT['sitename'] . '会员充值', 'body' => $charge_title ? $charge_title : '会员(' . $_username . ')帐户充值(订单号:' . $orderid . ')', "out_trade_no" => $orderid, "price" => $charge, "payment_type" => "1", "quantity" => "1", "logistics_fee" => '0.00', "logistics_payment" => 'SELLER_PAY', "logistics_type" => 'EXPRESS', "show_url" => $show_url, "seller_email" => $seller_email, "buyer_email" => $_email); //对URL组合 $alipay = new alipay_service($parameter, $security_code, $sign_type); $URI = $alipay->create_url(); ?> <html> <head> <meta http-equiv="Content-Type" content="text/html;charset=<?php echo DT_CHARSET; ?> "> <title>正在跳转到<?php echo $PAY[$bank]['name']; ?> 在线支付平台...</title> <meta http-equiv="refresh" content="0;url=<?php echo $URI; ?> "> </head> <body> </body> </html>
<?php require_once "alipay_service.php"; require_once "alipay_config.php"; $parameter = array("service" => "forex_refund_file", "partner" => $partner, "_input_charset" => $_input_charset); $alipay = new alipay_service($parameter, $security_code, $sign_type); print_r($parameter); $link = $alipay->create_url(); print <<<EOT <br/> <a href= {$link} ></a> EOT; ?> <html> <head> <title>Alipay</title> </head> <body> <form name="alipaysubmit" enctype="multipart/form-data" target="_blank" method="post" action="https://www.alipay.com/cooperate/gateway.do?"> <input type="hidden" name="_input_charset" value="<?php echo $parameter['_input_charset']; ?> "> <input type="hidden" name="partner" value="<?php echo $parameter['partner']; ?> "> <input type="hidden" name="service" value="forex_refund_file"> <input type="hidden" name="sign" value="<?php echo $alipay->signParams();
protected function index() { // 为 alipay.tpl 准备数据 $this->data['button_confirm'] = $this->language->get('button_confirm'); $this->data['button_back'] = $this->language->get('button_back'); // url $this->data['return'] = HTTPS_SERVER . 'index.php?route=checkout/success'; if ($this->request->get['route'] != 'checkout/guest_step_3') { $this->data['cancel_return'] = HTTPS_SERVER . 'index.php?route=checkout/payment'; } else { $this->data['cancel_return'] = HTTPS_SERVER . 'index.php?route=checkout/guest_step_2'; } $this->load->library('encryption'); $encryption = new Encryption($this->config->get('config_encryption')); $this->data['custom'] = $encryption->encrypt($this->session->data['order_id']); if ($this->request->get['route'] != 'checkout/guest_step_3') { $this->data['back'] = HTTPS_SERVER . 'index.php?route=checkout/payment'; } else { $this->data['back'] = HTTPS_SERVER . 'index.php?route=checkout/guest_step_2'; } // 获取订单数据 $this->load->model('checkout/order'); $order_id = $this->session->data['order_id']; $order_info = $this->model_checkout_order->getOrder($order_id); /* $this->data['business'] = $this->config->get('alipay_direct_seller_email'); $this->data['item_name'] = html_entity_decode($this->config->get('config_store'), ENT_QUOTES, 'UTF-8'); $this->data['currency_code'] = $order_info['currency']; $this->data['tgw'] = $this->session->data['order_id']; $this->data['amount'] = $this->currency->format($order_info['total'], $order_info['currency'], $order_info['value'], FALSE); $this->data['total'] = $order_info['total']; $this->data['currency'] = $order_info['currency']; $this->data['value'] = $order_info['value']; $this->data['first_name'] = html_entity_decode($order_info['payment_firstname'], ENT_QUOTES, 'UTF-8'); $this->data['last_name'] = html_entity_decode($order_info['payment_lastname'], ENT_QUOTES, 'UTF-8'); $this->data['address1'] = html_entity_decode($order_info['payment_address_1'], ENT_QUOTES, 'UTF-8'); $this->data['address2'] = html_entity_decode($order_info['payment_address_2'], ENT_QUOTES, 'UTF-8'); $this->data['city'] = html_entity_decode($order_info['payment_city'], ENT_QUOTES, 'UTF-8'); $this->data['zip'] = html_entity_decode($order_info['payment_postcode'], ENT_QUOTES, 'UTF-8'); $this->data['country'] = $order_info['payment_iso_code_2']; $this->data['notify_url'] = $this->url->http('payment/alipay/callback'); $this->data['email'] = $order_info['email']; $this->data['invoice'] = $this->session->data['order_id'] . ' - ' . html_entity_decode($order_info['payment_firstname'], ENT_QUOTES, 'UTF-8') . ' ' . html_entity_decode($order_info['payment_lastname'], ENT_QUOTES, 'UTF-8'); $this->data['lc'] = $this->session->data['language']; */ // 计算提交地址 $seller_email = $this->config->get('alipay_direct_seller_email'); // 商家邮箱 $security_code = $this->config->get('alipay_direct_security_code'); //安全检验码 $partner = $this->config->get('alipay_direct_partner'); //合作伙伴ID $currency_code = $this->config->get('alipay_direct_currency_code'); //人民币代号(CNY) $item_name = $this->config->get('config_store'); $first_name = $order_info['payment_firstname']; $last_name = $order_info['payment_lastname']; $total = $order_info['total']; if ($currency_code == '') { $currency_code = 'CNY'; } $currency_value = $this->currency->getValue($currency_code); $amount = $total * $currency_value; $amount = number_format($amount, 2, '.', ''); //$this->data['amount'] = html_entity_decode($this->config->get('config_store'), ENT_QUOTES, 'GB2312'); $_input_charset = "utf-8"; //字符编码格式 目前支持 GBK 或 utf-8 $sign_type = "MD5"; //加密方式 系统默认(不要修改) $transport = "http"; //访问模式,你可以根据自己的服务器是否支持ssl访问而选择http以及https访问模式(系统默认,不要修改) $notify_url = HTTP_SERVER . 'catalog/controller/payment/alipay_direct_notify_url.php'; $return_url = HTTPS_SERVER . 'index.php?route=checkout/success'; $show_url = ""; //你网站商品的展示地址 $out_trade_no = $order_id; $subject = 'Order ID ' . $order_id . ' of ' . $item_name; //商品名称,必填 $body = 'for ' . $last_name . ' ' . $first_name; //商品描述,必填 $total_fee = $amount; //扩展功能参数——默认支付方式 $paymethod = "directPay"; //默认支付方式,四个值可选:bankPay(网银); cartoon(卡通); directPay(余额); CASH(网点支付) $defaultbank = ""; $pay_mode = !empty($this->session->data['alipay_direct_method']) ? $this->session->data['alipay_direct_method'] : ''; if ($pay_mode != '') { $paymethod = "bankPay"; //默认支付方式,四个值可选:bankPay(网银); cartoon(卡通); directPay(余额); CASH(网点支付) $defaultbank = $pay_mode; //默认网银代号,代号列表见http://club.alipay.com/read.php?tid=8681379 } //扩展功能参数——防钓鱼 //请慎重选择是否开启防钓鱼功能 //exter_invoke_ip、anti_phishing_key一旦被设置过,那么它们就会成为必填参数 //开启防钓鱼功能后,服务器、本机电脑必须支持远程XML解析,请配置好该环境。 //若要使用防钓鱼功能,请打开class文件夹中alipay_function.php文件,找到该文件最下方的query_timestamp函数,根据注释对该函数进行修改 //建议使用POST方式请求数据 $anti_phishing_key = ''; //防钓鱼时间戳 $exter_invoke_ip = ''; //获取客户端的IP地址,建议:编写获取客户端IP地址的程序 //如: //$exter_invoke_ip = '202.1.1.1'; //$anti_phishing_key = query_timestamp($partner); //获取防钓鱼时间戳函数 //扩展功能参数——其他 $extra_common_param = ''; //自定义参数,可存放任何内容(除=、&等特殊字符外),不会显示在页面上 $buyer_email = ''; //默认买家支付宝账号 //扩展功能参数——分润(若要使用,请按照注释要求的格式赋值) $royalty_type = ""; //提成类型,该值为固定值:10,不需要修改 $royalty_parameters = ""; //提成信息集,与需要结合商户网站自身情况动态获取每笔交易的各分润收款账号、各分润金额、各分润说明。最多只能设置10条 //各分润金额的总和须小于等于total_fee //提成信息集格式为:收款方Email_1^金额1^备注1|收款方Email_2^金额2^备注2 //如: //royalty_type = "10" //royalty_parameters = "111@126.com^0.01^分润备注一|222@126.com^0.01^分润备注二" //构造要请求的参数数组,无需改动 $parameter = array("service" => "create_direct_pay_by_user", "payment_type" => "1", "partner" => $partner, "seller_email" => $seller_email, "return_url" => $return_url, "notify_url" => $notify_url, "_input_charset" => $_input_charset, "show_url" => $show_url, "out_trade_no" => $out_trade_no, "subject" => $this->config->get('config_name') . ' - #' . $order_id, "body" => $this->config->get('config_name') . ' - #' . $order_id, "total_fee" => $total_fee, "paymethod" => $paymethod, "defaultbank" => $defaultbank, "anti_phishing_key" => $anti_phishing_key, "exter_invoke_ip" => $exter_invoke_ip, "buyer_email" => $buyer_email, "extra_common_param" => $extra_common_param, "royalty_type" => $royalty_type, "royalty_parameters" => $royalty_parameters); /* $parameter = array( "service" => "create_partner_trade_by_buyer", //交易类型 "partner" => $partner, //合作商户号 "return_url" => $return_url, //同步返回 "notify_url" => $notify_url, //异步返回 "_input_charset" => $_input_charset, //字符集,默认为GBK "subject" => 'Order ID ' . $order_id . ' of ' .$item_name, //商品名称,必填 "body" => 'for ' . $last_name . ' ' . $first_name, //商品描述,必填 "out_trade_no" => $order_id,//'3',//date('Ymdhms'), //商品外部交易号,必填(保证唯一性) "price" => $amount, //商品单价,必填(价格不能为0) "payment_type" => "1", //默认为1,不需要修改 "quantity" => "1", //商品数量,必填 "logistics_fee" =>'0.00', //物流配送费用 "logistics_payment" =>'BUYER_PAY', //物流费用付款方式:SELLER_PAY(卖家支付)、BUYER_PAY(买家支付)、BUYER_PAY_AFTER_RECEIVE(货到付款) "logistics_type" =>'EXPRESS', //物流配送方式:POST(平邮)、EMS(EMS)、EXPRESS(其他快递) "show_url" => $show_url, //商品相关网站 "seller_email" => $seller_email //卖家邮箱,必填 ); */ $alipay = new alipay_service($parameter, $security_code, $sign_type); $action = $alipay->create_url(); $this->data['action'] = $action; $this->id = 'payment'; if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/payment/alipay_direct.tpl')) { $this->template = $this->config->get('config_template') . '/template/payment/alipay_direct.tpl'; } else { $this->template = 'default/template/payment/alipay_direct.tpl'; } $this->render(); }
/** * Process the payment and return the result **/ function process_payment($order_id) { global $woocommerce; require_once "alipay_config.php"; require_once "class/alipay_service.php"; $order = new WC_Order($order_id); if (sizeof($order->get_items()) > 0) { foreach ($order->get_items() as $item) { if ($item['qty']) { $item_names[] = $item['name'] . ' x ' . $item['qty']; } } } //扩展功能参数——默认支付方式 $paymethod = "directPay"; //默认支付方式,四个值可选:bankPay(网银); cartoon(卡通); directPay(余额); CASH(网点支付) $defaultbank = ""; //扩展功能参数——防钓鱼 //请慎重选择是否开启防钓鱼功能 //exter_invoke_ip、anti_phishing_key一旦被使用过,那么它们就会成为必填参数 //开启防钓鱼功能后,服务器、本机电脑必须支持远程XML解析,请配置好该环境。 //若要使用防钓鱼功能,请打开class文件夹中alipay_function.php文件,找到该文件最下方的query_timestamp函数,根据注释对该函数进行修改 //建议使用POST方式请求数据 $anti_phishing_key = ''; //防钓鱼时间戳 $exter_invoke_ip = ''; //获取客户端的IP地址,建议:编写获取客户端IP地址的程序 //如: //$exter_invoke_ip = '202.1.1.1'; //$anti_phishing_key = query_timestamp($partner); //获取防钓鱼时间戳函数 //扩展功能参数——其他 $extra_common_param = ''; //自定义参数,可存放任何内容(除=、&等特殊字符外),不会显示在页面上 $buyer_email = ''; //默认买家支付宝账号 //扩展功能参数——分润(若要使用,请按照注释要求的格式赋值) $royalty_type = ""; //提成类型,该值为固定值:10,不需要修改 $royalty_parameters = ""; //提成信息集,与需要结合商户网站自身情况动态获取每笔交易的各分润收款账号、各分润金额、各分润说明。最多只能设置10条 //各分润金额的总和须小于等于total_fee //提成信息集格式为:收款方Email_1^金额1^备注1|收款方Email_2^金额2^备注2 //如: //royalty_type = "10" //royalty_parameters = "111@126.com^0.01^分润备注一|222@126.com^0.01^分润备注二" ///////////////////////////////////////////////// //构造要请求的参数数组,无需改动 $parameter = array("service" => "create_direct_pay_by_user", "payment_type" => "1", "partner" => $partner, "seller_email" => $seller_email, "return_url" => $return_url, "notify_url" => $notify_url, "_input_charset" => $_input_charset, "show_url" => get_bloginfo('wpurl'), "out_trade_no" => 'CIP' . $order_id, "subject" => implode(',', $item_names), "body" => implode(',', $item_names), "total_fee" => number_format($order->get_order_total() - $order->get_total_discount(), 2, '.', ''), "paymethod" => $paymethod, "defaultbank" => $defaultbank, "anti_phishing_key" => $anti_phishing_key, "exter_invoke_ip" => $exter_invoke_ip, "buyer_email" => $buyer_email, "extra_common_param" => $extra_common_param, "royalty_type" => $royalty_type, "royalty_parameters" => $royalty_parameters); //构造请求函数 $alipay = new alipay_service($parameter, $key, $sign_type); $sHtmlText = $alipay->build_form(); $html = "<html>\r\n\t\t\t<head>\r\n\t\t\t\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\r\n\t\t\t\t<title>正在前往支付宝...</title>\r\n\t\t\t</head>\r\n\t\t\t<body><div style='display:none'>{$sHtmlText}</div"; echo $html; exit; return array('result' => 'success', 'redirect' => $sHtmlText); }
*详细:该页面是调用底层接口并返回处理结果页面 *版本:2.0 *修改日期:2011-09-06 '说明: '以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己网站的需要,按照技术文档编写,并非一定要使用该代码。 '该代码仅供学习和研究支付宝接口使用,只是提供一个参考。 */ require_once "alipay_config.php"; require_once "class/alipay_service.php"; /** * ****************************alipay_wap_trade_create_direct************************************* */ // 构造要请求的参数数组,无需改动 $pms1 = array("req_data" => '<direct_trade_create_req><subject>' . $subject . '</subject><out_trade_no>' . $out_trade_no . '</out_trade_no><total_fee>' . $total_fee . "</total_fee><seller_account_name>" . $seller_email . "</seller_account_name><notify_url>" . $notify_url . "</notify_url><out_user>" . $_GET["out_user"] . "</out_user><merchant_url>" . $merchant_url . "</merchant_url>" . "<call_back_url>" . $call_back_url . "</call_back_url></direct_trade_create_req>", "service" => $Service_create, "sec_id" => $sec_id, "partner" => $partner, "req_id" => date("Ymdhms"), "format" => $format, "v" => $v); // 构造请求函数 $alipay = new alipay_service(); // 调用alipay_wap_trade_create_direct接口,并返回token返回参数 $token = $alipay->alipay_wap_trade_create_direct($pms1); /** * ************************************************************************************************ */ /** * *******************************alipay_Wap_Auth_AuthAndExecute*********************************** */ // 构造要请求的参数数组,无需改动 $pms2 = array("req_data" => "<auth_and_execute_req><request_token>" . $token . "</request_token></auth_and_execute_req>", "service" => $Service_authAndExecute, "sec_id" => $sec_id, "partner" => $partner, "call_back_url" => $call_back_url, "format" => $format, "v" => $v); // 调用alipay_Wap_Auth_AuthAndExecute接口方法,并重定向页面 $alipay->alipay_Wap_Auth_AuthAndExecute($pms2); /** * ************************************************************************************************ */
public function lianjie($params) { //print_r($params);exit(); require_once "alipay_service.php"; //组合支付宝链接 if (!intval($params['cart']->id_currency)) { $currency = new Currency(intval($params['cookie']->id_currency)); } else { $currency = new Currency(intval($params['cart']->id_currency)); } if (!Validate::isLoadedObject($currency)) { $currency = new Currency(intval(Configuration::get('PS_DEFAULT_CURRENCY'))); } //这段是调出购物车的商品内容 $pric = $params['cart']->getOrderTotal(); $productsinfo = $params['cart']->getProducts(true); //这段是调出物流费用的 $shipping_cost = "0"; $parameter = array("service" => "trade_create_by_buyer", "partner" => $this->partner, "return_url" => $this->return_url, "_input_charset" => $this->_input_charset, "subject" => date(Ymdhms), "body" => $productsinfo[0][description_short], "out_trade_no" => date(Ymdhms), "logistics_fee" => $shipping_cost, "logistics_payment" => 'BUYER_PAY', "logistics_type" => 'EXPRESS', "price" => $pric, "payment_type" => "1", "quantity" => "1", "show_url" => $this->show_url, "seller_email" => $this->seller_email); $alipay = new alipay_service($parameter, $this->security_code, $this->sign_type); $link = $alipay->create_url(); //$link="http://www.baidu.com"; return $link; }
<?php include_once CFG_CACHEPATH . '/sys_pay.cache.php'; //支付配置文件 require_once dirname(__FILE__) . "/alipay_config.php"; require_once dirname(__FILE__) . "/alipay_service.php"; $price = sprintf("%01.2f", $priceCount); $parameter = array("service" => "create_direct_pay_by_user", "partner" => $partner, "return_url" => $return_url, "notify_url" => $notify_url, "_input_charset" => $_input_charset, "subject" => "账户充值订单号:" . $OrdersId, "body" => "支付金额:" . $price . "元", "out_trade_no" => $OrdersId, "logistics_fee" => '0.00', "logistics_payment" => 'BUYER_PAY', "logistics_type" => 'EXPRESS', "price" => $price, "payment_type" => "1", "quantity" => "1", "show_url" => $show_url, "seller_email" => $seller_email); $alipay = new alipay_service($parameter, $security_code, $sign_type); $strRequestUrl = $alipay->create_url(); echo '<html> <head> <title>转到支付宝支付页面</title> </head> <body onLoad="document.alipay.submit();"> <form name="alipay" action="' . $strRequestUrl . '" method="post"> </form> </body> </html>'; exit;
<?php require_once "alipay_config.php"; require_once "class/alipay_service.php"; // 构造要请求的参数数组,无需改动 $pms1 = array("req_data" => '<direct_trade_create_req><subject>' . $subject . '</subject><out_trade_no>' . $out_trade_no . '</out_trade_no><total_fee>' . $total_fee . "</total_fee><seller_account_name>" . $seller_email . "</seller_account_name><notify_url>" . $notify_url . "</notify_url><out_user>" . $_GET["out_user"] . "</out_user><merchant_url>" . $merchant_url . "</merchant_url>" . "<call_back_url>" . $call_back_url . "</call_back_url></direct_trade_create_req>", "service" => $Service_Create, "sec_id" => $sec_id, "partner" => $partner, "req_id" => date("Ymdhms"), "format" => $format, "v" => $v); // 构造请求函数 $alipay = new alipay_service(); // 调用alipay_wap_trade_create_direct接口,并返回token返回参数 $token = $alipay->alipay_wap_trade_create_direct($pms1, $key, $sec_id); // 构造要请求的参数数组,无需改动 $pms2 = array("req_data" => "<auth_and_execute_req><request_token>" . $token . "</request_token></auth_and_execute_req>", "service" => $Service_authAndExecute, "sec_id" => $sec_id, "partner" => $partner, "call_back_url" => $call_back_url, "format" => $format, "v" => $v); // 调用alipay_Wap_Auth_AuthAndExecute接口方法,并重定向页面 $ruselt_url = $alipay->alipay_Wap_Auth_AuthAndExecute($pms2, $key);
//客户端的IP地址,初始值 if ($antiphishing == 1) { $encrypt_key = query_timestamp($partner); $exter_invoke_ip = ''; //获取客户端的IP地址,建议:编写获取客户端IP地址的程序 } //扩展功能参数——其他 $extra_common_param = $_POST['pay_type']; //自定义参数,可存放任何内容(除=、&等特殊字符外),不会显示在页面上 $buyer_email = ''; //默认买家支付宝账号 ///////////////////////////////////////////////// //构造要请求的参数数组 $parameter = array("service" => "create_direct_pay_by_user", "payment_type" => "1", "partner" => $partner, "seller_email" => $seller_email, "return_url" => $return_url, "notify_url" => $notify_url, "_input_charset" => $_input_charset, "show_url" => $show_url, "out_trade_no" => $out_trade_no, "subject" => $subject, "body" => $body, "total_fee" => $total_fee, "paymethod" => $paymethod, "defaultbank" => $defaultbank, "anti_phishing_key" => $encrypt_key, "exter_invoke_ip" => $exter_invoke_ip, "buyer_email" => $buyer_email, "extra_common_param" => $extra_common_param); //构造请求函数 $alipay = new alipay_service($parameter, $security_code, $sign_type); //若改成GET方式传递 $url = $alipay->create_url(); $sHtmlText = "<a href=" . $url . "><img border='0' src='images/alipay.gif' /></a>"; echo "<script>window.location =\"{$url}\";</script>"; //POST方式传递,得到加密结果字符串,请取消下面一行的注释 //$sHtmlText = $alipay->build_postform(); ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>支付宝即时支付</title> <style type="text/css"> .font_content{ font-family:"宋体"; font-size:14px;
public function reorder() { $this->data['button_confirm'] = $this->language->get('button_reoder_confirm'); $this->data['button_back'] = $this->language->get('button_back'); $this->data['return'] = $this->url->link('checkout/success', '', 'SSL'); $this->load->library('encryption'); $encryption = new Encryption($this->config->get('config_encryption')); $order_id = $this->request->get['order_id']; $this->data['custom'] = $encryption->encrypt($order_id); $this->load->model('checkout/order'); $order_info = $this->model_checkout_order->getOrder($order_id); $seller_email = $this->config->get('alipay_seller_email'); $security_code = $this->config->get('alipay_security_code'); $trade_type = $this->config->get('alipay_trade_type'); $partner = $this->config->get('alipay_partner'); $currency_code = 'CNY'; $item_name = $this->config->get('config_name'); $first_name = $order_info['payment_firstname']; $last_name = $order_info['payment_lastname']; $total = $order_info['total']; $currency_value = $this->currency->getValue($currency_code); $amount = $total * $currency_value; $amount = number_format($amount, 2, '.', ''); $_input_charset = "utf-8"; $sign_type = "MD5"; $transport = "http"; $notify_url = HTTP_SERVER . 'catalog/controller/payment/alipay_callback.php'; $return_url = HTTPS_SERVER . 'index.php?route=account/paysuccess'; $show_url = ""; $parameter = array("service" => $trade_type, "partner" => $partner, "return_url" => $return_url, "notify_url" => $notify_url, "_input_charset" => $_input_charset, "subject" => $item_name . $this->language->get('text_order_no') . $order_id, "body" => $item_name, "out_trade_no" => $order_id, "price" => $amount, "payment_type" => "1", "quantity" => "1", "logistics_fee" => '0.00', "logistics_payment" => 'BUYER_PAY', "logistics_type" => 'EXPRESS', "show_url" => $show_url, "seller_email" => $seller_email); $alipay = new alipay_service($parameter, $security_code, $sign_type); $action = $alipay->build_url(); $this->data['reorder'] = true; $this->data['action'] = $action; $this->id = 'payment'; if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/payment/alipay.tpl')) { $this->template = $this->config->get('config_template') . '/template/payment/alipay.tpl'; } else { $this->template = 'default/template/payment/alipay.tpl'; } $this->render(); }
<?php /** * 名称 创建交易页面 * 功能 支付宝外部服务接口控制 * 版本 0.6 * 日期 2006-6-10 * 作者 http://www.buybay.org * 联系 Email: raftcham@hotmail.com Homepage:http://www.buybay.org * 版权 Copyright2006 Buybay NetTech */ require_once "alipay_service.php"; require_once "alipay_config.php"; $parameter = array("service" => "create_direct_pay_by_user", "partner" => $partner, "agent" => $agent, "return_url" => $return_url, "notify_url" => $notify_url, "_input_charset" => $_input_charset, "subject" => "多项测试", "body" => "jhshs哈哈1234567", "out_trade_no" => time(), "total_fee" => "0.01", "payment_type" => "1", "show_url" => "http://www.buyaby.org/", "seller_email" => $seller_email, "paymethod" => "bankPay", "defaultbank" => "CMB", "royalty_type" => "10", "royalty_parameters" => "yao2857@yahoo.com.cn^0.01^机票测试"); $alipay = new alipay_service($parameter, $security_code, $sign_type); print_r($parameter); $link = $alipay->create_url(); print <<<EOT <br/> <a href= {$link} target ="_blank">submit</a> EOT; ?>
public function index() { $currency_code = 'CNY'; $_input_charset = "utf-8"; $sign_type = "MD5"; $transport = "http"; $notify_url = HTTP_SERVER . 'catalog/controller/payment/alipay_callback.php'; $return_url = HTTPS_SERVER . 'index.php?route=payment/paysuccess'; $trade_type = $this->config->get('alipay_trade_type'); $partner = $this->config->get('alipay_partner'); $security_code = $this->config->get('alipay_security_code'); $item_name = $this->config->get('config_store'); $seller_email = $this->config->get('alipay_seller_email'); $trade_type_international = "alipay.trade.direct.forcard.pay"; $partner_international = "2088511796637269"; //$partner_international = "2088011357497434"; $security_code_international = "lzwlxledgojm22pz0vgkjtjkm907agf2"; //$security_code_international = "qo58xp4g1ywibtiiyns1gftw5mbv5rs3"; $seller_email_international = "*****@*****.**"; //$seller_email_international = "*****@*****.**"; $this->load->library('encryption'); $encryption = new Encryption($this->config->get('config_encryption')); $this->load->model('checkout/order'); $this->load->model('account/customer'); if (isset($this->session->data['customer_id'])) { $customer_id = $this->customer->getId(); if ($this->request->server['REQUEST_METHOD'] == 'POST' && isset($this->request->post['action']) && "recharge" == $this->request->post['action']) { //$return_url = HTTPS_SERVER . 'index.php?route=account/rmbaccount'; //人民币充值金额 if (isset($this->request->post['amount']) && $this->request->post['amount']) { $amount = $this->request->post['amount']; } else { $amount = ''; } if (isset($this->request->post['money']) && $this->request->post['money']) { $money = $this->request->post['money']; } else { $money = ''; } $this->load->model('account/rechargerecord'); $first_name = $this->customer->getFirstName(); $accountmoney = $this->customer->getMoney(); if (isset($this->request->post['js_return']) && $this->request->post['js_return']) { $security_code = $security_code_international; $extend_param = $this->request->post['js_return']; //$notify_url = HTTP_SERVER . 'catalog/controller/payment/callback_international.php'; if (isset($this->request->post['type']) && $this->request->post['type']) { $type = $this->request->post['type']; } $data = array("firstname" => $first_name, 'amount' => $amount, 'currency' => $currency_code, 'money' => $money, 'paytype' => '3', 'payname' => "支付宝国际信用卡", 'accountmoney' => $accountmoney + $money, 'addtime' => time(), 'state' => 0); $rid = $this->model_account_rechargerecord->addRechargerecord($data); $parameter = array("service" => $trade_type_international, "partner" => $partner_international, "return_url" => $return_url, "notify_url" => $notify_url, "_input_charset" => trim(strtolower($_input_charset)), "subject" => $item_name . ' Order:' . $rid, "out_trade_no" => 'cz-' . $rid . '-' . $customer_id, "default_bank" => "cybs-" . $type, "extend_param" => str_replace(" ", "", $extend_param), "total_fee" => $amount, "currency" => $currency_code, "paymethod" => trim("jvm-3d"), "sign_type" => "MD5", "sign" => $security_code_international, "seller_logon_id" => $seller_email_international); } else { if (isset($this->request->post['recharge_defaultbank']) && $this->request->post['recharge_defaultbank']) { $defaultbank = $this->request->post['recharge_defaultbank']; $payname = "网络银行"; } else { $defaultbank = ''; $payname = "支付宝"; } $data = array("firstname" => $first_name, 'amount' => $amount, 'currency' => $currency_code, 'money' => $money, 'paytype' => '2', 'payname' => $payname, 'accountmoney' => $accountmoney + $money, 'addtime' => time(), 'state' => 0); $rid = $this->model_account_rechargerecord->addRechargerecord($data); $parameter = array("paymethod" => "bankPay", "defaultbank" => $defaultbank, "service" => $trade_type, "partner" => $partner, "return_url" => $return_url, "notify_url" => $notify_url, "_input_charset" => $_input_charset, "subject" => $item_name . ' Order:' . $rid, "body" => 'Owner ' . $first_name, "out_trade_no" => 'cz-' . $rid . '-' . $customer_id, "total_fee" => $amount, "payment_type" => "1", "seller_email" => $seller_email); } $alipay = new alipay_service($parameter, $security_code, $sign_type); $action = $alipay->build_url(); $this->response->setOutput(json_encode($action)); } if ($this->request->server['REQUEST_METHOD'] == 'POST' && isset($this->request->post['action']) && "waybill" == $this->request->post['action']) { //$return_url = HTTPS_SERVER . 'index.php?route=order/order/order_guoji'; if (isset($this->request->post['js_return']) && $this->request->post['js_return']) { //$notify_url = HTTP_SERVER . 'catalog/controller/payment/callback_international.php'; if (isset($this->session->data['waybill'])) { $this->load->model('order/order'); $waybill = $this->session->data['waybill']; if (isset($this->request->post['type']) && $this->request->post['type']) { $type = $this->request->post['type']; } if (isset($this->request->post['amount']) && $this->request->post['amount']) { $amount = $this->request->post['amount']; } //测试专用 //$amount = 0.01; $extend_param = $this->request->post['js_return']; $security_code = $security_code_international; $parameter = array("service" => $trade_type_international, "partner" => $partner_international, "return_url" => $return_url, "notify_url" => $notify_url, "_input_charset" => $_input_charset, "subject" => $item_name . ' Order:' . $waybill, "out_trade_no" => 'yd-' . $waybill . '-' . $customer_id, "default_bank" => "cybs-" . $type, "extend_param" => str_replace(" ", "", $extend_param), "total_fee" => $amount, "payment_type" => "1", "paymethod" => trim("jvm-3d"), "sign_type" => "MD5", "sign" => $security_code_international, "seller_email" => $seller_email_international); } } else { // log_result("Waybill".$this->session->data['waybill']); if (isset($this->session->data['waybill'])) { $this->load->model('order/order'); //$return_url = HTTPS_SERVER . 'index.php?route=order/order/order_guoji'; $waybill = $this->session->data['waybill']; if (isset($this->request->post['amount']) && $this->request->post['amount']) { $amount = $this->request->post['amount']; } else { $amount = 0; } //测试专用 //$amount = 0.01; if (isset($this->request->post['waybill_defaultbank']) && $this->request->post['waybill_defaultbank']) { $defaultbank = $this->request->post['waybill_defaultbank']; } else { $defaultbank = ''; } $parameter = array("paymethod" => "bankPay", "defaultbank" => $defaultbank, "service" => $trade_type, "partner" => $partner, "return_url" => $return_url, "notify_url" => $notify_url, "_input_charset" => $_input_charset, "subject" => $item_name . ' Order:' . $waybill, "out_trade_no" => 'yd-' . $waybill . '-' . $customer_id, "total_fee" => $amount, "payment_type" => "1", "seller_email" => $seller_email); } } $alipay = new alipay_service($parameter, $security_code, $sign_type); $action = $alipay->build_url(); $this->response->setOutput(json_encode($action)); } if ($this->request->server['REQUEST_METHOD'] == 'POST' && isset($this->request->post['action']) && "order" == $this->request->post['action']) { //$return_url = HTTPS_SERVER . 'index.php?route=order/order'; if (isset($this->request->post['js_return']) && $this->request->post['js_return']) { if (isset($this->session->data['order_id'])) { $return_url = HTTPS_SERVER . 'index.php?route=order/order'; //$notify_url = HTTP_SERVER . 'catalog/controller/payment/callback_international.php'; $extend_param = $this->request->post['js_return']; $security_code = $security_code_international; $order_id_array = explode(",", $this->session->data['order_id']); $order_id = end($order_id_array); $amount = round($this->session->data['order_total'] * (1 + 0.01 + 0.001), 2); //测试专用 //$amount = 0.01; if (isset($this->request->post['type']) && $this->request->post['type']) { $type = $this->request->post['type']; } $parameter = array("service" => $trade_type_international, "partner" => $partner_international, "return_url" => $return_url, "notify_url" => $notify_url, "_input_charset" => trim(strtolower($_input_charset)), "subject" => $item_name . ' Order:' . $order_id, "out_trade_no" => $this->session->data['order_id'] . '-' . $customer_id, "default_bank" => "cybs-" . $type, "extend_param" => str_replace(" ", "", $extend_param), "total_fee" => $amount, "currency" => $currency_code, "paymethod" => trim("jvm-3d"), "sign_type" => "MD5", "sign" => $security_code_international, "seller_logon_id" => $seller_email_international); } } else { if (isset($this->session->data['order_id'])) { $order_id_array = explode(",", $this->session->data['order_id']); $order_id = end($order_id_array); $amount = round($this->session->data['order_total'] * (1 + 0.01 + 0.001), 2); if (isset($this->request->post['order_defaultbank']) && $this->request->post['order_defaultbank']) { $defaultbank = $this->request->post['order_defaultbank']; } else { $defaultbank = ''; } //测试专用 // $amount = 0.01; $parameter = array("paymethod" => "bankPay", "defaultbank" => $defaultbank, "service" => $trade_type, "partner" => $partner, "return_url" => $return_url, "notify_url" => $notify_url, "_input_charset" => $_input_charset, "subject" => $item_name . ' Order:' . $order_id, "out_trade_no" => $this->session->data['order_id'] . '-' . $customer_id, "payment_type" => "1", "total_fee" => $amount, "seller_email" => $seller_email); } } $alipay = new alipay_service($parameter, $security_code, $sign_type); $action = $alipay->build_url(); $this->response->setOutput(json_encode($action)); } } }
if ($antiphishing == 1) { $encrypt_key = query_timestamp($partner); $exter_invoke_ip = ''; //获取客户端的IP地址,建议:编写获取客户端IP地址的程序 } //扩展功能参数——其他 $extra_common_param = ''; //自定义参数,可存放任何内容(除=、&等特殊字符外),不会显示在页面上 $buyer_email = ''; //默认买家支付宝账号 //扩展功能参数——分润(若要使用,请按照注释要求的格式赋值) $royalty_type = ""; //提成类型,该值为固定值:10,不需要修改 $royalty_parameters = ""; //提成信息集,与需要结合商户网站自身情况动态获取每笔交易的各分润收款账号、各分润金额、各分润说明。最多只能设置10条 //各分润金额的总和须小于等于total_fee //提成信息集格式为:收款方Email_1^金额1^备注1|收款方Email_2^金额2^备注2 //如: //royalty_type = "10" //royalty_parameters = "111@126.com^0.01^分润备注一|222@126.com^0.01^分润备注二" //扩展功能参数——自定义超时(若要使用,请按照注释要求的格式赋值) //该功能默认不开通, //申请开通方式:拨打0571-88158090申请或提交集成申请(https://b.alipay.com/support/helperApply.htm?action=consultationApply) //超时时间,不填默认是15天。设置范围:1m~15d。 m-分钟,h-小时,d-天,1c-当天(无论何时创建,交易都在0点关闭) $it_b_pay = ""; ///////////////////////////////////////////////// //构造要请求的参数数组,无需改动 $parameter = array("service" => 'create_direct_pay_by_user', "payment_type" => "1", "partner" => $partner, "seller_email" => $seller_email, "return_url" => $return_url, "notify_url" => $notify_url, "_input_charset" => $_input_charset, "show_url" => $show_url, "out_trade_no" => $out_trade_no, "subject" => $subject, "body" => $body, "total_fee" => $total_fee, "paymethod" => $paymethod, "defaultbank" => $defaultbank, "anti_phishing_key" => $encrypt_key, "exter_invoke_ip" => $exter_invoke_ip, "buyer_email" => $buyer_email, "extra_common_param" => $extra_common_param, "royalty_type" => $royalty_type, "royalty_parameters" => $royalty_parameters, "it_b_pay" => $it_b_pay); //构造请求函数 $alipay = new alipay_service($parameter, $key, $sign_type); $sHtmlText = $alipay->build_form();
//获取客户端的IP地址,建议:编写获取客户端IP地址的程序 //如: //$exter_invoke_ip = '202.1.1.1'; //$anti_phishing_key = query_timestamp($partner); //获取防钓鱼时间戳函数 //扩展功能参数——其他 $extra_common_param = ''; //自定义参数,可存放任何内容(除=、&等特殊字符外),不会显示在页面上 $buyer_email = ''; //默认买家支付宝账号 //扩展功能参数——分润(若要使用,请按照注释要求的格式赋值) $royalty_type = ""; //提成类型,该值为固定值:10,不需要修改 $royalty_parameters = ""; //提成信息集,与需要结合商户网站自身情况动态获取每笔交易的各分润收款账号、各分润金额、各分润说明。最多只能设置10条 //各分润金额的总和须小于等于total_fee //提成信息集格式为:收款方Email_1^金额1^备注1|收款方Email_2^金额2^备注2 //如: //royalty_type = "10" //royalty_parameters = "111@126.com^0.01^分润备注一|222@126.com^0.01^分润备注二" ///////////////////////////////////////////////// //构造要请求的参数数组,无需改动 $parameter = array("service" => "create_direct_pay_by_user", "payment_type" => "1", "partner" => $GLOBALS['setting_cfg']['ALIPAY_PARTNER']['value'], "seller_email" => $GLOBALS['setting_cfg']['ALIPAY_SELLER_EMAIL']['value'], "return_url" => $return_url, "notify_url" => $notify_url, "_input_charset" => 'utf-8', "show_url" => $url_base . '/', "out_trade_no" => $out_trade_no, "subject" => $subject, "body" => $body, "total_fee" => $total_fee, "paymethod" => $paymethod, "defaultbank" => $defaultbank, "anti_phishing_key" => $anti_phishing_key, "exter_invoke_ip" => $exter_invoke_ip, "buyer_email" => $buyer_email, "extra_common_param" => $extra_common_param, "royalty_type" => $royalty_type, "royalty_parameters" => $royalty_parameters); //构造请求函数 $alipay = new alipay_service($parameter, $GLOBALS['setting_cfg']['ALIPAY_KEY']['value'], 'MD5'); $url = $alipay->build_form(); //die($url); //$sHtmlText = '<html><body><meta http-equiv="Content-Type" content="text/html; charset=utf-8">'; header("Location:" . $url); die; //$sHtmlText .= '</body></html>'; //die($sHtmlText);