File tree 3 files changed +93
-0
lines changed
3 files changed +93
-0
lines changed Original file line number Diff line number Diff line change @@ -126,6 +126,11 @@ public function completePurchase($parameters = array ())
126
126
return $ this ->createRequest ('\Omnipay\WechatPay\Message\CompletePurchaseRequest ' , $ parameters );
127
127
}
128
128
129
+ public function completeRefund ($ parameters = array ())
130
+ {
131
+ return $ this ->createRequest ('\Omnipay\WechatPay\Message\CompleteRefundRequest ' , $ parameters );
132
+ }
133
+
129
134
130
135
/**
131
136
* @param array $parameters
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Omnipay \WechatPay \Message ;
4
+
5
+ use Omnipay \WechatPay \Helper ;
6
+
7
+ class CompleteRefundRequest extends BaseAbstractRequest
8
+ {
9
+
10
+ public function setRequestParams ($ requestParams )
11
+ {
12
+ $ this ->setParameter ('request_params ' , $ requestParams );
13
+ }
14
+
15
+ public function sendData ($ data )
16
+ {
17
+ $ data = $ this ->getData ();
18
+ $ sign = Helper::sign ($ data , $ this ->getApiKey ());
19
+
20
+ $ responseData = array ();
21
+
22
+ if (isset ($ data ['sign ' ]) && $ data ['sign ' ] && $ sign === $ data ['sign ' ]) {
23
+ $ responseData ['sign_match ' ] = true ;
24
+ } else {
25
+ $ responseData ['sign_match ' ] = false ;
26
+ }
27
+
28
+ if ($ responseData ['sign_match ' ] && isset ($ data ['refund_status ' ]) && $ data ['refund_status ' ] == 'SUCCESS ' ) {
29
+ $ responseData ['refunded ' ] = true ;
30
+ } else {
31
+ $ responseData ['refunded ' ] = false ;
32
+ }
33
+
34
+ return $ this ->response = new CompleteRefundResponse ($ this , $ responseData );
35
+ }
36
+
37
+ public function getData ()
38
+ {
39
+ $ data = $ this ->getRequestParams ();
40
+
41
+ if (is_string ($ data )) {
42
+ $ data = Helper::xml2array ($ data );
43
+ }
44
+
45
+ return $ data ;
46
+ }
47
+
48
+
49
+ public function getRequestParams ()
50
+ {
51
+ return $ this ->getParameter ('request_params ' );
52
+ }
53
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Omnipay \WechatPay \Message ;
4
+
5
+ use Omnipay \Common \Message \AbstractResponse ;
6
+
7
+ class CompleteRefundResponse extends AbstractResponse
8
+ {
9
+
10
+ public function isSuccessful ()
11
+ {
12
+ return $ this ->isRefunded ();
13
+ }
14
+
15
+ public function isRefunded ()
16
+ {
17
+ $ data = $ this ->getData ();
18
+
19
+ return $ data ['refunded ' ];
20
+ }
21
+
22
+
23
+ public function isSignMatch ()
24
+ {
25
+ $ data = $ this ->getData ();
26
+
27
+ return $ data ['sign_match ' ];
28
+ }
29
+
30
+
31
+ public function getRequestData ()
32
+ {
33
+ return $ this ->request ->getData ();
34
+ }
35
+ }
You can’t perform that action at this time.
0 commit comments