本文整理汇总了PHP中WxPayApi::refund方法的典型用法代码示例。如果您正苦于以下问题:PHP WxPayApi::refund方法的具体用法?PHP WxPayApi::refund怎么用?PHP WxPayApi::refund使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WxPayApi
的用法示例。
在下文中一共展示了WxPayApi::refund方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: myrefund
public function myrefund($transid)
{
global $_W, $_GPC;
include_once 'WxPay.Api.php';
$WxPayApi = new WxPayApi();
$input = new WxPayRefund();
load()->func('communication');
load()->model('account');
$accounts = uni_accounts();
$acid = $_W['uniacid'];
$path_cert = '../addons/feng_fightgroups/cert/' . $_W['uniacid'] . '/apiclient_cert.pem';
//证书路径
$path_key = '../addons/feng_fightgroups/cert/' . $_W['uniacid'] . '/apiclient_key.pem';
//证书路径
$key = $this->module['config']['apikey'];
//商户支付秘钥(API秘钥)
$appid = $accounts[$acid]['key'];
//身份标识(appid)
// $appsecret = $accounts[$acid]['secret'];//身份密钥(appsecret)
$mchid = $this->module['config']['mchid'];
//微信支付商户号(mchid)
$order_out = pdo_fetch("select * from" . tablename('tg_order') . "where transid = '{$transid}'");
$fee = $order_out['price'] * 100;
//退款金额
$refundid = $transid;
//微信订单号
message("key=" . $key . "appid=" . $appid . "mchid=" . $mchid . "fee=" . $fee . "refundid=" . $refundid);
exit;
/*$input:退款必须要的参数*/
$input->SetAppid($appid);
$input->SetMch_id($mchid);
$input->SetOp_user_id($mchid);
$input->SetOut_refund_no($mchid . date("YmdHis"));
$input->SetRefund_fee($fee);
$input->SetTotal_fee($fee);
$input->SetTransaction_id($refundid);
$result = $WxPayApi->refund($input, 6, $path_cert, $path_key, $key);
if ($result['return_code'] == 'SUCCESS') {
return 'success';
} else {
return 'fail';
}
}
示例2: WxPayRefund
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">
示例3: wxpayOp
/**
* 微信退款 v3-b12
*
*/
public function wxpayOp()
{
$result = array('state' => 'false', 'msg' => '参数错误,微信退款失败');
$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) && in_array($detail_array['refund_code'], array('wxpay', 'wx_jsapi', 'wx_saoma'))) {
$order = $model_refund->getPayDetailInfo($detail_array);
//退款订单详细
$refund_amount = $order['pay_refund_amount'];
//本次在线退款总金额
if ($refund_amount > 0) {
$wxpay = $order['payment_config'];
define('WXPAY_APPID', $wxpay['appid']);
define('WXPAY_MCHID', $wxpay['mchid']);
define('WXPAY_KEY', $wxpay['key']);
$total_fee = $order['pay_amount'] * 100;
//微信订单实际支付总金额(在线支付金额,单位为分)
$refund_fee = $refund_amount * 100;
//本次微信退款总金额(单位为分)
$api_file = BASE_PATH . DS . 'api' . DS . 'refund' . DS . 'wxpay' . DS . 'WxPay.Api.php';
include $api_file;
$input = new WxPayRefund();
$input->SetTransaction_id($order['trade_no']);
//微信订单号
$input->SetTotal_fee($total_fee);
$input->SetRefund_fee($refund_fee);
$input->SetOut_refund_no($detail_array['batch_no']);
//退款批次号
$input->SetOp_user_id(WxPayConfig::MCHID);
$data = WxPayApi::refund($input);
if (!empty($data) && $data['return_code'] == 'SUCCESS') {
//请求结果
if ($data['result_code'] == 'SUCCESS') {
//业务结果
$detail_array = array();
$detail_array['pay_amount'] = ncPriceFormat($data['refund_fee'] / 100);
$detail_array['pay_time'] = time();
$model_refund->editDetail(array('refund_id' => $refund_id), $detail_array);
$result['state'] = 'true';
$result['msg'] = '微信成功退款:' . $detail_array['pay_amount'];
$refund = $model_refund->getRefundInfo(array('refund_id' => $refund_id));
$consume_array = array();
$consume_array['member_id'] = $refund['buyer_id'];
$consume_array['member_name'] = $refund['buyer_name'];
$consume_array['consume_amount'] = $detail_array['pay_amount'];
$consume_array['consume_time'] = time();
$consume_array['consume_remark'] = '微信在线退款成功(到账有延迟),虚拟退款单号:' . $refund['refund_sn'];
QueueClient::push('addConsume', $consume_array);
} else {
$result['msg'] = '微信退款错误,' . $data['err_code_des'];
//错误描述
}
} else {
$result['msg'] = '微信接口错误,' . $data['return_msg'];
//返回信息
}
}
}
exit(json_encode($result));
}
示例4: refund
/**
* 退单
* $transaction_id 微信订单号
* $out_trade_no 系统订单号
* $total_fee 订单金额
* $refund_fee 退款金额
*
*/
function refund($data = array())
{
$input = new WxPayRefund();
if ($data['transaction_id']) {
$input->SetTransaction_id($data['transaction_id']);
}
if ($data['out_trade_no']) {
$input->SetOut_trade_no($data['out_trade_no']);
}
$input->SetTotal_fee($data['total_fee']);
$input->SetRefund_fee($data['refund_fee']);
$input->SetOut_refund_no(get_order_sn('zr'));
$input->SetOp_user_id(WxPayConfig::MCHID);
return WxPayApi::refund($input);
}
示例5: doWebOrder
//.........这里部分代码省略.........
"color":"#000000"
},
"remark":{
"value":"\\n\\n' . $send_remark . '",
"color":"#0099FF"
}
}
}';
include_once 'message.php';
$sendmessage = new WX_message();
$res = $sendmessage->WX_request($url, $msg_json);
message('发货操作成功!', referer(), 'success');
}
if (checksubmit('cancelsend')) {
// $item = pdo_fetch("SELECT transid FROM " . tablename('tg_order') . " WHERE id = :id", array(':id' => $id));
// if (!empty($item['transid'])) {
// $this->changeWechatSend($id, 0, $_GPC['cancelreson']);
// }
pdo_update('tg_order', array('status' => 1), array('id' => $id));
message('取消发货操作成功!', referer(), 'success');
}
if (checksubmit('finish')) {
pdo_update('tg_order', array('status' => 3), array('id' => $id));
message('订单操作成功!', referer(), 'success');
}
if (checksubmit('refund')) {
include_once '../addons/feng_fightgroups/WxPay.Api.php';
$WxPayApi = new WxPayApi();
$input = new WxPayRefund();
load()->model('account');
load()->func('communication');
$accounts = uni_accounts();
$acid = $_W['uniacid'];
$path_cert = IA_ROOT . '/addons/feng_fightgroups/cert/' . $_W['uniacid'] . '/apiclient_cert.pem';
//证书路径
$path_key = IA_ROOT . '/addons/feng_fightgroups/cert/' . $_W['uniacid'] . '/apiclient_key.pem';
//证书路径
$key = $this->module['config']['apikey'];
//商户支付秘钥(API秘钥)
$appid = $accounts[$acid]['key'];
//身份标识(appid)
// $appsecret = $accounts[$acid]['secret'];//身份密钥(appsecret)
$mchid = $this->module['config']['mchid'];
//微信支付商户号(mchid)
$refund_id = $_GPC['refund_id'];
//页面获取的退款订单号
$refund_ids = pdo_fetch("select * from" . tablename('tg_order') . "where id={$refund_id}");
$fee = $refund_ids['price'] * 100;
//退款金额
$refundid = $refund_ids['transid'];
//微信订单号
/*$input:退款必须要的参数*/
$input->SetAppid($appid);
$input->SetMch_id($mchid);
$input->SetOp_user_id($mchid);
$input->SetOut_refund_no($mchid . date("YmdHis"));
$input->SetRefund_fee($fee);
$input->SetTotal_fee($fee);
示例6: WxPayRefund
$key = $this->module['config']['apikey'];
//商户支付秘钥(API秘钥)
$appid = $accounts[$acid]['key'];
//身份标识(appid)
$mchid = $this->module['config']['mchid'];
//微信支付商户号(mchid)
/*$input:退款必须要的参数*/
$input = new WxPayRefund();
$input->SetAppid($appid);
$input->SetMch_id($mchid);
$input->SetOp_user_id($mchid);
$input->SetOut_refund_no($mchid . date("YmdHis"));
$input->SetRefund_fee($fee);
$input->SetTotal_fee($fee);
$input->SetTransaction_id($refundid);
$result = $WxPayApi->refund($input, 6, $path_cert, $path_key, $key);
if ($result['return_code'] == 'SUCCESS') {
pdo_update('tg_order', array('status' => 4), array('id' => $value['id']));
pdo_query("update" . tablename('tg_goods') . " set gnum=gnum+1 where id = '{$value['g_id']}'");
}
}
}
if ($num == 0) {
message('未找到已付款且团购过期的微信订单。', referer(), 'fail');
} else {
message('一键退款成功!共处理了' . $num . '个订单。', referer(), 'success');
}
} elseif ($operation == 'output') {
$status = $_GPC['status'];
$keyword = $_GPC['keyword'];
$member = $_GPC['member'];
示例7: refund
public function refund($orderno, $price, $type)
{
global $_GPC, $_W;
include_once '../addons/feng_fightgroups/source/WxPay.Api.php';
$WxPayApi = new WxPayApi();
$input = new WxPayRefund();
load()->model('account');
load()->func('communication');
$accounts = uni_accounts();
$acid = $_W['uniacid'];
$path_cert = IA_ROOT . '/addons/feng_fightgroups/cert/' . $_W['uniacid'] . '/apiclient_cert.pem';
//证书路径
$path_key = IA_ROOT . '/addons/feng_fightgroups/cert/' . $_W['uniacid'] . '/apiclient_key.pem';
//证书路径
$key = $this->module['config']['apikey'];
//商户支付秘钥(API秘钥)
$account_info = pdo_fetch("select * from" . tablename('account_wechats') . "where uniacid={$_W['uniacid']}");
//身份标识(appid)
$appid = $account_info['key'];
//身份标识(appid)
$mchid = $this->module['config']['mchid'];
//微信支付商户号(mchid)
$refund_ids = pdo_fetch("select * from" . tablename('tg_order') . "where orderno ='{$orderno}'");
$goods = pdo_fetch("select * from" . tablename('tg_goods') . "where id='{$refund_ids['g_id']}'");
if (!empty($price)) {
$fee = $price;
} else {
$fee = $refund_ids['price'] * 100;
}
//退款金额
$refundid = $refund_ids['transid'];
//微信订单号
/*$input:退款必须要的参数*/
$input->SetAppid($appid);
$input->SetMch_id($mchid);
$input->SetOp_user_id($mchid);
$input->SetOut_refund_no($refund_ids['orderno']);
$input->SetRefund_fee($fee);
$input->SetTotal_fee($refund_ids['price'] * 100);
$input->SetTransaction_id($refundid);
$result = $WxPayApi->refund($input, 6, $path_cert, $path_key, $key);
//写入退款记录
$data = array('transid' => $refund_ids['transid'], 'refund_id' => $result['refund_id'], 'createtime' => TIMESTAMP, 'status' => 0, 'type' => $type, 'goodsid' => $refund_ids['g_id'], 'orderid' => $refund_ids['id'], 'payfee' => $refund_ids['price'], 'refundfee' => $refund_ids['price'], 'refundername' => $refund_ids['addname'], 'refundermobile' => $refund_ids['mobile'], 'goodsname' => $goods['gname'], 'uniacid' => $_W['uniacid']);
pdo_insert('tg_refund_record', $data);
if ($result['return_code'] == 'SUCCESS') {
if ($type == 3) {
pdo_update('tg_order', array('status' => 7, 'is_tuan' => 2), array('id' => $refund_ids['id']));
} else {
pdo_update('tg_order', array('status' => 7), array('id' => $refund_ids['id']));
}
pdo_update('tg_refund_record', array('status' => 1), array('transid' => $refund_ids['transid']));
/*退款通知*/
require_once IA_ROOT . '/addons/feng_fightgroups/source/Message.class.php';
$access_token = WeAccount::token();
$url1 = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" . $access_token . "";
$url2 = '';
$sendmessage = new Message();
if ($type == 4) {
$res = $sendmessage->part_refund($refund_ids['openid'], $price * 0.01, $this, $url1, $url2);
} else {
$res = $sendmessage->refund($refund_ids['openid'], $refund_ids['price'], $this, $url1, $url2);
}
/*退款通知*/
pdo_query("update" . tablename('tg_goods') . " set gnum=gnum+1 where id = '{$refund_ids['g_id']}'");
return 'success';
} else {
if ($type == 3) {
pdo_update('tg_order', array('status' => 6, 'is_tuan' => 2), array('id' => $refund_ids['id']));
} else {
pdo_update('tg_order', array('status' => 6), array('id' => $refund_ids['id']));
}
return 'fail';
}
}
示例8: WxPayRefund
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);
$result = WxPayApi::refund($input);
Log::DEBUG("refund:" . json_encode($result));
echo json_encode($result);
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/>