buildRequestParaToString() public method

生成要请求给支付宝的参数数组
public buildRequestParaToString ( $para_temp ) : 要请求的参数数组字符串
$para_temp 请求前的参数数组
return 要请求的参数数组字符串
Exemplo n.º 1
0
 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;
 }
Exemplo n.º 2
0
 public function returnParam($param)
 {
     $this->format = 'xml';
     $this->v = '2.0';
     $this->req_id = date('Ymdhis');
     $this->notify_url = MOBILE_SITE_URL . '/api/payment/alipay/notify_url.php';
     //$this->notify_url = 'http://'.$_SERVER['SERVER_NAME'].'/mobile/index.php?act=payment&op=notify&payment_code=alipay';
     $this->call_back_url = MOBILE_SITE_URL . '/api/payment/alipay/call_back_url.php';
     //$this->call_back_url = 'http://'.$_SERVER['SERVER_NAME'].'/mobile/index.php?act=payment&op=return&payment_code=alipay';
     $this->seller_email = $param['alipay_account'];
     //v3-b11
     $this->out_trade_no = $param['order_sn'] . '-' . $param['order_type'];
     $this->subject = $param['order_sn'];
     $this->total_fee = $param['order_amount'];
     $this->alipay_config = array('partner' => $param['alipay_partner'], 'key' => $param['alipay_key'], 'private_key_path' => 'key/rsa_private_key.pem', 'ali_public_key_path' => 'key/alipay_public_key.pem', 'sign_type' => 'RSA', 'input_charset' => 'utf-8', 'cacert' => getcwd() . '\\cacert.pem', 'transport' => 'http');
     //请求业务参数详细
     $req_data = '<direct_trade_create_req><notify_url>' . $this->notify_url . '</notify_url><call_back_url>' . $this->call_back_url . '</call_back_url><seller_account_name>' . $this->seller_email . '</seller_account_name><out_trade_no>' . $this->out_trade_no . '</out_trade_no><subject>' . $this->subject . '</subject><total_fee>' . $this->total_fee . '</total_fee></direct_trade_create_req>';
     //必填
     //构造要请求的参数数组,无需改动
     $para_token = array("seller_id" => $this->seller_email, "out_trade_no" => $this->out_trade_no, "subject" => $this->subject, "notify_url" => $this->notify_url, "body" => 123, "total_fee" => $this->total_fee, "payment_type" => 1, "sign_type" => trim($this->alipay_config['sign_type']), "service" => "mobile.securitypay.pay", "partner" => trim($this->alipay_config['partner']), "_input_charset" => trim(strtolower($this->alipay_config['input_charset'])));
     //建立请求
     $alipaySubmit = new AlipaySubmit($this->alipay_config);
     $reqstring = $alipaySubmit->buildRequestParaToString($para_token);
     //$html_text = $alipaySubmit->buildRequestHttp($para_token);
     return $reqstring;
 }
Exemplo n.º 3
0
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;
}
Exemplo n.º 4
0
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;
}
Exemplo n.º 5
0
function createAlipayUrl(array $alipayConfig, array $parameter, $type = 1)
{
    $alipayConfig = getAlipayConfig($alipayConfig);
    if ($type != 3) {
        //调用官方sdk 参数需指定传入
        $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);
    if ($type == 1) {
        $url = $alipaySubmit->alipay_gateway_new;
        $url .= $alipaySubmit->buildRequestParaToString($parameter);
    } elseif ($type == 2) {
        $parameter['seller_id'] = trim($alipayConfig['partner']);
        $url = $alipaySubmit->alipay_client_url;
        $url .= urlencode(json_encode(array('requestType' => 'SafePay', 'fromAppUrlScheme' => 'com.zhiyiThinkSNS4', 'dataString' => $alipaySubmit->buildRequestParaToString($parameter))));
        //带客户端协议的参数拼接
    } elseif ($type == 3) {
        $url = $alipaySubmit->buildRequestParaToString($parameter);
    }
    return $url;
}
Exemplo n.º 6
0
 /**
  * 生成支付代码
  * @param   array   $order  订单信息
  * @param   array   $payment    支付方式信息
  */
 function get_wappay_url($order, $payment)
 {
     $order_id = $order['order_id'];
     $order_desc = $order['order_sn'];
     $order_sn = $order['order_sn'];
     $amount = $order['order_amount'];
     $ecmobile_url = ecmobile_url();
     //修正配置文件路径
     $this->alipay_config = $this->modify_config_path($this->alipay_config);
     $format = "xml";
     //返回格式
     $v = "2.0";
     $req_id = date('Ymdhis');
     //请求号
     $notify_url = $ecmobile_url . "/payment/alipay/wap/notify_url.php";
     //服务器异步通知页面路径
     $call_back_url = $ecmobile_url . "/payment/wap_callback.php?code=alipay";
     //页面跳转同步通知页面路径
     $merchant_url = $ecmobile_url . "/payment/wap_merchant.php?code=alipay";
     //操作中断返回地址
     $seller_email = '*****@*****.**';
     //卖家支付宝帐户
     $out_trade_no = $order_sn;
     //商户订单号
     $subject = $order_desc;
     //订单名称
     $total_fee = $amount;
     //付款金额
     //请求业务参数详细
     $req_data = '<direct_trade_create_req><notify_url>' . $notify_url . '</notify_url><call_back_url>' . $call_back_url . '</call_back_url><seller_account_name>' . $seller_email . '</seller_account_name><out_trade_no>' . $out_trade_no . '</out_trade_no><subject>' . $subject . '</subject><total_fee>' . $total_fee . '</total_fee><merchant_url>' . $merchant_url . '</merchant_url></direct_trade_create_req>';
     $para_token = array("service" => "alipay.wap.trade.create.direct", "partner" => trim($this->alipay_config['partner']), "sec_id" => trim($this->alipay_config['sign_type']), "format" => $format, "v" => $v, "req_id" => $req_id, "req_data" => $req_data, "_input_charset" => trim(strtolower($this->alipay_config['input_charset'])));
     //建立请求
     $alipaySubmit = new AlipaySubmit($this->alipay_config);
     $html_text = $alipaySubmit->buildRequestHttp($para_token);
     $html_text = urldecode($html_text);
     //解析远程模拟提交后返回的信息
     $para_html_text = $alipaySubmit->parseResponse($html_text);
     //获取request_token
     $request_token = $para_html_text['request_token'];
     if ($request_token) {
         //业务详细
         $req_data = '<auth_and_execute_req><request_token>' . $request_token . '</request_token></auth_and_execute_req>';
         //构造要请求的参数数组,无需改动
         $parameter = array("service" => "alipay.wap.auth.authAndExecute", "partner" => trim($this->alipay_config['partner']), "sec_id" => trim($this->alipay_config['sign_type']), "format" => $format, "v" => $v, "req_id" => $req_id, "req_data" => $req_data, "_input_charset" => trim(strtolower($this->alipay_config['input_charset'])));
         //建立请求
         $alipaySubmit = new AlipaySubmit($this->alipay_config);
         $url = $alipaySubmit->alipay_gateway_new . $alipaySubmit->buildRequestParaToString($parameter);
         return $url;
     } else {
         return false;
     }
 }
