Example #1
0
 public function buildForm($request)
 {
     $params = array('partner' => $this->partner, 'seller_email' => $this->seller_email, 'return_url' => $this->return_url, 'notify_url' => $this->notify_url, '_input_charset' => $this->_input_charset, 'show_url' => $this->show_url);
     $params = array_merge($params, $request->getParams());
     $service = new AlipayService($params, $this->key, $this->sign_type);
     return $service->build_form();
 }
Example #2
0
function pay_charge_alipay($total_money, $charge_id, $title)
{
    global $INI;
    if ($total_money <= 0 || !$title) {
        return null;
    }
    $order_id = 'charge';
    /* param */
    $_input_charset = 'utf-8';
    $service = 'create_direct_pay_by_user';
    $partner = $INI['alipay']['mid'];
    $security_code = $INI['alipay']['sec'];
    $seller_email = $INI['alipay']['acc'];
    $itbpay = strval($INI['alipay']['itbpay']);
    $sign_type = 'MD5';
    $out_trade_no = $charge_id;
    $return_url = $INI['system']['wwwprefix'] . '/order/alipay/return.php';
    $notify_url = $INI['system']['wwwprefix'] . '/order/alipay/notify.php';
    $show_url = $INI['system']['wwwprefix'] . "/credit/index.php";
    $subject = $title;
    $body = $show_url;
    $quantity = 1;
    $parameter = array("service" => $service, "partner" => $partner, "return_url" => $return_url, "notify_url" => $notify_url, "_input_charset" => $_input_charset, "subject" => $subject, "body" => $body, "out_trade_no" => $out_trade_no, "total_fee" => $total_money, "payment_type" => "1", "show_url" => $show_url, "seller_email" => $seller_email, "extend_param" => "isv^zt11");
    if (!empty($_SESSION['ali_token'])) {
        $parameter['token'] = $_SESSION['ali_token'];
    }
    if ($itbpay) {
        $parameter['it_b_pay'] = $itbpay;
    }
    $alipay = new AlipayService($parameter, $security_code, $sign_type);
    $sign = $alipay->Get_Sign();
    $reqUrl = $alipay->create_url();
    return render('block_pay_alipay', array('order_id' => $order_id, 'reqUrl' => $reqUrl));
}
Example #3
0
function alipay_link($params)
{
    #支付宝接口配置
    $need_confirm = $params['need_confirm'];
    $type = $params['T'];
    $alipay_config['input_charset'] = 'utf-8';
    $alipay_config['sign_type'] = "MD5";
    $alipay_config['transport'] = "http";
    $alipay_config['partner'] = $params['partnerID'];
    $alipay_config['key'] = $params['security_code'];
    $alipay_config['seller_email'] = $params['seller_email'];
    $logistics_fee = $params["logistics_fee"];
    //物流费用,即运费。
    $logistics_type = $params["logistics_type"];
    //物流类型,三个值可选:EXPRESS(快递)、POST(平邮)、EMS(EMS)
    $logistics_payment = $params["logistics_payment"];
    //物流支付方式,两个值可选:SELLER_PAY(卖家承担运费)、BUYER_PAY(买家承担运费)
    $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.htm";
    $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:
            return "支付宝接口配置有误";
    }
    $parameter = array("service" => $service_name, "partner" => trim($alipay_config['partner']), "payment_type" => "1", "_input_charset" => trim(strtolower($alipay_config['input_charset'])), "seller_email" => trim($alipay_config['seller_email']), "return_url" => trim($alipay_config['return_url']), "notify_url" => trim($alipay_config['notify_url']), "subject" => "{$companyname} 订单[ {$invoiceid} ]", "body" => $description, "out_trade_no" => $invoiceid, "price" => $amount, "quantity" => "1");
    if ($type != "1") {
        $parameter["logistics_fee"] = $logistics_fee;
        $parameter["logistics_type"] = $logistics_type;
        $parameter["logistics_payment"] = $logistics_payment;
        if ($logistics_type == "POST") {
            $parameter["t_b_rec_post"] = "3";
        }
    }
    $alipayService = new AlipayService($alipay_config);
    $link = $alipayService->build_link($parameter);
    $img = $systemurl . "/modules/gateways/lib/alipay.gif";
    $code = $link . "<a href='#' onclick=\"document.forms['alipaysubmit'].submit();\"><img src='{$img}' alt='点击使用支付宝支付'> </a>";
    return $code;
}
Example #4
0
 public function aliPayTo()
 {
     $aliPayConfig = C('aliPayConfig');
     $condition['id'] = array('eq', intval($_GET['id']));
     $result = $this->payModel->getOrderInfoData($condition);
     $parameter = array('service' => 'create_direct_pay_by_user', 'payment_type' => '1', 'partner' => trim($aliPayConfig['partner']), '_input_charset' => trim(strtolower($aliPayConfig['input_charset'])), 'seller_email' => trim($aliPayConfig['seller_email']), 'return_url' => trim($aliPayConfig['return_url']), 'notify_url' => trim($aliPayConfig['notify_url']), 'out_trade_no' => $result['order_No'], 'subject' => $result['title_info'], 'body' => $result['remark'], 'total_fee' => $result['price'], 'paymethod' => '', 'defaultbank' => '', 'anti_phishing_key' => '', 'exter_invoke_ip' => '', 'show_url' => 'http://www.xujiantao.com/works/lvsenshop', 'extra_common_param' => '', 'royalty_type' => '', 'royalty_parameters' => '');
     $aliPayService = new AlipayService($aliPayConfig);
     $html_text = $aliPayService->create_direct_pay_by_user($parameter);
     echo $html_text;
 }
