Compare commits

...

10 Commits

Author SHA1 Message Date
Anyon
c901adfb29 fix: 增加支付宝退款查询接口 2025-07-10 18:53:38 +08:00
Anyon
15622a4009 fix: 修改微信V3支付参数,增加 APPID 返回。 2025-06-20 10:36:00 +08:00
邹景立
8dd0601357 fix: 更新项目描述 2025-05-24 02:24:01 +08:00
邹景立
cdf88da1a9 fix: 增加转账结果查询 2025-04-21 23:22:27 +08:00
邹景立
59ca095072 fix: 增加新版本提现 2025-04-21 23:06:41 +08:00
邹景立
1182a2dc97 fix: 未读取到平台证书提示异常 2025-04-21 22:29:53 +08:00
邹景立
97825e0556 fix: 更新小程序订单管理 2025-03-18 11:51:28 +08:00
邹景立
c617666343 fix: 支付类型判定使用常量 2025-03-15 19:12:10 +08:00
邹景立
7b291e343c fix: 更新支付查询接口及参数 2025-03-15 19:07:33 +08:00
邹景立
0885bd4c5a fix: 更新支付通知接收参数类型问题,支持 null 自动获取 2025-03-13 09:06:32 +08:00
8 changed files with 208 additions and 23 deletions

View File

@ -152,6 +152,22 @@ abstract class BasicAliPay
return $this->getResult($options);
}
/**
* 支付宝订单退款查询
* @param array|string $options 退款参数或退款商户订单号
* @param array|null $queryOptions 查询选项
* @return array|bool
* @throws \WeChat\Exceptions\InvalidResponseException
* @throws \WeChat\Exceptions\LocalCacheException
*/
public function refundQuery($options, $queryOptions = null)
{
if (!is_array($options)) $options = ['out_trade_no' => $options];
empty($queryOptions) || $options['query_options'] = $queryOptions;
$this->options->set('method', 'alipay.trade.fastpay.refund.query');
return $this->getResult($options);
}
/**
* 关闭支付宝进行中的订单
* @param array|string $options

View File

@ -38,4 +38,33 @@ class Operation extends BasicWeChat
$url = 'https://api.weixin.qq.com/wxaapi/userlog/userlog_search?access_token=ACCESS_TOKEN';
return $this->callPostApi($url, $data, true);
}
/**
* 获取 mediaId 图片
* @param array $data
* @return array
* @throws \WeChat\Exceptions\InvalidResponseException
* @throws \WeChat\Exceptions\LocalCacheException
*/
public function getFeedbackmedia($data)
{
$query = http_build_query($data);
$url = 'https://api.weixin.qq.com/cgi-bin/media/getfeedbackmedia?'. $query .'&access_token=ACCESS_TOKEN';
return $this->callGetApi($url);
}
/**
* 实时日志查询
* @param array $data
* @return array
* @throws \WeChat\Exceptions\InvalidResponseException
* @throws \WeChat\Exceptions\LocalCacheException
*/
public function getFeedback($data)
{
$query = http_build_query($data);
$url = 'https://api.weixin.qq.com/wxaapi/userlog/userlog_search?'.$query.'&access_token=ACCESS_TOKEN';
return $this->callGetApi($url);
}
}

95
WeMini/Shopping.php Normal file
View File