Exemplo n.º 7
0
 public function GetPaymentURL($orderId, $amount, $title = null, $customData = null)
 {
     $alipay_config = $this->_getConfig();
     if ($customData) {
         $customData = json_encode($customData);
     }
     //构造要请求的参数数组
     $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($this->returnURL), "notify_url" => trim($this->notifyURL), "out_trade_no" => $orderId, "subject" => $title, "total_fee" => $amount, "paymethod" => $paymethod, "defaultbank" => $defaultbank, "anti_phishing_key" => $anti_phishing_key, "exter_invoke_ip" => $exter_invoke_ip, "show_url" => SITE_URL, "extra_common_param" => $customData, "royalty_type" => $royalty_type, "royalty_parameters" => $royalty_parameters);
     //构造即时到帐接口
     $alipaySubmit = new AlipaySubmit();
     $url = $this->aPIURL . $alipaySubmit->buildRequestParaToString($parameter, $alipay_config);
     return $url;
 }
Exemplo n.º 8
0
 /**
  * 获取支付代码
  *
  * @author freeway
  * @param array $order_info  待支付的订单信息
  * @param $service
  * @return string
  */
 public function get_html_nupost($order_info, $service = 'create_direct_pay_by_user')
 {
     // 构造要请求的参数数组
     if ($service == 'create_direct_pay_by_user') {
         $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['out_trade_no'], "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" => '');
     } else {
         $parameter = array("service" => "create_partner_trade_by_buyer", "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'], "out_trade_no" => $order_info['out_trade_no'], "subject" => $order_info['subject'], "price" => $order_info['total_fee'], "quantity" => '1', "logistics_fee" => $this->_config['logistics_fee'], "logistics_type" => $this->_config['logistics_type'], "logistics_payment" => $this->_config['logistics_payment'], "body" => $order_info['body'], "show_url" => '', "receive_name" => '', "receive_address" => '', "receive_zip" => '', "receive_phone" => '', "receive_mobile" => '', "_input_charset" => 'utf-8');
     }
     require_once "alipay/alipay_submit.class.php";
     $alipaySubmit = new AlipaySubmit($this->_config);
     $html = $alipaySubmit->buildRequestParaToString($parameter, "get", "确认");
     return $this->alipay_gateway_new . $html;
 }
Exemplo n.º 9
0
 public function pay($notify_url, $return_url, $out_trade_no, $subject, $body, $show_url, $money, $extra_param = '', $is_wap = false)
 {
     require_once "alipay.config.php";
     require_once "lib/alipay_submit.class.php";
     $parameter = array("partner" => trim($alipay_config['partner']), 'seller_id' => trim($alipay_config['seller_id']), "payment_type" => 1, "notify_url" => $notify_url, "return_url" => $return_url, "out_trade_no" => $out_trade_no, "subject" => $subject, "total_fee" => $money, "body" => $body, "show_url" => $show_url, "it_b_pay" => '30m', "anti_phishing_key" => '', "_input_charset" => trim(strtolower($alipay_config['input_charset'])), "extra_common_param" => $extra_param);
     if ($is_wap) {
         $parameter['service'] = 'alipay.wap.create.direct.pay.by.user';
     } else {
         $parameter['service'] = 'create_direct_pay_by_user';
         $parameter['seller_email'] = trim($alipay_config['seller_email']);
         $parameter['exter_invoke_ip'] = $_SERVER['REMOTE_ADDR'];
     }
     // 建立请求
     $alipaySubmit = new \AlipaySubmit($alipay_config);
     return $alipaySubmit->buildRequestParaToString($parameter, "get", "正在跳转到支付页面……");
 }