Example #5
0
 function aliapytransfer($rechargemoney)
 {
     $aliapy_config = (include TIPASK_ROOT . '/data/alipay.config.php');
     $tradeid = "u-" . strtolower(random(6));
     //构造要请求的参数数组
     $parameter = array("service" => "create_direct_pay_by_user", "payment_type" => "1", "partner" => trim($aliapy_config['partner']), "_input_charset" => trim(strtolower($aliapy_config['input_charset'])), "seller_email" => trim($aliapy_config['seller_email']), "return_url" => trim($aliapy_config['return_url']), "notify_url" => trim($aliapy_config['notify_url']), "out_trade_no" => $tradeid, "subject" => '财富充值', "body" => '财富充值', "total_fee" => $rechargemoney, "paymethod" => '', "defaultbank" => '', "anti_phishing_key" => '', "exter_invoke_ip" => '', "show_url" => '', "extra_common_param" => '', "royalty_type" => '', "royalty_parameters" => '');
     //构造即时到帐接口
     $alipayService = new AlipayService($aliapy_config);
     $html_text = $alipayService->create_direct_pay_by_user($parameter);
     echo $html_text;
 }
Example #6
0
 function createPay($AppInfo, $PartnerInfo, $ServerInfo, $PassageInfo, $OrderInfo, $Pay)
 {
     $comment = json_decode($AppInfo['comment'], true);
     /* 商户号 */
     $partner = $PassageInfo['StagePartnerId'];
     /* 密钥 */
     $key = $PassageInfo['StageSecureCode'];
     $subject = "购买" . $AppInfo['name'] . $comment['coin_name'];
     $body = "购买" . $AppInfo['name'] . "-" . $PartnerInfo['name'] . "-" . $ServerInfo['name'] . $OrderInfo['AppCoin'] . $comment['coin_name'];
     require "AliPayClass/alipayto.php";
     //构造纯网关接口
     $alipayService = new AlipayService($aliapy_config, $PassageInfo);
     $params = $alipayService->create_direct_pay_by_user($parameter);
     return $params;
 }
Example #7
0
 /**
  * 生成支付表单
  * @param unknown $orderid
  * @param unknown $subject
  * @param unknown $body
  * @param unknown $total_fee
  * @return Ambigous <表单提交HTML信息, 提交表单HTML文本, string>
  */
 public static function makePay($orderid, $subject, $body, $total_fee)
 {
     if (ENV_SCENE == 'dev') {
         $total_fee = 0.01;
     }
     require_once LIB_PATH . '/Payment/Alipay/alipay_service.class.php';
     $alipay_config = Yaf_G::getConf('aliapy_config', null, 'alipay');
     $t_paymethod = '';
     $t_defaultbank = '';
     // 订单ID
     //$orderid = $this->getParam('id');
     // 请与贵网站订单系统中的唯一订单号匹配
     //$out_trade_no = $orderid; // $_POST['orderno'];
     // 订单名称,显示在支付宝收银台里的“商品名称”里,显示在支付宝的交易管理的“商品名称”的列表里。
     //$subject = "51wom"; // $_POST['subject'];
     // 订单描述、订单详细、订单备注,显示在支付宝收银台里的“商品描述”里
     //$body = "在线支付"; // @$_POST['body'];
     // 订单总金额,显示在支付宝收银台里的“应付总额”里
     //$total_fee = 0.01; // $_POST['total_fee'];
     // 默认支付方式,取值见“即时到帐接口”技术文档中的请求参数列表
     $paymethod = $t_paymethod;
     // 默认网银代号,代号列表见“即时到帐接口”技术文档“附录”→“银行列表”
     $defaultbank = $t_defaultbank;
     // 防钓鱼时间戳
     $anti_phishing_key = '';
     // 获取客户端的IP地址,建议:编写获取客户端IP地址的程序
     $exter_invoke_ip = '';
     // 商品展示地址,要用 http://格式的完整路径,不允许加?id=123这类自定义参数
     $show_url = '';
     // PageHelper::book2_url();
     // 自定义参数,可存放任何内容(除=、&等特殊字符外),不会显示在页面上
     $extra_common_param = '';
     // 扩展功能参数——分润(若要使用,请按照注释要求的格式赋值)
     $royalty_type = "";
     // 提成类型,该值为固定值:10,不需要修改
     $royalty_parameters = "";
     // 构造要请求的参数数组
     $parameter = array("service" => "create_direct_pay_by_user", "payment_type" => "1", "partner" => trim($alipay_config['partner']), "_input_charset" => trim(strtolower($alipay_config['input_charset'])), "seller_email" => trim($alipay_config['seller_email']), "return_url" => $alipay_config['return_url'], "notify_url" => $alipay_config['notify_url'], "out_trade_no" => $orderid, "subject" => $subject, "body" => $body, "total_fee" => $total_fee, "paymethod" => $paymethod, "defaultbank" => $defaultbank, "anti_phishing_key" => $anti_phishing_key, "exter_invoke_ip" => $exter_invoke_ip, "show_url" => $show_url, "extra_common_param" => $extra_common_param, "royalty_type" => $royalty_type, "royalty_parameters" => $royalty_parameters);
     // 构造即时到帐接口
     $alipayService = new AlipayService($alipay_config);
     return $alipayService->create_direct_pay_by_user($parameter);
 }
