mirror of
https://gitee.com/zoujingli/WeChatDeveloper.git
synced 2025-12-04 16:32:09 +08:00
Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c901adfb29 | ||
|
|
15622a4009 | ||
|
|
8dd0601357 | ||
|
|
cdf88da1a9 | ||
|
|
59ca095072 | ||
|
|
1182a2dc97 | ||
|
|
97825e0556 | ||
|
|
c617666343 | ||
|
|
7b291e343c | ||
|
|
0885bd4c5a |
@ -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
|
||||
|
||||
@ -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
95
WeMini/Shopping.php
Normal 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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -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']] = [
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
# WeChatDeveloper for PHP
|
||||
|
||||
[](https://gitcode.com/ThinkAdmin/ThinkAdmin)
|
||||
[](https://gitee.com/zoujingli/ThinkAdmin)
|
||||
[](https://packagist.org/packages/zoujingli/wechat-developer)
|
||||
[](https://packagist.org/packages/zoujingli/wechat-developer)
|
||||
[](https://packagist.org/packages/zoujingli/wechat-developer)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user