First commit
This commit is contained in:
1
weixinpay/example/WxPay.JsApiPay.php
Executable file
1
weixinpay/example/WxPay.JsApiPay.php
Executable file
File diff suppressed because one or more lines are too long
147
weixinpay/example/WxPay.MicroPay.php
Executable file
147
weixinpay/example/WxPay.MicroPay.php
Executable file
@@ -0,0 +1,147 @@
|
||||
<?php
|
||||
|
||||
require_once "../lib/WxPay.Api.php";
|
||||
|
||||
/**
|
||||
|
||||
*
|
||||
|
||||
* 刷卡支付实现类
|
||||
|
||||
* 该类实现了一个刷卡支付的流程,流程如下:
|
||||
|
||||
* 1、提交刷卡支付
|
||||
|
||||
* 2、根据返回结果决定是否需要查询订单,如果查询之后订单还未变则需要返回查询(一般反复查10次)
|
||||
|
||||
* 3、如果反复查询10订单依然不变,则发起撤销订单
|
||||
|
||||
* 4、撤销订单需要循环撤销,一直撤销成功为止(注意循环次数,建议10次)
|
||||
|
||||
*
|
||||
|
||||
* 该类是微信支付提供的样例程序,商户可根据自己的需求修改,或者使用lib中的api自行开发,为了防止
|
||||
|
||||
* 查询时hold住后台php进程,商户查询和撤销逻辑可在前端调用
|
||||
|
||||
*
|
||||
|
||||
* @author widy
|
||||
|
||||
*
|
||||
|
||||
*/
|
||||
|
||||
class MicroPay
|
||||
|
||||
{
|
||||
|
||||
/**
|
||||
|
||||
*
|
||||
|
||||
* 提交刷卡支付,并且确认结果,接口比较慢
|
||||
|
||||
* @param WxPayMicroPay $microPayInput
|
||||
|
||||
* @throws WxpayException
|
||||
|
||||
* @return 返回查询接口的结果
|
||||
|
||||
*/
|
||||
|
||||
public function pay($microPayInput)
|
||||
|
||||
{
|
||||
|
||||
//①、提交被扫支付
|
||||
|
||||
$result = WxPayApi::micropay($microPayInput, 5);
|
||||
|
||||
//如果返回成功
|
||||
|
||||
if(!array_key_exists("return_code", $result)
|
||||
|
||||
|| !array_key_exists("out_trade_no", $result)
|
||||
|
||||
|| !array_key_exists("result_code", $result))
|
||||
|
||||
{
|
||||
|
||||
echo "接口调用失败,请确认是否输入是否有误!";
|
||||
|
||||
throw new WxPayException("接口调用失败!");
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//签名验证
|
||||
|
||||
$out_trade_no = $microPayInput->GetOut_trade_no();
|
||||
|
||||
|
||||
|
||||
//②、接口调用成功,明确返回调用失败
|
||||
|
||||
if($result["return_code"] == "SUCCESS" &&
|
||||
|
||||
$result["result_code"] == "FAIL" &&
|
||||
|
||||
$result["err_code"] != "USERPAYING" &&
|
||||
|
||||
$result["err_code"] != "SYSTEMERROR")
|
||||
|
||||
{
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//③、确认支付是否成功
|
||||
|
||||
$queryTimes = 10;
|
||||
|
||||
while($queryTimes > 0)
|
||||
|
||||
{
|
||||
|
||||
$succResult = 0;
|
||||
|
||||
$queryResult = $this->query($out_trade_no, $succResult);
|
||||
|
||||
//如果需要等待1s后继续
|
||||
|
||||
if($succResult == 2){
|
||||
|
||||
sleep(2);
|
||||
|
||||
continue;
|
||||
|
||||
} else if($succResult == 1){//查询成功
|
||||
|
||||
return $queryResult;
|
||||
|
||||
} else {//订单交易失败
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//④、次确认失败,则撤销订单
|
||||
|
||||
if(!$this->cancel($out_trade_no))
|
||||
|
||||
{
|
||||
|
||||
throw new WxpayException("撤销单失败!");
|
||||
|
||||
}
|
||||
|
||||
|
||||
56
weixinpay/example/WxPay.NativePay.php
Executable file
56
weixinpay/example/WxPay.NativePay.php
Executable file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
require_once "../lib/WxPay.Api.php";
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
*
|
||||
|
||||
* 刷卡支付实现类
|
||||
|
||||
* @author widyhu
|
||||
|
||||
*
|
||||
|
||||
*/
|
||||
|
||||
class NativePay
|
||||
|
||||
{
|
||||
|
||||
/**
|
||||
|
||||
*
|
||||
|
||||
* 生成扫描支付URL,模式一
|
||||
|
||||
* @param BizPayUrlInput $bizUrlInfo
|
||||
|
||||
*/
|
||||
|
||||
public function GetPrePayUrl($productId)
|
||||
|
||||
{
|
||||
|
||||
$biz = new WxPayBizPayUrl();
|
||||
|
||||
$biz->SetProduct_id($productId);
|
||||
|
||||
$values = WxpayApi::bizpayurl($biz);
|
||||
|
||||
$url = "weixin://wxpay/bizpayurl?" . $this->ToUrlParams($values);
|
||||
|
||||
return $url;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
*
|
||||
|
||||
* 参数数组转换为url参数
|
||||
|
||||
40
weixinpay/example/download.php
Executable file
40
weixinpay/example/download.php
Executable file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
require_once "../lib/WxPay.Api.php";
|
||||
|
||||
//require_once "../lib/WxPay.MicroPay.php";
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
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"/>
|
||||
|
||||
127
weixinpay/example/jsapi.php
Executable file
127
weixinpay/example/jsapi.php
Executable file
@@ -0,0 +1,127 @@
|
||||
<?php
|
||||
|
||||
ini_set('date.timezone','Asia/Shanghai');
|
||||
|
||||
//error_reporting(E_ERROR);
|
||||
|
||||
require_once "../lib/WxPay.Api.php";
|
||||
|
||||
require_once "WxPay.JsApiPay.php";
|
||||
|
||||
require_once 'log.php';
|
||||
|
||||
|
||||
|
||||
//初始化日志
|
||||
|
||||
$logHandler= new CLogFileHandler("../logs/".date('Y-m-d').'.log');
|
||||
|
||||
$log = Log::Init($logHandler, 15);
|
||||
|
||||
|
||||
|
||||
//打印输出数组信息
|
||||
|
||||
function printf_info($data)
|
||||
|
||||
{
|
||||
|
||||
foreach($data as $key=>$value){
|
||||
|
||||
echo "<font color='#00ff55;'>$key</font> : $value <br/>";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//①、获取用户openid
|
||||
|
||||
$tools = new JsApiPay();
|
||||
|
||||
$openId = $tools->GetOpenid();
|
||||
|
||||
|
||||
|
||||
//②、统一下单
|
||||
|
||||
$input = new WxPayUnifiedOrder();
|
||||
|
||||
$input->SetBody("test");
|
||||
|
||||
$input->SetAttach("test");
|
||||
|
||||
$input->SetOut_trade_no(WX_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);
|
||||
|
||||
$jsApiParameters = $tools->GetJsApiParameters($order);
|
||||
|
||||
|
||||
|
||||
//获取共享收货地址js函数参数
|
||||
|
||||
$editAddress = $tools->GetEditAddressParameters();
|
||||
|
||||
|
||||
|
||||
//③、在支持成功回调通知中处理成功之后的事宜,见 notify.php
|
||||
|
||||
/**
|
||||
|
||||
* 注意:
|
||||
|
||||
* 1、当你的回调地址不可访问的时候,回调通知会失败,可以通过查询订单来确认支付是否成功
|
||||
|
||||
* 2、jsapi支付时需要填入用户openid,WxPay.JsApiPay.php中有获取openid流程 (文档可以参考微信公众平台“网页授权接口”,
|
||||
|
||||
* 参考http://mp.weixin.qq.com/wiki/17/c0f37d5704f0b64713d5d2c37b468d75.html)
|
||||
|
||||
*/
|
||||
|
||||
?>
|
||||
|
||||
|
||||
|
||||
<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>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
//调用微信JS api 支付
|
||||
|
||||
function jsApiCall()
|
||||
|
||||
{
|
||||
|
||||
WeixinJSBridge.invoke(
|
||||
|
||||
'getBrandWCPayRequest',
|
||||
|
||||
<?php echo $jsApiParameters; ?>,
|
||||
125
weixinpay/example/log.php
Executable file
125
weixinpay/example/log.php
Executable file
@@ -0,0 +1,125 @@
|
||||
<?php
|
||||
|
||||
//以下为日志
|
||||
|
||||
|
||||
|
||||
interface ILogHandler
|
||||
|
||||
{
|
||||
|
||||
public function write($msg);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
class CLogFileHandler implements ILogHandler
|
||||
|
||||
{
|
||||
|
||||
private $handle = null;
|
||||
|
||||
|
||||
|
||||
public function __construct($file = '')
|
||||
|
||||
{
|
||||
|
||||
$this->handle = fopen($file,'a');
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function write($msg)
|
||||
|
||||
{
|
||||
|
||||
fwrite($this->handle, $msg, 4096);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function __destruct()
|
||||
|
||||
{
|
||||
|
||||
fclose($this->handle);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
class Log
|
||||
|
||||
{
|
||||
|
||||
private $handler = null;
|
||||
|
||||
private $level = 15;
|
||||
|
||||
|
||||
|
||||
private static $instance = null;
|
||||
|
||||
|
||||
|
||||
private function __construct(){}
|
||||
|
||||
|
||||
|
||||
private function __clone(){}
|
||||
|
||||
|
||||
|
||||
public static function Init($handler = null,$level = 15)
|
||||
|
||||
{
|
||||
|
||||
if(!self::$instance instanceof self)
|
||||
|
||||
{
|
||||
|
||||
self::$instance = new self();
|
||||
|
||||
self::$instance->__setHandle($handler);
|
||||
|
||||
self::$instance->__setLevel($level);
|
||||
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private function __setHandle($handler){
|
||||
|
||||
$this->handler = $handler;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
private function __setLevel($level)
|
||||
|
||||
{
|
||||
|
||||
$this->level = $level;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static function DEBUG($msg)
|
||||
|
||||
{
|
||||
56
weixinpay/example/micropay.php
Executable file
56
weixinpay/example/micropay.php
Executable file
@@ -0,0 +1,56 @@
|
||||
<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>
|
||||
|
||||
<?php
|
||||
|
||||
require_once "../lib/WxPay.Api.php";
|
||||
|
||||
require_once "WxPay.MicroPay.php";
|
||||
|
||||
require_once 'log.php';
|
||||
|
||||
|
||||
|
||||
//初始化日志
|
||||
|
||||
$logHandler= new CLogFileHandler("../logs/".date('Y-m-d').'.log');
|
||||
|
||||
$log = Log::Init($logHandler, 15);
|
||||
|
||||
|
||||
|
||||
//打印输出数组信息
|
||||
|
||||
function printf_info($data)
|
||||
|
||||
{
|
||||
|
||||
foreach($data as $key=>$value){
|
||||
|
||||
echo "<font color='#00ff55;'>$key</font> : $value <br/>";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(isset($_REQUEST["auth_code"]) && $_REQUEST["auth_code"] != ""){
|
||||
|
||||
$auth_code = $_REQUEST["auth_code"];
|
||||
|
||||
$input = new WxPayMicroPay();
|
||||
|
||||
$input->SetAuth_code($auth_code);
|
||||
|
||||
$input->SetBody("刷卡测试样例-支付");
|
||||
|
||||
59
weixinpay/example/native.php
Executable file
59
weixinpay/example/native.php
Executable file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
ini_set('date.timezone','Asia/Shanghai');
|
||||
|
||||
//error_reporting(E_ERROR);
|
||||
|
||||
|
||||
|
||||
require_once "../lib/WxPay.Api.php";
|
||||
|
||||
require_once "WxPay.NativePay.php";
|
||||
|
||||
require_once 'log.php';
|
||||
|
||||
|
||||
|
||||
//模式一
|
||||
|
||||
/**
|
||||
|
||||
* 流程:
|
||||
|
||||
* 1、组装包含支付信息的url,生成二维码
|
||||
|
||||
* 2、用户扫描二维码,进行支付
|
||||
|
||||
* 3、确定支付之后,微信服务器会回调预先配置的回调地址,在【微信开放平台-微信支付-支付配置】中进行配置
|
||||
|
||||
* 4、在接到回调通知之后,用户进行统一下单支付,并返回支付信息以完成支付(见:native_notify.php)
|
||||
|
||||
* 5、支付完成之后,微信服务器会通知支付成功
|
||||
|
||||
* 6、在支付成功通知中需要查单确认是否真正支付成功(见:notify.php)
|
||||
|
||||
*/
|
||||
|
||||
$notify = new NativePay();
|
||||
|
||||
$url1 = $notify->GetPrePayUrl("123456789");
|
||||
|
||||
|
||||
|
||||
//模式二
|
||||
|
||||
/**
|
||||
|
||||
* 流程:
|
||||
|
||||
* 1、调用统一下单,取得code_url,生成二维码
|
||||
|
||||
* 2、用户扫描二维码,进行支付
|
||||
|
||||
* 3、支付完成之后,微信服务器会通知支付成功
|
||||
|
||||
* 4、在支付成功通知中需要查单确认是否真正支付成功(见:notify.php)
|
||||
|
||||
*/
|
||||
|
||||
$input = new WxPayUnifiedOrder();
|
||||
72
weixinpay/example/native_notify.php
Executable file
72
weixinpay/example/native_notify.php
Executable file
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
ini_set('date.timezone','Asia/Shanghai');
|
||||
|
||||
error_reporting(E_ERROR);
|
||||
|
||||
|
||||
|
||||
require_once "../lib/WxPay.Api.php";
|
||||
|
||||
require_once '../lib/WxPay.Notify.php';
|
||||
|
||||
require_once 'log.php';
|
||||
|
||||
|
||||
|
||||
//初始化日志
|
||||
|
||||
$logHandler= new CLogFileHandler("../logs/".date('Y-m-d').'.log');
|
||||
|
||||
$log = Log::Init($logHandler, 15);
|
||||
|
||||
|
||||
|
||||
class NativeNotifyCallBack extends WxPayNotify
|
||||
|
||||
{
|
||||
|
||||
public function unifiedorder($openId, $product_id)
|
||||
|
||||
{
|
||||
|
||||
//统一下单
|
||||
|
||||
$input = new WxPayUnifiedOrder();
|
||||
|
||||
$input->SetBody("test");
|
||||
|
||||
$input->SetAttach("test");
|
||||
|
||||
$input->SetOut_trade_no(WX_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("NATIVE");
|
||||
|
||||
$input->SetOpenid($openId);
|
||||
|
||||
$input->SetProduct_id($product_id);
|
||||
|
||||
$result = WxPayApi::unifiedOrder($input);
|
||||
|
||||
Log::DEBUG("unifiedorder:" . json_encode($result));
|
||||
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function NotifyProcess($data, &$msg)
|
||||
|
||||
{
|
||||
|
||||
53
weixinpay/example/notify.php
Executable file
53
weixinpay/example/notify.php
Executable file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
ini_set('date.timezone','Asia/Shanghai');
|
||||
|
||||
error_reporting(E_ERROR);
|
||||
|
||||
|
||||
|
||||
require_once "../lib/WxPay.Api.php";
|
||||
|
||||
require_once '../lib/WxPay.Notify.php';
|
||||
|
||||
require_once 'log.php';
|
||||
|
||||
|
||||
|
||||
//初始化日志
|
||||
|
||||
$logHandler= new CLogFileHandler("../logs/".date('Y-m-d').'.log');
|
||||
|
||||
$log = Log::Init($logHandler, 15);
|
||||
|
||||
|
||||
|
||||
class PayNotifyCallBack extends WxPayNotify
|
||||
|
||||
{
|
||||
|
||||
//查询订单
|
||||
|
||||
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;
|
||||
53
weixinpay/example/orderquery.php
Executable file
53
weixinpay/example/orderquery.php
Executable file
@@ -0,0 +1,53 @@
|
||||
<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>
|
||||
|
||||
<?php
|
||||
|
||||
ini_set('date.timezone','Asia/Shanghai');
|
||||
|
||||
error_reporting(E_ERROR);
|
||||
|
||||
require_once "../lib/WxPay.Api.php";
|
||||
|
||||
require_once 'log.php';
|
||||
|
||||
|
||||
|
||||
//初始化日志
|
||||
|
||||
$logHandler= new CLogFileHandler("./logs/".date('Y-m-d').'.log');
|
||||
|
||||
$log = Log::Init($logHandler, 15);
|
||||
|
||||
|
||||
|
||||
function printf_info($data)
|
||||
|
||||
{
|
||||
|
||||
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();
|
||||
3312
weixinpay/example/phpqrcode/phpqrcode.php
Executable file
3312
weixinpay/example/phpqrcode/phpqrcode.php
Executable file
File diff suppressed because it is too large
Load Diff
5
weixinpay/example/qrcode.php
Executable file
5
weixinpay/example/qrcode.php
Executable file
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
error_reporting(E_ERROR);
|
||||
|
||||
require_once 'phpqrcode/phpqrcode.php';
|
||||
71
weixinpay/example/refund.php
Executable file
71
weixinpay/example/refund.php
Executable file
@@ -0,0 +1,71 @@
|
||||
<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>
|
||||
|
||||
<?php
|
||||
|
||||
ini_set('date.timezone','Asia/Shanghai');
|
||||
|
||||
error_reporting(E_ERROR);
|
||||
|
||||
require_once "../lib/WxPay.Api.php";
|
||||
|
||||
require_once 'log.php';
|
||||
|
||||
|
||||
|
||||
//初始化日志
|
||||
|
||||
$logHandler= new CLogFileHandler("../logs/".date('Y-m-d').'.log');
|
||||
|
||||
$log = Log::Init($logHandler, 15);
|
||||
|
||||
|
||||
|
||||
function printf_info($data)
|
||||
|
||||
{
|
||||
|
||||
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"];
|
||||
|
||||
$total_fee = $_REQUEST["total_fee"];
|
||||
|
||||
$refund_fee = $_REQUEST["refund_fee"];
|
||||
|
||||
$input = new WxPayRefund();
|
||||
|
||||
$input->SetTransaction_id($transaction_id);
|
||||
|
||||
$input->SetTotal_fee($total_fee);
|
||||
|
||||
$input->SetRefund_fee($refund_fee);
|
||||
|
||||
$input->SetOut_refund_no(WX_MCHID.date("YmdHis"));
|
||||
|
||||
$input->SetOp_user_id(WX_MCHID);
|
||||
|
||||
printf_info(WxPayApi::refund($input));
|
||||
|
||||
exit();
|
||||
|
||||
}
|
||||
73
weixinpay/example/refundquery.php
Executable file
73
weixinpay/example/refundquery.php
Executable file
@@ -0,0 +1,73 @@
|
||||
<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>
|
||||
|
||||
<?php
|
||||
|
||||
ini_set('date.timezone','Asia/Shanghai');
|
||||
|
||||
error_reporting(E_ERROR);
|
||||
|
||||
require_once "../lib/WxPay.Api.php";
|
||||
|
||||
require_once 'log.php';
|
||||
|
||||
|
||||
|
||||
//初始化日志
|
||||
|
||||
$logHandler= new CLogFileHandler("../logs/".date('Y-m-d').'.log');
|
||||
|
||||
$log = Log::Init($logHandler, 15);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function printf_info($data)
|
||||
|
||||
{
|
||||
|
||||
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 WxPayRefundQuery();
|
||||
|
||||
$input->SetTransaction_id($transaction_id);
|
||||
|
||||
printf_info(WxPayApi::refundQuery($input));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(isset($_REQUEST["out_trade_no"]) && $_REQUEST["out_trade_no"] != ""){
|
||||
|
||||
$out_trade_no = $_REQUEST["out_trade_no"];
|
||||
|
||||
$input = new WxPayRefundQuery();
|
||||
|
||||
$input->SetOut_trade_no($out_trade_no);
|
||||
|
||||
printf_info(WxPayApi::refundQuery($input));
|
||||
|
||||
exit();
|
||||
Reference in New Issue
Block a user