Example #8
0
 function actionAlipay()
 {
     $order_number = $this->_context->order_number;
     $rs = Invoice::find('order_number =?', $order_number);
     $rs = $rs->getOne();
     if ($rs->trade_status == 'WAIT_BUYER_PAY') {
         $total_fee = $rs->total_fee;
         $subject = $rs->order->name;
         $out_trade_no = $rs->order_number;
         $body = '订购' . Q::ini('appini/meta/title') . '提供的稳定加速服务';
         if (Q::ini('isAdmin') || Q::ini('isDemo')) {
             $total_fee = 0.01;
         }
         $logistics_fee = "0.00";
         //物流费用,即运费。
         $logistics_type = "EXPRESS";
         //物流类型,三个值可选:EXPRESS(快递)、POST(平邮)、EMS(EMS)
         $logistics_payment = "SELLER_PAY";
         //物流支付方式,两个值可选:SELLER_PAY(卖家承担运费)、BUYER_PAY(买家承担运费)
         $quantity = "1";
         //商品数量,建议默认为1,不改变值,把一次交易看成是一次下订单而非购买一件商品。
         $receive_name = $this->_user_name;
         $receive_address = Q::ini('appini/meta/url') . "/service";
         $receive_zip = "";
         $receive_phone = "";
         $receive_mobile = $this->_user->user_mail;
         $show_url = Q::ini('appini/meta/url') . "/service";
         $root_dir = Q::ini('app_config/ROOT_DIR');
         require_once $root_dir . Q::ini('appini/alipay_dir') . "lib/alipay_service.class.php";
         $parameter = array("service" => "trade_create_by_buyer", "payment_type" => "1", "partner" => trim(Q::ini('appini/payment/alipay/partner')), "_input_charset" => trim(strtolower(Q::ini('appini/payment/alipay/input_charset'))), "seller_email" => trim(Q::ini('appini/payment/alipay/seller_email')), "return_url" => trim(Q::ini('appini/payment/alipay/return_url')), "notify_url" => trim(Q::ini('appini/payment/alipay/notify_url')), "out_trade_no" => $out_trade_no, "subject" => $subject, "body" => $body, "price" => $total_fee, "quantity" => $quantity, "logistics_fee" => $logistics_fee, "logistics_type" => $logistics_type, "logistics_payment" => $logistics_payment, "receive_name" => $receive_name, "receive_address" => $receive_address, "receive_zip" => $receive_zip, "receive_phone" => $receive_phone, "receive_mobile" => $receive_mobile, "show_url" => $show_url);
         #dump($parameter);exit;
         $alipayService = new AlipayService(Q::ini('appini/payment/alipay'));
         $html_text = $alipayService->trade_create_by_buyer($parameter);
         return $html_text;
     }
     return '已过期';
 }
Example #9
0
require_once DT_ROOT . '/api/trade/alipay/2/send/alipay_service.class.php';
/**************************请求参数**************************/
//必填参数//
//支付宝交易号。它是登陆支付宝网站在交易管理中查询得到,一般以8位日期开头的纯数字(如:20100419XXXXXXXXXX)
$trade_no = $td['trade_no'];
//物流公司名称
$logistics_name = $send_type;
//物流发货单号
$invoice_no = $send_no;
//物流发货时的运输类型,三个值可选:POST(平邮)、EXPRESS(快递)、EMS(EMS)
$transport_type = 'EXPRESS';
/************************************************************/
//构造要请求的参数数组,无需改动
$parameter = array("service" => "send_goods_confirm_by_platform", "partner" => trim($aliapy_config['partner']), "_input_charset" => trim(strtolower($aliapy_config['input_charset'])), "trade_no" => $trade_no, "logistics_name" => $logistics_name, "invoice_no" => $invoice_no, "transport_type" => $transport_type);
//构造确认发货接口
$alipayService = new AlipayService($aliapy_config);
$doc = $alipayService->send_goods_confirm_by_platform($parameter);
//请在这里加上商户的业务逻辑程序代码
//――请根据您的业务逻辑来编写程序(以下代码仅作参考)――
//获取支付宝的通知返回参数,可参考技术文档中页面跳转同步通知参数列表
//解析XML
$response = '';
if (!empty($doc->getElementsByTagName("response")->item(0)->nodeValue)) {
    $response = $doc->getElementsByTagName("response")->item(0)->nodeValue;
}
/*
echo $response;
20880020086056250156[REFUND, CONFIRM_GOODS]debonair@netease.comPRIVATE_ACCOUNT2088002008605625interface/dual2011-08-10 10:06:5715612011-08-12 10:43:26B6208800205173067120884022833126540156[EXTEND_TIMEOUT]625842207@qq.comPRIVATE_ACCOUNT20884022833126540.000.0F0.10INST_PARTNER2011081016342262WAIT_BUYER_CONFIRM_GOODSS
exit('Here');
*/
//――请根据您的业务逻辑来编写程序(以上代码仅作参考)――
Example #10
0
<?php