@ -0,0 +1,95 @@
<?php
// +----------------------------------------------------------------------
// | WeChatDeveloper
// +----------------------------------------------------------------------
// | 版权所有 2014~2025 ThinkAdmin [ thinkadmin.top ]
// +----------------------------------------------------------------------
// | 官方网站: https://thinkadmin.top
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// | 免责声明 ( https://thinkadmin.top/disclaimer )
// +----------------------------------------------------------------------
// | gitee 代码仓库https://gitee.com/zoujingli/WeChatDeveloper
// | github 代码仓库https://github.com/zoujingli/WeChatDeveloper
// +----------------------------------------------------------------------
namespace WeMini;
use WeChat\Contracts\BasicWeChat;
/**
* 小程序购物订单
* Class Shopping
* @package WeMini
*/
class Shopping extends BasicWeChat
{
/**
* 上传购物详情
* @param array $data
* @return array
* @throws \WeChat\Exceptions\InvalidResponseException
* @throws \WeChat\Exceptions\LocalCacheException
*/
public function uploadShoppingInfo($data)
{
$url = 'https://api.weixin.qq.com/user-order/orders?access_token=ACCESS_TOKEN';
return $this->callPostApi($url, $data, true);
}
/**
* 上传物流信息
* @param array $data
* @return array
* @throws \WeChat\Exceptions\InvalidResponseException
* @throws \WeChat\Exceptions\LocalCacheException
*/
public function uploadShippingInfo($data)
{
$url = 'https://api.weixin.qq.com/user-order/orders?access_token=ACCESS_TOKEN';
return $this->callPostApi($url, $data, true);
}
/**
* 上传合单购物详情
* @param array $data
* @return array
* @throws \WeChat\Exceptions\InvalidResponseException
* @throws \WeChat\Exceptions\LocalCacheException
*/
public function uploadCombinedShoppingInfo($data)
{
$url = 'https://api.weixin.qq.com/user-order/orders?access_token=ACCESS_TOKEN';
return $this->callPostApi($url, $data, true);
}
/**
* 上传合单物流信息
* @param array $data
* @return array
* @throws \WeChat\Exceptions\InvalidResponseException
* @throws \WeChat\Exceptions\LocalCacheException
*/
public function uploadCombinedShippingInfo($data)
{
$url = 'https://api.weixin.qq.com/user-order/orders?access_token=ACCESS_TOKEN';
return $this->callPostApi($url, $data, true);
}
/**
* 验证购物订单上传结果
* @param array $data
* @return array
* @throws \WeChat\Exceptions\InvalidResponseException
* @throws \WeChat\Exceptions\LocalCacheException
*/
public function ShoppingInfoVerifyUploadResult($data)
{
$url = 'https://api.weixin.qq.com/user-order/shoppinginfo/verify?access_token=ACCESS_TOKEN';
return $this->callPostApi($url, $data, true);
}
}

View File

