Skip to content

Commit 4e565b3

Browse files
committed
企业付款银行卡查询
1 parent fa5ecfa commit 4e565b3

File tree

4 files changed

+146
-1
lines changed

4 files changed

+146
-1
lines changed

src/BaseAbstractGateway.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,4 +264,14 @@ public function getPublicKey($parameters = array())
264264
{
265265
return $this->createRequest('\Omnipay\WechatPay\Message\GetPublicKeyRequest', $parameters);
266266
}
267+
268+
/**
269+
* @param array $parameters
270+
*
271+
* @return \Omnipay\WechatPay\Message\QueryBankRequest
272+
*/
273+
public function queryBank($parameters = array())
274+
{
275+
return $this->createRequest('\Omnipay\WechatPay\Message\QueryBankRequest', $parameters);
276+
}
267277
}

src/Message/GetPublicKeyRequest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,6 @@ public function sendData($data)
9898
$response = $client->request('POST', $this->endpoint, $options)->getBody();
9999
$responseData = Helper::xml2array($response);
100100

101-
return $this->response = new PayBankResponse($this, $responseData);
101+
return $this->response = new GetPublicKeyResponse($this, $responseData);
102102
}
103103
}

src/Message/QueryBankRequest.php

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
<?php
2+
3+
namespace Omnipay\WechatPay\Message;
4+
5+
use GuzzleHttp\Client;
6+
use Omnipay\Common\Exception\InvalidRequestException;
7+
use Omnipay\Common\Message\ResponseInterface;
8+
use Omnipay\WechatPay\Helper;
9+
10+
/**
11+
* Class QueryBankRequest
12+
*
13+
* @package Omnipay\WechatPay\Message
14+
* @link https://pay.weixin.qq.com/wiki/doc/api/tools/mch_pay.php?chapter=24_3
15+
* @method QueryBankResponse send()
16+
*/
17+
class QueryBankRequest extends BaseAbstractRequest
18+
{
19+
protected $endpoint = 'https://api.mch.weixin.qq.com/mmpaysptrans/query_bank';
20+
21+
/**
22+
* Get the raw data array for this message. The format of this varies from gateway to
23+
* gateway, but will usually be either an associative array, or a SimpleXMLElement.
24+
* @return mixed
25+
* @throws InvalidRequestException
26+
*/
27+
public function getData()
28+
{
29+
$this->validate('mch_id', 'partner_trade_no', 'cert_path', 'key_path');
30+
31+
$data = array(
32+
'mch_id' => $this->getMchId(),
33+
'partner_trade_no' => $this->getPartnerTradeNo(),
34+
'nonce_str' => md5(uniqid()),
35+
);
36+
37+
$data = array_filter($data);
38+
39+
$data['sign'] = Helper::sign($data, $this->getApiKey());
40+
41+
return $data;
42+
}
43+
44+
45+
/**
46+
* @return mixed
47+
*/
48+
public function getPartnerTradeNo()
49+
{
50+
return $this->getParameter('partner_trade_no');
51+
}
52+
53+
54+
/**
55+
* @param mixed $partnerTradeNo
56+
*/
57+
public function setPartnerTradeNo($partnerTradeNo)
58+
{
59+
$this->setParameter('partner_trade_no', $partnerTradeNo);
60+
}
61+
62+
63+
/**
64+
* @return mixed
65+
*/
66+
public function getCertPath()
67+
{
68+
return $this->getParameter('cert_path');
69+
}
70+
71+
72+
/**
73+
* @param mixed $certPath
74+
*/
75+
public function setCertPath($certPath)
76+
{
77+
$this->setParameter('cert_path', $certPath);
78+
}
79+
80+
81+
/**
82+
* @return mixed
83+
*/
84+
public function getKeyPath()
85+
{
86+
return $this->getParameter('key_path');
87+
}
88+
89+
90+
/**
91+
* @param mixed $keyPath
92+
*/
93+
public function setKeyPath($keyPath)
94+
{
95+
$this->setParameter('key_path', $keyPath);
96+
}
97+
98+
99+
/**
100+
* Send the request with specified data
101+
*
102+
* @param mixed $data The data to send
103+
*
104+
* @return ResponseInterface
105+
*/
106+
public function sendData($data)
107+
{
108+
$body = Helper::array2xml($data);
109+
$client = new Client();
110+
111+
$options = [
112+
'body' => $body,
113+
'verify' => true,
114+
'cert' => $this->getCertPath(),
115+
'ssl_key' => $this->getKeyPath(),
116+
];
117+
$response = $client->request('POST', $this->endpoint, $options)->getBody();
118+
$responseData = Helper::xml2array($response);
119+
120+
return $this->response = new QueryBankResponse($this, $responseData);
121+
}
122+
}

src/Message/QueryBankResponse.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
namespace Omnipay\WechatPay\Message;
4+
5+
/**
6+
* Class QueryBankResponse
7+
*
8+
* @package Omnipay\WechatPay\Message
9+
* @link https://pay.weixin.qq.com/wiki/doc/api/tools/mch_pay.php?chapter=24_3
10+
*/
11+
class QueryBankResponse extends BaseAbstractResponse
12+
{
13+
}

0 commit comments

Comments
 (0)