if (!defined('APP_ROOT_PATH')) {
    define('APP_ROOT_PATH', str_replace('system/api_login/taobao/redirect.php', '', str_replace('\\', '/', __FILE__)));
}
require_once APP_ROOT_PATH . 'system/utils/es_session.php';
es_session::start();
require_once "alipay_service.class.php";
$aliapy_config['partner'] = es_session::get('taobao_app_key');
$aliapy_config['key'] = es_session::get('taobao_app_secret');
$aliapy_config['return_url'] = es_session::get('taobao_callback');
$aliapy_config['sign_type'] = 'MD5';
$aliapy_config['input_charset'] = 'utf-8';
$aliapy_config['transport'] = 'http';
$anti_phishing_key = '';
$exter_invoke_ip = '';
$parameter = array("anti_phishing_key" => $anti_phishing_key, "exter_invoke_ip" => $exter_invoke_ip);
//构造快捷登录接口
$alipayService = new AlipayService($aliapy_config);
$html_text = $alipayService->alipay_auth_authorize($parameter);
echo $html_text;
Example #11
0
 }
 $partner = $INI['alipay']['mid'];
 $security_code = $INI['alipay']['sec'];
 $seller_email = $INI['alipay']['acc'];
 //禁止支付宝账号为空
 if (!$partner || !$security_code || !$seller_email) {
     die('fail');
 }
 //参数设置
 $_input_charset = "utf-8";
 //设置编码方式
 $sign_type = "MD5";
 $transport = 'http';
 $parameter = array("service" => "single_trade_query", "partner" => $partner, "_input_charset" => $_input_charset, "out_trade_no" => "{$no}");
 //支付宝类初始化参数、建立单条查询链接参数
 $alipay = new AlipayService($parameter, $security_code, $sign_type, $transport);
 $xml_file = $alipay->create_url();
 //XML 文件解析
 $xml_parser = xml_parser_create();
 //建立XML解析对象
 xml_set_element_handler($xml_parser, 'startElement', 'endElement');
 xml_set_character_data_handler($xml_parser, 'parseData');
 if (!($fp = fopen($xml_file, 'r'))) {
     die('could not open xml file .');
 }
 while ($data = fread($fp, 4096)) {
     if (!xml_parse($xml_parser, $data, feof($fp))) {
         var_dump($data);
         die(sprintf('XML error : %s at line $d ', xml_error_string(xml_get_error_code($xml_parser)), xml_get_current_line_number($xml_parser)));
     }
 }
Example #12
0
 function getUrl($call_back = null)
 {
     if (empty($this->aliapy_config['partner']) || empty($this->aliapy_config['key'])) {
         throw new Exception('Unknown alipay_akey');
         return false;
     }
     //构造快捷登录接口
     $alipayService = new AlipayService($this->aliapy_config);
     $this->loginUrl = $alipayService->alipay_auth_authorize($this->parameter);
     return $this->loginUrl;
 }
 /**
  * Process the payment and return the result
  **/
 function process_payment($order_id)
 {
     global $woocommerce;
     require_once CI_WC_PATH . "/lib/alipay.config.php";
     require_once CI_WC_PATH . "/lib/alipay_service.class.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'];
             }
         }
     }
     //////////////////////////////////////
     /**************************请求参数**************************/
     //必填参数//
     $out_trade_no = 'CIP' . $order_id;
     //请与贵网站订单系统中的唯一订单号匹配
     $subject = implode(',', $item_names);
     //订单名称,显示在支付宝收银台里的“商品名称”里,显示在支付宝的交易管理的“商品名称”的列表里。
     $body = implode(',', $item_names);
     //订单描述、订单详细、订单备注,显示在支付宝收银台里的“商品描述”里
     $price = number_format($order->get_order_total() - $order->get_total_discount(), 2, '.', '');
     //订单总金额,显示在支付宝收银台里的“应付总额”里
     $logistics_fee = "0.00";
     //物流费用,即运费。
     $logistics_type = "EXPRESS";
     //物流类型,三个值可选:EXPRESS(快递)、POST(平邮)、EMS(EMS)
     $logistics_payment = "SELLER_PAY";
     //物流支付方式,两个值可选:SELLER_PAY(卖家承担运费)、BUYER_PAY(买家承担运费)
     $quantity = "1";
     //商品数量,建议默认为1,不改变值,把一次交易看成是一次下订单而非购买一件商品。
     $receive_name = "";
     //收货人姓名,如:张三
     $receive_address = "";
     //收货人地址,如:XX省XXX市XXX区XXX路XXX小区XXX栋XXX单元XXX号
     $receive_zip = "";
     //收货人邮编,如:123456
     $receive_phone = "";
     //收货人电话号码,如:0571-81234567
     $receive_mobile = "";
     //收货人手机号码,如:13312341234
     //网站商品的展示地址,不允许加?id=123这类自定义参数
     $show_url = get_bloginfo('url');
     /************************************************************/
     //构造要请求的参数数组
     $parameter = array("service" => "trade_create_by_buyer", "payment_type" => "1", "partner" => trim($aliapy_config['partner']), "_input_charset" => trim(strtolower($aliapy_config['input_charset'])), "seller_email" => trim($aliapy_config['seller_email']), "return_url" => trim($aliapy_config['return_url']), "notify_url" => trim($aliapy_config['notify_url']), "out_trade_no" => $out_trade_no, "subject" => $subject, "body" => $body, "price" => $price, "quantity" => $quantity, "logistics_fee" => $logistics_fee, "logistics_type" => $logistics_type, "logistics_payment" => $logistics_payment, "receive_name" => $receive_name, "receive_address" => $receive_address, "receive_zip" => $receive_zip, "receive_phone" => $receive_phone, "receive_mobile" => $receive_mobile, "show_url" => $show_url);
     //构造标准双接口
     $alipayService = new AlipayService($aliapy_config);
     $html_text = $alipayService->trade_create_by_buyer($parameter);
     //param end
     $output = "\r\n\t\t\t<html>\r\n\t\t    <head>\r\n\t\t\t\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\r\n\t\t        <title>正在前往支付宝...</title>\r\n\t\t    </head>\r\n\t\t    <body><div  style='display:none'>{$html_text}</div>'</body></html>";
     echo $output;
     exit;
     return array('result' => 'success', 'redirect' => $output);
 }
