Skip to content

Commit edf371f

Browse files
committed
添加微信开发配置接口
1 parent 5d77df0 commit edf371f

File tree

5 files changed

+138
-5
lines changed

5 files changed

+138
-5
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?php
2+
3+
namespace TPay\AddWeChatConfig;
4+
5+
6+
use TPay\BaseParams;
7+
8+
/**
9+
* @property $appid
10+
* @property $path
11+
* @property $subscribeAppid
12+
* Class AddWeChatConfigParams
13+
* @package TPay\addWeChatConfig
14+
*/
15+
class AddWeChatConfigParams extends BaseParams
16+
{
17+
/**
18+
* @return mixed
19+
*/
20+
public function getAppid()
21+
{
22+
return $this->data['appid'];
23+
}
24+
25+
/**
26+
* @param mixed $appid
27+
*/
28+
public function setAppid($appid): void
29+
{
30+
$this->data['appid'] = $appid;
31+
}
32+
33+
/**
34+
* @return mixed
35+
*/
36+
public function getPath()
37+
{
38+
return $this->data['path'];
39+
}
40+
41+
/**
42+
* @param mixed $path
43+
*/
44+
public function setPath($path): void
45+
{
46+
$this->data['path'] = $path;
47+
}
48+
49+
/**
50+
* @return mixed
51+
*/
52+
public function getSubscribeAppid()
53+
{
54+
return $this->data['subscribeAppid'];
55+
}
56+
57+
/**
58+
* @param mixed $subscribeAppid
59+
*/
60+
public function setSubscribeAppid($subscribeAppid): void
61+
{
62+
$this->data['subscribeAppid'] = $subscribeAppid;
63+
}
64+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
namespace TPay\AddWeChatConfig;
4+
5+
6+
use TPay\BaseResponse;
7+
8+
class AddWeChatConfigResponse extends BaseResponse
9+
{
10+
11+
}

Src/Client.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
namespace TPay;
99

1010

11+
use TPay\AddWeChatConfig\AddWeChatConfigParams;
12+
use TPay\AddWeChatConfig\AddWeChatConfigResponse;
1113
use TPay\BarcodePay\BarcodePayParams;
1214
use TPay\BarcodePay\BarcodePayResponse;
1315
use TPay\PreCreate\PreCreateParams;
@@ -150,6 +152,22 @@ public function cancel(TradeCancelParams $params)
150152
return $response;
151153
}
152154

155+
/**
156+
* 添加微信开发配置
157+
* @param AddWeChatConfigParams $params
158+
* @return AddWeChatConfigResponse
159+
* @throws ParamsException
160+
* @throws RequestException
161+
*/
162+
public function addWeChatConfig(AddWeChatConfigParams $params)
163+
{
164+
$response = new AddWeChatConfigResponse();
165+
166+
$this->request('open/merchant/addWeChatConfig', $params, $response);
167+
168+
return $response;
169+
}
170+
153171
/**
154172
* 发起请求
155173
* @param $api
@@ -171,7 +189,6 @@ public function request($api, BaseParams $params, BaseResponse $response = null)
171189
$rawData['sign'] = $this->generateSign($rawData);
172190

173191
$result = json_decode($this->curlPOST($this->domain . $api, $rawData), true);
174-
var_dump($result);
175192

176193
// 转为response对象
177194
if (!is_null($response)) {

Src/TPayManager.php

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@
88
namespace TPay;
99

1010

11+
use TPay\AddWeChatConfig\AddWeChatConfigParams;
1112
use TPay\BarcodePay\BarcodePayParams;
1213
use TPay\PreCreate\PreCreateParams;
1314
use TPay\Refund\RefundParams;
1415
use TPay\RefundQuery\RefundQueryParams;
1516
use TPay\TradeCancel\TradeCancelParams;
1617
use TPay\TradeCreate\TradeCreateParams;
18+
use TPay\TradeCreate\TradeCreateResponse;
1719
use TPay\TradeQuery\TradeQueryParams;
1820

1921
class TPayManager
@@ -163,7 +165,7 @@ public static function newTradeCreateParams($payType, $outTradeNo, $amount, $sub
163165
* @param $body
164166
* @param $buyerId
165167
* @param string $notifyURL
166-
* @return PreCreate\TradeCreateResponse
168+
* @return TradeCreateResponse
167169
* @throws ParamsException
168170
* @throws RequestException
169171
*/
@@ -323,4 +325,43 @@ public static function cancel(Client $client, $payType, $outTradeNo = '', $chann
323325

324326
return $client->cancel($params);
325327
}
328+
329+
/**
330+
* 获取新的添加微信开发配置参数对象
331+
* @param string $appid
332+
* @param string $path
333+
* @param string $subscribeAppid
334+
* @return AddWeChatConfigParams
335+
* @throws ParamsException
336+
*/
337+
public static function newAddWeChatConfigParams($appid = '', $path = '', $subscribeAppid = '')
338+
{
339+
$params = new AddWeChatConfigParams();
340+
$params->setSubscribeAppid($subscribeAppid);
341+
$params->setAppid($appid);
342+
$params->setPath($path);
343+
344+
if (empty($params->getData())) {
345+
throw new ParamsException('appid,path,subscribeAppid 不能同时为空');
346+
}
347+
348+
return $params;
349+
}
350+
351+
/**
352+
* 添加微信开发配置
353+
* @param Client $client
354+
* @param string $appid
355+
* @param string $path
356+
* @param string $subscribeAppid
357+
* @return AddWeChatConfig\AddWeChatConfigResponse
358+
* @throws ParamsException
359+
* @throws RequestException
360+
*/
361+
public static function addWeChatConfig(Client $client, $appid = '', $path = '', $subscribeAppid = '')
362+
{
363+
$params = self::newAddWeChatConfigParams($appid, $path, $subscribeAppid);
364+
365+
return $client->addWeChatConfig($params);
366+
}
326367
}

test.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525

2626
// 通过helper直接发起请求
27-
/*$response = TPayManager::barcodePay($client, 1, 'FZY2019112101', 0.01, 'authcode',
27+
/*$response = TPayManager::barcodePay($client, 1, 'FZY2019112204', 0.03, 'xxxxxxxxxxxxxxx',
2828
'测试订单', '测试订单');*/
2929

3030
//$response = TPayManager::preCreate($client, 1, 'FZY2019112201', 0.01, '测试订单', '测试订单');
@@ -35,9 +35,9 @@
3535

3636
//$response = TPayManager::cancel($client, 1, 'FZY2019112202');
3737

38-
//$response = TPayManager::refund($client, 1, 0.01, 0.01, 'FZY2019112201', 'FZY2019112201');
38+
$response = TPayManager::refund($client, 1, 0.01, 0.03, 'FZY201911220403', 'FZY2019112204');
3939

40-
$response = TPayManager::refundQuery($client, 1, 'FZY2019112201', 'FZY2019112201');
40+
//$response = TPayManager::refundQuery($client, 1, 'FZY2019112201', 'FZY2019112201');
4141

4242
echo PHP_EOL;
4343
echo $response;

0 commit comments

Comments
 (0)