Exemplo n.º 1
0
 /**
  * 
  * 生成直接支付url,支付url有效期为2小时,模式二
  * @param base\WxPayUnifiedOrder $input
  */
 public function GetPayUrl($input)
 {
     if ($input->GetTrade_type() == "NATIVE") {
         $result = WxPayApi::unifiedOrder($input);
         return $result;
     }
 }
Exemplo n.º 2
0
 public function Queryorder($transaction_id)
 {
     $input = new WxPayOrderQuery();
     $input->SetTransaction_id($transaction_id);
     $result = WxPayApi::orderQuery($input);
     Log::DEBUG("query:" . json_encode($result));
     if (array_key_exists("return_code", $result) && array_key_exists("result_code", $result) && $result["return_code"] == "SUCCESS" && $result["result_code"] == "SUCCESS") {
         return true;
     }
     return false;
 }
Exemplo n.º 3
0
 /**
  * 
  * 获取jsapi支付的参数
  * @param array $UnifiedOrderResult 统一支付接口返回的数据
  * @throws WxPayException
  * 
  * @return json数据,可直接填入js函数作为参数
  */
 public function GetJsApiParameters($UnifiedOrderResult)
 {
     if (!array_key_exists("appid", $UnifiedOrderResult) || !array_key_exists("prepay_id", $UnifiedOrderResult) || $UnifiedOrderResult['prepay_id'] == "") {
         throw new WxPayException("参数错误");
     }
     $jsapi = new WxPayJsApiPay();
     $jsapi->SetAppid($UnifiedOrderResult["appid"]);
     $timeStamp = time();
     $jsapi->SetTimeStamp("{$timeStamp}");
     $jsapi->SetNonceStr(WxPayApi::getNonceStr());
     $jsapi->SetPackage("prepay_id=" . $UnifiedOrderResult['prepay_id']);
     $jsapi->SetSignType("MD5");
     $jsapi->SetPaySign($jsapi->MakeSign());
     $parameters = json_encode($jsapi->GetValues());
     return $parameters;
 }
Exemplo n.º 4
0
 public function NotifyProcess($data, &$msg)
 {
     //echo "处理回调";
     Log::DEBUG("call back:" . json_encode($data));
     if (!array_key_exists("openid", $data) || !array_key_exists("product_id", $data)) {
         $msg = "回调数据异常";
         return false;
     }
     $openid = $data["openid"];
     $product_id = $data["product_id"];
     //统一下单
     $result = $this->unifiedorder($openid, $product_id);
     if (!array_key_exists("appid", $result) || !array_key_exists("mch_id", $result) || !array_key_exists("prepay_id", $result)) {
         $msg = "统一下单失败";
         return false;
     }
     $this->SetData("appid", $result["appid"]);
     $this->SetData("mch_id", $result["mch_id"]);
     $this->SetData("nonce_str", WxPayApi::getNonceStr());
     $this->SetData("prepay_id", $result["prepay_id"]);
     $this->SetData("result_code", "SUCCESS");
     $this->SetData("err_code_des", "OK");
     return true;
 }
Exemplo n.º 5
0
 $amount = $_REQUEST["amount"];
 $re_user_name = $_REQUEST['re_user_name'];
 $input = new WxPayTransfer();
 $input->SetOpenid($openid);
 //转账对象
 $input->SetAmount($amount);
 //金额单位分,最少100分才能转
 $input->SetRe_user_name($re_user_name);
 //经微信实名认证的用户真实姓名
 $input->SetCheck_name('FORCE_CHECK');
 //FORCE_CHECK:强校验真实姓名
 $input->SetPartner_trade_no(WxPayConfig::MCHID . date("YmdHis"));
 //创建转账单号
 $input->SetDesc('这个是测试:吴汉青:泉州~');
 //转账说明,必填!
 $result = WxPayApi::transfer($input);
 //	printf_info(WxPayApi::transfer($input));
 var_dump($result);
 if ($result['return_code'] == 'FAIL') {
     echo $result["return_msg"];
 } else {
     if ($result['result_code'] == 'FAIL') {
         echo $result["err_code_desc"];
     } else {
         echo 'APPID' . $result["mch_appid"] . '商户号' . $result["mchid"] . '商户订单号' . $result["partner_trade_no"] . '付款时间' . $result["payment_time"];
     }
 }
 /*NO_CHECK:不校验真实姓名
 	FORCE_CHECK:强校验真实姓名(未实名认证的用户会校验失败,无法转账)
 OPTION_CHECK:针对已实名认证的用户才校验真实姓名(未实名认证用户不校验,可以转账成功)*/
 //	exit();