Exemplo n.º 10
0
 /**
  * 支付宝退款 v3-b12
  *
  */
 public function alipayOp()
 {
     $refund_id = intval($_GET['refund_id']);
     $model_refund = Model('vr_refund');
     $condition = array();
     $condition['refund_id'] = $refund_id;
     $condition['refund_state'] = '1';
     $detail_array = $model_refund->getDetailInfo($condition);
     //退款详细
     if (!empty($detail_array) && $detail_array['refund_code'] == 'alipay') {
         $order = $model_refund->getPayDetailInfo($detail_array);
         //退款订单详细
         $refund_amount = $order['pay_refund_amount'];
         //本次在线退款总金额
         if ($refund_amount > 0) {
             $payment_config = $order['payment_config'];
             $alipay_config = array();
             $alipay_config['seller_email'] = $payment_config['alipay_account'];
             $alipay_config['partner'] = $payment_config['alipay_partner'];
             $alipay_config['key'] = $payment_config['alipay_key'];
             $api_file = BASE_PATH . DS . 'api' . DS . 'refund' . DS . 'alipay' . DS . 'alipay.class.php';
             include $api_file;
             $alipaySubmit = new AlipaySubmit($alipay_config);
             $parameter = getPara($alipay_config);
             $batch_no = $detail_array['batch_no'];
             $b_date = substr($batch_no, 0, 8);
             if ($b_date != date('Ymd')) {
                 $batch_no = date('Ymd') . substr($batch_no, 8);
                 //批次号。支付宝要求格式为:当天退款日期+流水号。
                 $model_refund->editDetail(array('refund_id' => $refund_id), array('batch_no' => $batch_no));
             }
             $parameter['notify_url'] = ADMIN_SITE_URL . "/api/refund/alipay/vr_notify_url.php";
             $parameter['batch_no'] = $batch_no;
             $parameter['detail_data'] = $order['trade_no'] . '^' . $refund_amount . '^协商退款';
             //数据格式为:原交易号^退款金额^理由
             $pay_url = $alipaySubmit->buildRequestParaToString($parameter);
             @header("Location: " . $pay_url);
         }
     }
 }
Exemplo n.º 11
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);
        $html_text = urldecode($html_text);
        //解析远程模拟提交后返回的信息
        $para_html_text = $alipaySubmit->parseResponse($html_text);
        //获取request_token
        $request_token = $para_html_text['request_token'];
        //业务详细
        $req_data = '<auth_and_execute_req><request_token>' . $request_token . '</request_token></auth_and_execute_req>';
        //构造要请求的参数数组,无需改动
        $parameter = array("service" => "alipay.wap.auth.authAndExecute", "partner" => trim($alipay_config['partner']), "sec_id" => trim($alipay_config['sign_type']), "format" => $format, "v" => $v, "req_id" => $req_id, "req_data" => $req_data, "_input_charset" => trim(strtolower($alipay_config['input_charset'])));
        //建立请求
        $alipaySubmit = new AlipaySubmit($alipay_config);
        $url = $alipaySubmit->alipay_gateway_new . $alipaySubmit->buildRequestParaToString($parameter);
        header("Location: {$url}");
        //$html_text = $alipaySubmit->buildRequestForm($parameter, 'get', '确认');
        //echo $html_text;
        break;
    default:
        GZ_Api::outPut(101);
        break;
}
function modify_config_path($alipay_config)
{
    $alipay_config['cacert'] = str_replace('/alipay', '/payment/alipay', $alipay_config['cacert']);
    return $alipay_config;
}
Exemplo n.º 12
0
function creatersanew($info)
{
    require_once "mobilepay/alipaysdk/alipay.config.php";
    $alisub = new AlipaySubmit($alipay_config);
    $rsa = $alisub->buildRequestParaToString($info);
    return $rsa;
}
 /**
  * Build Alipay Query String for redirection to Alipay using GET method
  *
  * @access public
  * @param mixed $order
  * @return string
  */
 function build_alipay_string($order)
 {
     require_once "lib/alipay_submit.class.php";
     // Get alipay args
     $alipay_args = $this->get_alipay_args($order);
     $alipay_config = $this->get_alipay_config();
     $alipaySubmit = new AlipaySubmit($alipay_config);
     // Build query string
     $query_string = $alipaySubmit->buildRequestParaToString($alipay_args);
     $alipay_string = $alipaySubmit->alipay_gateway_new . $query_string;
     return $alipay_string;
 }