Example #14
0
 public function send_goods($params)
 {
     require_once LIB_PATH . "Com/payment/alipay_warrant/alipay_service.class.php";
     $aliapy_config = array();
     $aliapy_config['partner'] = $this->_aliapy_config['partner'];
     //安全检验码,以数字和字母组成的32位字符
     $aliapy_config['key'] = $this->_aliapy_config['key'];
     //签名方式 不需修改
     $aliapy_config['sign_type'] = $this->_aliapy_config['sign_type'];
     //字符编码格式 目前支持 gbk 或 utf-8
     $aliapy_config['input_charset'] = $this->_aliapy_config['input_charset'];
     //访问模式,根据自己的服务器是否支持ssl访问,若支持请选择https;若不支持请选择http
     $aliapy_config['transport'] = $this->_aliapy_config['transport'];
     /**************************请求参数**************************/
     //必填参数//
     //支付宝交易号。它是登陆支付宝网站在交易管理中查询得到,一般以8位日期开头的纯数字(如:20100419XXXXXXXXXX)
     $trade_no = $params['trade_no'];
     //物流公司名称
     $logistics_name = '无需物流';
     //物流发货单号
     $invoice_no = '无需物流';
     //物流发货时的运输类型,三个值可选:POST(平邮)、EXPRESS(快递)、EMS(EMS)
     $transport_type = 'EXPRESS';
     /************************************************************/
     //构造要请求的参数数组,无需改动
     $parameter = array("service" => "send_goods_confirm_by_platform", "partner" => trim($aliapy_config['partner']), "_input_charset" => trim(strtolower($aliapy_config['input_charset'])), "trade_no" => $trade_no, "logistics_name" => $logistics_name, "invoice_no" => $invoice_no, "transport_type" => $transport_type);
     //构造确认发货接口
     $alipayService = new AlipayService($aliapy_config);
     $doc = $alipayService->send_goods_confirm_by_platform($parameter);
     //解析XML
     $response = '';
     if (!empty($doc->getElementsByTagName("response")->item(0)->nodeValue)) {
         $response = $doc->getElementsByTagName("response")->item(0)->nodeValue;
     }
     return $response;
 }