Exemplo n.º 6
0
    foreach ($data as $key => $value) {
        echo "<font color='#f00;'>{$key}</font> : {$value} <br/>";
    }
}
if (isset($_REQUEST["transaction_id"]) && $_REQUEST["transaction_id"] != "") {
    $transaction_id = $_REQUEST["transaction_id"];
    $input = new WxPayOrderQuery();
    $input->SetTransaction_id($transaction_id);
    printf_info(WxPayApi::orderQuery($input));
    exit;
}
if (isset($_REQUEST["out_trade_no"]) && $_REQUEST["out_trade_no"] != "") {
    $out_trade_no = $_REQUEST["out_trade_no"];
    $input = new WxPayOrderQuery();
    $input->SetOut_trade_no($out_trade_no);
    printf_info(WxPayApi::orderQuery($input));
    exit;
}
?>
<body>  
	<form action="#" method="post">
        <div style="margin-left:2%;color:#f00">微信订单号和商户订单号选少填一个,微信订单号优先:</div><br/>
        <div style="margin-left:2%;">微信订单号:</div><br/>
        <input type="text" style="width:96%;height:35px;margin-left:2%;" name="transaction_id" /><br /><br />
        <div style="margin-left:2%;">商户订单号:</div><br/>
        <input type="text" style="width:96%;height:35px;margin-left:2%;" name="out_trade_no" /><br /><br />
		<div align="center">
			<input type="submit" value="查询" style="width:210px; height:50px; border-radius: 15px;background-color:#FE6714; border:0px #FE6714 solid; cursor: pointer;  color:white;  font-size:16px;" type="button" onclick="callpay()" />
		</div>
	</form>
</body>
Exemplo n.º 7
0
$tools = new JsApiPay();
$openId = $tools->GetOpenid();
//②、统一下单
$input = new WxPayUnifiedOrder();
$input->SetBody("test");
$input->SetAttach("test");
$input->SetOut_trade_no(WxPayConfig::MCHID . date("YmdHis"));
$input->SetTotal_fee("1");
//金额
$input->SetTime_start(date("YmdHis"));
$input->SetTime_expire(date("YmdHis", time() + 600));
$input->SetGoods_tag("test");
$input->SetNotify_url("http://paysdk.weixin.qq.com/example/notify.php");
$input->SetTrade_type("JSAPI");
$input->SetOpenid($openId);
$order = WxPayApi::unifiedOrder($input);
echo '<font color="#f00"><b>统一下单支付单信息</b></font><br/>';
printf_info($order);
//$order为数组
$jsApiParameters = $tools->GetJsApiParameters($order);
//$jsApiParameters为json格式
//获取共享收货地址js函数参数
$editAddress = $tools->GetEditAddressParameters();
//③、在支持成功回调通知中处理成功之后的事宜,见 notify.php
/**
 * 注意:
 * 1、当你的回调地址不可访问的时候,回调通知会失败,可以通过查询订单来确认支付是否成功
 * 2、jsapi支付时需要填入用户openid,WxPay.JsApiPay.php中有获取openid流程 (文档可以参考微信公众平台“网页授权接口”,
 * 参考http://mp.weixin.qq.com/wiki/17/c0f37d5704f0b64713d5d2c37b468d75.html)
 */
?>
Exemplo n.º 8
0
<?php

require '../conf.php';
require '../vendor/autoload.php';
use lib\WxPayApi;
use lib\base\WxPayDownloadBill;
//数据输入对象类
//use lib\base\WxPayConfig;//微信支付参数配置类
if (isset($_REQUEST["bill_date"]) && $_REQUEST["bill_date"] != "") {
    $bill_date = $_REQUEST["bill_date"];
    $bill_type = $_REQUEST["bill_type"];
    $input = new WxPayDownloadBill();
    $input->SetBill_date($bill_date);
    $input->SetBill_type($bill_type);
    $file = WxPayApi::downloadBill($input);
    echo $file;
    //TODO 对账单文件处理
    exit(0);
}
?>
<html>
<head>
    <meta http-equiv="content-type" content="text/html;charset=utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1" /> 
    <title>微信支付样例-查退款单</title>