@ -44,6 +44,9 @@ class Cert extends BasicWePay
try {
$certs = [];
$result = $this->doRequest('GET', '/v3/certificates');
if (empty($result['data']) && !empty($result['message'])) {
throw new InvalidResponseException($result['message']);
}
$decrypt = new DecryptAes($this->config['mch_v3_key']);
foreach ($result['data'] as $vo) {
$certs[$vo['serial_no']] = [

View File

@ -188,24 +188,28 @@ class Ecommerce extends BasicWePay
/**
* 微信支付订单号查询订单(普通支付)
* @param string $transaction_id
* @param string $sub_mchid
* @return array
* @throws \WeChat\Exceptions\InvalidResponseException
*/
public function getTransactionsById($transaction_id)
public function getTransactionsById($transaction_id, $sub_mchid)
{
$pathinfo = "/v3/pay/partner/transactions/id/{$transaction_id}";
$pathinfo = $pathinfo . "?sp_mchid={$this->config['mch_id']}&sub_mchid={$sub_mchid}";
return $this->doRequest('GET', $pathinfo, '', true);
}
/**
* 微信支付商户订单号查询订单(普通支付)
* @param string $out_trade_no
* @param string $sub_mchid
* @return array
* @throws \WeChat\Exceptions\InvalidResponseException
*/
public function getTransactionsByTradeNo($out_trade_no)
public function getTransactionsByTradeNo($out_trade_no, $sub_mchid)
{
$pathinfo = "/v3/pay/partner/transactions/out-trade-no/{$out_trade_no}";
$pathinfo = $pathinfo . "?sp_mchid={$this->config['mch_id']}&sub_mchid={$sub_mchid}";
return $this->doRequest('GET', $pathinfo, '', true);
}
@ -443,41 +447,44 @@ class Ecommerce extends BasicWePay
/**
* 查询单笔退款(按商户退款单号)(退款)
* @param string $refund_id
* @param string $sub_mchid
* @return array
* @throws \WeChat\Exceptions\InvalidResponseException
*/
public function queryRefundsById($refund_id)
public function queryRefundsById($refund_id, $sub_mchid)
{
$pathinfo = "/v3/ecommerce/refunds/id/{$refund_id}";
$pathinfo = "/v3/ecommerce/refunds/id/{$refund_id}?sub_mchid={$$sub_mchid}";
return $this->doRequest('GET', $pathinfo, '', true);
}
/**
* 查询单笔退款(按商户退款单号)(退款)
* @param string $out_refund_no
* @param string $sub_mchid
* @return array
* @throws \WeChat\Exceptions\InvalidResponseException
*/
public function queryRefundsByNo($out_refund_no)
public function queryRefundsByNo($out_refund_no, $sub_mchid)
{
$pathinfo = "/v3/ecommerce/refunds/out-refund-no/{$out_refund_no}";
$pathinfo = "/v3/ecommerce/refunds/out-refund-no/{$out_refund_no}?sub_mchid={$sub_mchid}";
return $this->doRequest('GET', $pathinfo, '', true);
}
/**
* 查询垫付回补结果(退款)
* @param string $refund_id
* @param string $sub_mchid
* @return array
* @throws \WeChat\Exceptions\InvalidResponseException
*/
public function queryRefundsReturnAdvance($refund_id)
public function queryRefundsReturnAdvance($refund_id, $sub_mchid)
{
$pathinfo = "/v3/ecommerce/refunds/{$refund_id}/return-advance";
$pathinfo = "/v3/ecommerce/refunds/{$refund_id}/return-advance?sub_mchid={$sub_mchid}";
return $this->doRequest('GET', $pathinfo, '', true);
}
/**
* 查询垫付回补结果(退款)
* 垫付退款回补
* @param string $refund_id
* @param array $data
* @return array
@ -492,24 +499,26 @@ class Ecommerce extends BasicWePay
/**
* 查询二级商户账户实时余额API(余额查询)
* @param string $sub_mchid
* @param string $account_type 二级商户账户类型 BASIC: 基本账户 FEES: 手续费账户 OPERATION: 运营账户 DEPOSIT: 保证金账户
* @return array
* @throws \WeChat\Exceptions\InvalidResponseException
*/
public function fundBalance($sub_mchid)
public function fundBalance($sub_mchid, $account_type = 'BASIC')
{
$pathinfo = "/v3/ecommerce/fund/balance/{$sub_mchid}";
$pathinfo = "/v3/ecommerce/fund/balance/{$sub_mchid}?account_type={$account_type}";
return $this->doRequest('GET', $pathinfo, '', true);
}
/**
* 查询二级商户账户日终余额API(余额查询)
* @param string $sub_mchid
* @param array $query
* @return array
* @throws \WeChat\Exceptions\InvalidResponseException
*/
public function fundEnddayBalance($sub_mchid)
public function fundEnddayBalance($sub_mchid, $query)
{
$pathinfo = "/v3/ecommerce/fund/enddaybalance/{$sub_mchid}";
$pathinfo = "/v3/ecommerce/fund/enddaybalance/{$sub_mchid}?" . http_build_query($query);
return $this->doRequest('GET', $pathinfo, '', true);
}
@ -528,12 +537,13 @@ class Ecommerce extends BasicWePay
/**
* 查询收付通平台账户日终余额API(余额查询)
* @param string $account_type
* @param array $query
* @return array
* @throws \WeChat\Exceptions\InvalidResponseException
*/
public function merchantEnddayBalance($account_type)
public function merchantEnddayBalance($account_type, $query)
{
$pathinfo = "/v3/merchant/fund/enddaybalance/{$account_type}";
$pathinfo = "/v3/merchant/fund/enddaybalance/{$account_type}?" . http_build_query($query);
return $this->doRequest('GET', $pathinfo, '', true);
}
@ -753,10 +763,10 @@ class Ecommerce extends BasicWePay
$time = strval(time());
$appid = $this->config['appid'];
$nonceStr = Tools::createNoncestr();
if ($type === 'app') {
if ($type === Order::WXPAY_APP) {
$sign = $this->signBuild(join("\n", [$appid, $time, $nonceStr, $prepay_id, '']));
return ['partnerId' => $this->config['mch_id'], 'prepayId' => $prepay_id, 'package' => 'Sign=WXPay', 'nonceStr' => $nonceStr, 'timeStamp' => $time, 'sign' => $sign];
} elseif ($type === 'jsapi') {
} elseif ($type === Order::WXPAY_JSAPI) {
$sign = $this->signBuild(join("\n", [$appid, $time, $nonceStr, "prepay_id={$prepay_id}", '']));
return ['appId' => $appid, 'timestamp' => $time, 'timeStamp' => $time, 'nonceStr' => $nonceStr, 'package' => "prepay_id={$prepay_id}", 'signType' => 'RSA', 'paySign' => $sign];
} else {

View File

@ -64,10 +64,10 @@ class Order extends BasicWePay
$time = strval(time());
$appid = $this->config['appid'];
$nonceStr = Tools::createNoncestr();
if ($type === 'app') {
if ($type === self::WXPAY_APP) {
$sign = $this->signBuild(join("\n", [$appid, $time, $nonceStr, $result['prepay_id'], '']));
return ['partnerId' => $this->config['mch_id'], 'prepayId' => $result['prepay_id'], 'package' => 'Sign=WXPay', 'nonceStr' => $nonceStr, 'timeStamp' => $time, 'sign' => $sign];
} elseif ($type === 'jsapi') {
return ['appId' => $appid, 'partnerId' => $this->config['mch_id'], 'prepayId' => $result['prepay_id'], 'package' => 'Sign=WXPay', 'nonceStr' => $nonceStr, 'timeStamp' => $time, 'sign' => $sign];
} elseif ($type === self::WXPAY_JSAPI) {
$sign = $this->signBuild(join("\n", [$appid, $time, $nonceStr, "prepay_id={$result['prepay_id']}", '']));
return ['appId' => $appid, 'timestamp' => $time, 'timeStamp' => $time, 'nonceStr' => $nonceStr, 'package' => "prepay_id={$result['prepay_id']}", 'signType' => 'RSA', 'paySign' => $sign];
} else {
@ -104,11 +104,11 @@ class Order extends BasicWePay
/**
* 支付通知解析
* @param array $data
* @param array|null $data
* @return array
* @throws \WeChat\Exceptions\InvalidDecryptException
*/
public function notify(array $data = [])
public function notify($data = [])
{
if (empty($data)) {
$data = json_decode(Tools::getRawInput(), true);

View File

@ -25,6 +25,37 @@ use WePayV3\Contracts\BasicWePay;
*/
class Transfers extends BasicWePay
{
/**
* 新版商家转换到零钱
* @param $body
* @return array|string
* @throws \WeChat\Exceptions\InvalidDecryptException
* @throws \WeChat\Exceptions\InvalidResponseException
* @link https://pay.weixin.qq.com/doc/v3/merchant/4012716434
*/
public function bills($body)
{
if (empty($body['appid'])) {
$body['appid'] = $this->config['appid'];
}
if (!empty($body['user_name'])) {
$body['user_name'] = $this->rsaEncode($body['user_name']);
}
return $this->doRequest('POST', '/v3/fund-app/mch-transfer/transfer-bills', json_encode($body, JSON_UNESCAPED_UNICODE), true);
}
/**
* 查询转账结果
* @param $out_bill_no
* @return array|string
* @throws \WeChat\Exceptions\InvalidResponseException
*/
public function billsQuery($out_bill_no)
{
return $this->doRequest('GET', "/v3/fund-app/mch-transfer/transfer-bills/out-bill-no/{$out_bill_no}", '', true);
}
/**
* 发起商家批量转账
* @param array $body

View File

@ -1,5 +1,6 @@
# WeChatDeveloper for PHP
[![star](https://gitcode.com/ThinkAdmin/WeChatDeveloper/star/badge.svg)](https://gitcode.com/ThinkAdmin/ThinkAdmin)
[![star](https://gitee.com/zoujingli/WeChatDeveloper/badge/star.svg?theme=gvp)](https://gitee.com/zoujingli/ThinkAdmin)
[![Latest Stable Version](https://poser.pugx.org/zoujingli/wechat-developer/v/stable)](https://packagist.org/packages/zoujingli/wechat-developer)
[![Total Downloads](https://poser.pugx.org/zoujingli/wechat-developer/downloads)](https://packagist.org/packages/zoujingli/wechat-developer)
[![Monthly Downloads](https://poser.pugx.org/zoujingli/wechat-developer/d/monthly)](https://packagist.org/packages/zoujingli/wechat-developer)