Example #15
0
    $reqHandler->setParameter("sp_billno", $sp_billno);
    $reqHandler->setParameter("transaction_id", $transaction_id);
    $reqHandler->setParameter("total_fee", $v_amount);
    $reqHandler->setParameter("return_url", $v_url);
    $reqHandler->setParameter("desc", $desc);
    $reqHandler->setParameter("spbill_create_ip", Utility::GetRemoteIp());
    $reqUrl = $reqHandler->getRequestURL();
    include template('order_charge');
} else {
    if ($_POST['paytype'] == 'alipay') {
        $_input_charset = 'utf-8';
        $service = 'create_direct_pay_by_user';
        $partner = $INI['alipay']['mid'];
        $security_code = $INI['alipay']['sec'];
        $seller_email = $INI['alipay']['acc'];
        $sign_type = 'MD5';
        $out_trade_no = "charge-{$login_user_id}-{$now}-{$randno}";
        $return_url = $INI['system']['wwwprefix'] . '/order/alipay/return.php';
        $notify_url = $INI['system']['wwwprefix'] . '/order/alipay/notify.php';
        $show_url = $INI['system']['wwwprefix'] . "/credit/index.php";
        $subject = $title;
        $body = $show_url;
        $quantity = 1;
        $parameter = array("service" => $service, "partner" => $partner, "return_url" => $return_url, "notify_url" => $notify_url, "_input_charset" => $_input_charset, "subject" => $subject, "body" => $body, "out_trade_no" => $out_trade_no, "total_fee" => $total_money, "payment_type" => "1", "show_url" => $show_url, "seller_email" => $seller_email);
        $alipay = new AlipayService($parameter, $security_code, $sign_type);
        $sign = $alipay->Get_Sign();
        include template('order_charge');
    } else {
        Utility::Redirect(WEB_ROOT . "/credit/index.php");
    }
}
 * 功能:快捷登录用户物流地址查询接口接入页
 * 版本:3.2
 * 修改日期:2011-03-25
 * 说明:
 * 以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己网站的需要,按照技术文档编写,并非一定要使用该代码。
 * 该代码仅供学习和研究支付宝接口使用,只是提供一个参考。
 *************************注意*************************
 * 如果您在接口集成过程中遇到问题,可以按照下面的途径来解决
 * 1、商户服务中心(https://b.alipay.com/support/helperApply.htm?action=consultationApply),提交申请集成协助,我们会有专业的技术工程师主动联系您协助解决
 * 2、商户帮助中心(http://help.alipay.com/support/232511-16307/0-16307.htm?sh=Y&info_type=9)
 * 3、支付宝论坛(http://club.alipay.com/read-htm-tid-8681712.html)
 * 如果不想使用扩展功能请把扩展功能参数赋空值。
 */
require_once "alipayadd.config.php";
require_once "lib/alipay_service.class.php";
/**************************请求参数**************************/
//选填参数//
//授权令牌,该参数的值由快捷登录接口(alipay.auth.authorize)的页面跳转同步通知参数中获取
$token = $_SESSION['ali_token'];
//注意:
//token的有效时间为30分钟,过期后需重新执行快捷登录接口(alipay.auth.authorize)获得新的token
/************************************************************/
//构造要请求的参数数组
$parameter = array("service" => "user.logistics.address.query", "partner" => trim($aliapy_config['partner']), "_input_charset" => trim(strtolower($aliapy_config['input_charset'])), "return_url" => trim($aliapy_config['return_url']), "token" => $token);
//构造快捷登录用户物流地址查询接口
$alipayService = new AlipayService($aliapy_config);
$html_text = $alipayService->user_logistics_address_query($parameter);
echo $html_text;
?>

Example #17
0
//注意:
//1.请慎重选择是否开启防钓鱼功能
//2.exter_invoke_ip、anti_phishing_key一旦被使用过,那么它们就会成为必填参数
//3.开启防钓鱼功能后,服务器、本机电脑必须支持SSL,请配置好该环境。
//示例:
//$exter_invoke_ip = '202.1.1.1';
//$ali_service_timestamp = new AlipayService($aliapy_config);
//$anti_phishing_key = $ali_service_timestamp->query_timestamp();//获取防钓鱼时间戳函数
//扩展功能参数——其他//
//商品展示地址,要用 http://格式的完整路径,不允许加?id=123这类自定义参数
$show_url = 'http://www.xxx.com/order/myorder.php';
//自定义参数,可存放任何内容(除=、&等特殊字符外),不会显示在页面上
$extra_common_param = '';
//扩展功能参数——分润(若要使用,请按照注释要求的格式赋值)
$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" => trim($aliapy_config['partner']), "_input_charset" => trim(strtolower($aliapy_config['input_charset'])), "seller_email" => trim($aliapy_config['seller_email']), "return_url" => trim($aliapy_config['return_url']), "notify_url" => trim($aliapy_config['notify_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, "show_url" => $show_url, "extra_common_param" => $extra_common_param, "royalty_type" => $royalty_type, "royalty_parameters" => $royalty_parameters);
//构造即时到帐接口
$alipayService = new AlipayService($aliapy_config);
$html_text = $alipayService->create_direct_pay_by_user($parameter);
echo $html_text;
Example #18
0
File: pay.php Project: noikiy/mdwp
function pay_team_alipay($total_money, $order) {
	global $INI; if($total_money<=0||!$order) return null;
	$team = Table::Fetch('team', $order['team_id']);
	$order_id = $order['id'];
	$pay_id = $order['pay_id'];
	$guarantee = strtoupper($INI['alipay']['guarantee'])=='Y';

	/* param */
	$_input_charset = 'utf-8';
	$service = $guarantee ? 'create_partner_trade_by_buyer' : 'create_direct_pay_by_user';
    if(strtoupper($INI['alipay']['guarantee'])=='S') $service = 'trade_create_by_buyer';
	$partner = $INI['alipay']['mid'];
	$security_code = $INI['alipay']['sec'];
	$seller_email = $INI['alipay']['acc'];
	$itbpay = strval($INI['alipay']['itbpay']);

	$sign_type = 'MD5';
	$out_trade_no = $pay_id;

	$return_url = $INI['system']['wwwprefix'] . '/order/alipay/return.php';
	$notify_url = $INI['system']['wwwprefix'] . '/order/alipay/notify.php';
	$show_url = $INI['system']['wwwprefix'] . "/team.php?id={$team['id']}";
	$show_url = obscure_rep($show_url);

	$subject = mb_substr(strip_tags($team['title']),0,128,'UTF-8');
	$body = $show_url;
	$quantity = $order['quantity'];
    //print_r($service);exit;
	$parameter = array(
			"service"         => $service,
			"partner"         => $partner,      
			"return_url"      => $return_url,  
			"notify_url"      => $notify_url, 
			"_input_charset"  => $_input_charset, 
			"subject"         => $subject,  	 
			"body"            => $body,     	
			"out_trade_no"    => $out_trade_no,
			"payment_type"    => "1",
			"show_url"        => $show_url,
			"seller_email"    => $seller_email,  
		    "extend_param"    => "isv^zt11",
			);

	if ($guarantee || $service == 'trade_create_by_buyer') {
		$parameter['price'] = $total_money;
		$parameter['quantity'] = 1;
		$parameter['logistics_fee'] = '0.00';
		$parameter['logistics_type'] = 'EXPRESS';
		$parameter['logistics_payment'] = 'SELLER_PAY';
	} else {
		$parameter["total_fee"] = $total_money;
	}
    
	//print_r($parameter);exit;
    if(!empty($_SESSION['ali_token'])) $parameter['token'] = $_SESSION['ali_token'];
	if ($itbpay) $parameter['it_b_pay'] = $itbpay;
	$alipay = new AlipayService($parameter, $security_code, $sign_type);
	$sign = $alipay->Get_Sign();
	$reqUrl = $alipay->create_url();

	return render('block_pay_alipay', array(
				'order_id' => $order_id,
				'reqUrl' => $reqUrl,
				));
}
Example #19
0
//物流费用,即运费。
$logistics_type = "EXPRESS";
//物流类型,三个值可选:EXPRESS(快递)、POST(平邮)、EMS(EMS)
$logistics_payment = "SELLER_PAY";
//物流支付方式,两个值可选:SELLER_PAY(卖家承担运费)、BUYER_PAY(买家承担运费)
$quantity = "1";
//商品数量,建议默认为1,不改变值,把一次交易看成是一次下订单而非购买一件商品。
//选填参数//
//买家收货信息(推荐作为必填)
//该功能作用在于买家已经在商户网站的下单流程中填过一次收货信息,而不需要买家在支付宝的付款流程中再次填写收货信息。
//若要使用该功能,请至少保证receive_name、receive_address有值
//收货信息格式请严格按照姓名、地址、邮编、电话、手机的格式填写
$receive_name = "收货人姓名";
//收货人姓名,如:张三
$receive_address = "收货人地址";
//收货人地址,如:XX省XXX市XXX区XXX路XXX小区XXX栋XXX单元XXX号
$receive_zip = "123456";
//收货人邮编,如:123456
$receive_phone = "0571-81234567";
//收货人电话号码,如:0571-81234567
$receive_mobile = "13312341234";
//收货人手机号码,如:13312341234
//网站商品的展示地址,不允许加?id=123这类自定义参数
$show_url = "http://www.xxx.com/myorder.php";
/************************************************************/
//构造要请求的参数数组
$parameter = array("service" => "create_partner_trade_by_buyer", "payment_type" => "1", "partner" => trim($aliapy_config['partner']), "_input_charset" => trim(strtolower($aliapy_config['input_charset'])), "seller_email" => trim($aliapy_config['seller_email']), "return_url" => trim($aliapy_config['return_url']), "notify_url" => trim($aliapy_config['notify_url']), "out_trade_no" => $out_trade_no, "subject" => $subject, "body" => $body, "price" => $price, "quantity" => $quantity, "logistics_fee" => $logistics_fee, "logistics_type" => $logistics_type, "logistics_payment" => $logistics_payment, "receive_name" => $receive_name, "receive_address" => $receive_address, "receive_zip" => $receive_zip, "receive_phone" => $receive_phone, "receive_mobile" => $receive_mobile, "show_url" => $show_url);
//构造担保交易接口
$alipayService = new AlipayService($aliapy_config);
$html_text = $alipayService->create_partner_trade_by_buyer($parameter);
echo $html_text;
Example #20
0
 public function alipayto()
 {
     import("@.Alipay.alipay_service");
     $aliapy_config = getAliConfig();
     /**************************请求参数**************************/
     //必填参数//
     //请与贵网站订单系统中的唯一订单号匹配
     $out_trade_no = $this->_get('oid');
     //订单名称,显示在支付宝收银台里的“商品名称”里,显示在支付宝的交易管理的“商品名称”的列表里。
     $subject = $this->_get('subject');
     //订单描述、订单详细、订单备注,显示在支付宝收银台里的“商品描述”里
     $body = $this->_get('body');
     //订单总金额,显示在支付宝收银台里的“应付总额”里
     $total_fee = $this->_get('money');
     //扩展功能参数——默认支付方式//
     //默认支付方式,取值见“即时到帐接口”技术文档中的请求参数列表
     $paymethod = '';
     //默认网银代号,代号列表见“即时到帐接口”技术文档“附录”→“银行列表”
     $defaultbank = '';
     //扩展功能参数——防钓鱼//
     //防钓鱼时间戳
     $anti_phishing_key = '';
     //获取客户端的IP地址,建议:编写获取客户端IP地址的程序
     $exter_invoke_ip = '';
     //注意:
     //1.请慎重选择是否开启防钓鱼功能
     //2.exter_invoke_ip、anti_phishing_key一旦被使用过,那么它们就会成为必填参数
     //3.开启防钓鱼功能后,服务器、本机电脑必须支持SSL,请配置好该环境。
     //示例:
     //$exter_invoke_ip = '202.1.1.1';
     //$ali_service_timestamp = new AlipayService($aliapy_config);
     //$anti_phishing_key = $ali_service_timestamp->query_timestamp();//获取防钓鱼时间戳函数
     //扩展功能参数——其他//
     //商品展示地址,要用 http://格式的完整路径,不允许加?id=123这类自定义参数
     $show_url = 'http://www.xwoo.info/order/';
     //自定义参数,可存放任何内容(除=、&等特殊字符外),不会显示在页面上
     $extra_common_param = '';
     //扩展功能参数——分润(若要使用,请按照注释要求的格式赋值)
     $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" => trim($aliapy_config['partner']), "_input_charset" => trim(strtolower($aliapy_config['input_charset'])), "seller_email" => trim($aliapy_config['seller_email']), "return_url" => trim($aliapy_config['return_url']), "notify_url" => trim($aliapy_config['notify_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, "show_url" => $show_url, "extra_common_param" => $extra_common_param, "royalty_type" => $royalty_type, "royalty_parameters" => $royalty_parameters);
     //构造即时到帐接口
     $alipayService = new AlipayService($aliapy_config);
     $html_text = $alipayService->create_direct_pay_by_user($parameter);
     echo $html_text;
 }
Example #21
0
//收货人姓名,如:张三
$receive_address = $td['buyer_address'];
//收货人地址,如:XX省XXX市XXX区XXX路XXX小区XXX栋XXX单元XXX号
$receive_zip = $td['buyer_postcode'];
//收货人邮编,如:123456
$receive_phone = $td['buyer_phone'];
//收货人电话号码,如:0571-81234567
$receive_mobile = $td['buyer_phone'];
//收货人手机号码,如:13312341234
//网站商品的展示地址,不允许加?id=123这类自定义参数
$show_url = DT_PATH . 'api/trade/alipay/show.php';
/************************************************************/
//构造要请求的参数数组
$parameter = array("service" => "trade_create_by_buyer", "payment_type" => "1", "partner" => trim($aliapy_config['partner']), "_input_charset" => trim(strtolower($aliapy_config['input_charset'])), "seller_email" => trim($aliapy_config['seller_email']), "return_url" => trim($aliapy_config['return_url']), "notify_url" => trim($aliapy_config['notify_url']), "out_trade_no" => $out_trade_no, "subject" => $subject, "body" => $body, "price" => $price, "quantity" => $quantity, "buyer_email" => $_trade, "logistics_fee" => $logistics_fee, "logistics_type" => $logistics_type, "logistics_payment" => $logistics_payment, "receive_name" => $receive_name, "receive_address" => $receive_address, "receive_zip" => $receive_zip, "receive_phone" => $receive_phone, "receive_mobile" => $receive_mobile, "show_url" => $show_url);
//构造标准双接口
$alipayService = new AlipayService($aliapy_config);
$html_text = $alipayService->trade_create_by_buyer($parameter);
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=<?php 
echo DT_CHARSET;
?>
">
<meta http-equiv="cache-control" content="no-cache">
<title>Loading...</title>
</head>
<body onload="document.getElementById('alipaysubmit').submit();">
<?php 
echo $html_text;
?>
Example #22
0
    $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);
    $result = $alipaySubmit->buildRequestForm($parameter, 'get', '确认');
} else {
    // PC 接口
    require FCPATH . 'member/pay/alipay/alipay_submit.class.php';
    require FCPATH . 'member/pay/alipay/alipay_service.class.php';
    /**************************请求参数**************************/
    //构造要请求的参数数组
    $parameter = array('service' => 'create_direct_pay_by_user', 'payment_type' => '1', 'partner' => trim($alipay_config['partner']), '_input_charset' => trim(strtolower($alipay_config['input_charset'])), 'seller_email' => trim($alipay_config['seller_email']), 'return_url' => trim($alipay_config['return_url']), 'notify_url' => trim($alipay_config['notify_url']), 'out_trade_no' => $sn, 'subject' => $title, 'body' => dr_lang('m-178', $this->member['username'], $id), 'total_fee' => $money);
    //构造即时到帐接口
    $alipayService = new AlipayService($alipay_config);
    $result = $alipayService->create_direct_pay_by_user($parameter);
}