</head>
<body>  
	<form action="#" method="post">
        <div style="margin-left:2%;">对账日期:</div><br/>
        <input type="text" style="width:96%;height:35px;margin-left:2%;" name="bill_date" /><br /><br />
        <div style="margin-left:2%;">账单类型:</div><br/>
Exemplo n.º 9
0
    exit;
}
//$_REQUEST["out_trade_no"]= "122531270220150304194108";
///$_REQUEST["total_fee"]= "1";
//$_REQUEST["refund_fee"] = "1";
if (isset($_REQUEST["out_trade_no"]) && $_REQUEST["out_trade_no"] != "") {
    $out_trade_no = $_REQUEST["out_trade_no"];
    $total_fee = $_REQUEST["total_fee"];
    $refund_fee = $_REQUEST["refund_fee"];
    $input = new WxPayRefund();
    $input->SetOut_trade_no($out_trade_no);
    $input->SetTotal_fee($total_fee);
    $input->SetRefund_fee($refund_fee);
    $input->SetOut_refund_no(WxPayConfig::MCHID . date("YmdHis"));
    $input->SetOp_user_id(WxPayConfig::MCHID);
    printf_info(WxPayApi::refund($input));
    exit;
}
?>
<body>  
	<form action="#" method="post">
        <div style="margin-left:2%;color:#f00">微信订单号和商户订单号选少填一个,微信订单号优先:</div><br/>
        <div style="margin-left:2%;">微信订单号:</div><br/>
        <input type="text" style="width:96%;height:35px;margin-left:2%;" name="transaction_id" /><br /><br />
        <div style="margin-left:2%;">商户订单号:</div><br/>
        <input type="text" style="width:96%;height:35px;margin-left:2%;" name="out_trade_no" /><br /><br />
        <div style="margin-left:2%;">订单总金额(分):</div><br/>
        <input type="text" style="width:96%;height:35px;margin-left:2%;" name="total_fee" /><br /><br />
        <div style="margin-left:2%;">退款金额(分):</div><br/>
        <input type="text" style="width:96%;height:35px;margin-left:2%;" name="refund_fee" /><br /><br />
		<div align="center">
Exemplo n.º 10
0
    $input->SetOut_trade_no($out_trade_no);
    printf_info(WxPayApi::refundQuery($input));
    exit;
}
if (isset($_REQUEST["out_refund_no"]) && $_REQUEST["out_refund_no"] != "") {
    $out_refund_no = $_REQUEST["out_refund_no"];
    $input = new WxPayRefundQuery();
    $input->SetOut_refund_no($out_refund_no);
    printf_info(WxPayApi::refundQuery($input));
    exit;
}
if (isset($_REQUEST["refund_id"]) && $_REQUEST["refund_id"] != "") {
    $refund_id = $_REQUEST["refund_id"];
    $input = new WxPayRefundQuery();
    $input->SetRefund_id($refund_id);
    printf_info(WxPayApi::refundQuery($input));
    exit;
}
?>
<body>  
	<form action="#" method="post">
        <div style="margin-left:2%;color:#f00">微信订单号、商户订单号、微信订单号、微信退款单号选填至少一个,微信退款单号优先:</div><br/>
        <div style="margin-left:2%;">微信订单号:</div><br/>
        <input type="text" style="width:96%;height:35px;margin-left:2%;" name="transaction_id" /><br /><br />
        <div style="margin-left:2%;">商户订单号:</div><br/>
        <input type="text" style="width:96%;height:35px;margin-left:2%;" name="out_trade_no" /><br /><br />
        <div style="margin-left:2%;">商户退款单号:</div><br/>
        <input type="text" style="width:96%;height:35px;margin-left:2%;" name="out_refund_no" /><br /><br />
        <div style="margin-left:2%;">微信退款单号:</div><br/>
        <input type="text" style="width:96%;height:35px;margin-left:2%;" name="refund_id" /><br /><br />
		<div align="center">