66use Yzh \ApiUserSignServiceClient ;
77use Yzh \Config ;
88use Yzh \Model \Apiusersign \ApiUserSignContractRequest ;
9- use Yzh \Model \Apiusersign \ApiUserSignContractResponse ;
109use Yzh \Model \Apiusersign \ApiUserSignReleaseRequest ;
11- use Yzh \Model \Apiusersign \ApiUserSignReleaseResponse ;
1210use Yzh \Model \Apiusersign \ApiUserSignRequest ;
13- use Yzh \Model \Apiusersign \ ApiUserSignResponse ;
11+ use Yzh \Model \Notify \ NotifyRequest ;
1412use Yzh \Model \Payment \CreateAlipayOrderRequest ;
15- use Yzh \Model \Payment \CreateAlipayOrderResponse ;
1613use Yzh \Model \Payment \CreateBankpayOrderRequest ;
17- use Yzh \Model \ Payment \ CreateBankpayOrderResponse ;
14+ use Yzh \NotifyClient ;
1815use Yzh \PaymentClient ;
1916
2017class Service
@@ -25,6 +22,8 @@ class Service
2522
2623 protected static string $ projectId = '' ;
2724
25+ protected static bool $ validateNotifyIP = false ;
26+
2827 protected Config $ config ;
2928
3029 public function __construct (array $ config )
@@ -35,7 +34,7 @@ public function __construct(array $config)
3534 $ this ->config = Config::newFromArray ($ config );
3635 }
3736
38- public function getContract (): ApiUserSignContractResponse
37+ public function getContract (): ResponseAdapter
3938 {
4039 $ client = new ApiUserSignServiceClient ($ this ->config );
4140
@@ -46,10 +45,10 @@ public function getContract(): ApiUserSignContractResponse
4645
4746 $ request ->setRequestID ((string ) Str::orderedUuid ());
4847
49- return $ client ->apiUserSignContract ($ request );
48+ return new ResponseAdapter ( $ client ->apiUserSignContract ($ request) );
5049 }
5150
52- public function sign (string $ name , string $ idCard ): ApiUserSignResponse
51+ public function sign (string $ name , string $ idCard ): ResponseAdapter
5352 {
5453 $ client = new ApiUserSignServiceClient ($ this ->config );
5554
@@ -63,10 +62,10 @@ public function sign(string $name, string $idCard): ApiUserSignResponse
6362
6463 $ request ->setRequestID ((string ) Str::orderedUuid ());
6564
66- return $ client ->apiUserSign ($ request );
65+ return new ResponseAdapter ( $ client ->apiUserSign ($ request) );
6766 }
6867
69- public function unsign (string $ name , string $ idCard ): ApiUserSignReleaseResponse
68+ public function unsign (string $ name , string $ idCard ): ResponseAdapter
7069 {
7170 $ client = new ApiUserSignServiceClient ($ this ->config );
7271
@@ -80,10 +79,16 @@ public function unsign(string $name, string $idCard): ApiUserSignReleaseResponse
8079
8180 $ request ->setRequestID ((string ) Str::orderedUuid ());
8281
83- return $ client ->apiUserSignRelease ($ request );
82+ return new ResponseAdapter ( $ client ->apiUserSignRelease ($ request) );
8483 }
8584
86- protected function payWithBankCard (BankCard $ bankCard , string $ amount , string $ orderId , string $ payRemark , string $ notifyUrl , string $ projectId ): CreateBankpayOrderResponse
85+ protected function payWithBankCard (
86+ BankCard $ bankCard ,
87+ string $ amount ,
88+ string $ orderId ,
89+ string $ payRemark ,
90+ string $ notifyUrl ,
91+ string $ projectId ): ResponseAdapter
8792 {
8893 $ client = new PaymentClient ($ this ->config );
8994
@@ -103,10 +108,16 @@ protected function payWithBankCard(BankCard $bankCard, string $amount, string $o
103108
104109 $ request ->setRequestID ((string ) Str::orderedUuid ());
105110
106- return $ client ->createBankpayOrder ($ request );
111+ return new ResponseAdapter ( $ client ->createBankpayOrder ($ request) );
107112 }
108113
109- protected function payWithAlipay (BankCard $ bankCard , string $ amount , string $ orderId , string $ payRemark , string $ notifyUrl , string $ projectId ): CreateAlipayOrderResponse
114+ protected function payWithAlipay (
115+ BankCard $ bankCard ,
116+ string $ amount ,
117+ string $ orderId ,
118+ string $ payRemark ,
119+ string $ notifyUrl ,
120+ string $ projectId ): ResponseAdapter
110121 {
111122 $ client = new PaymentClient ($ this ->config );
112123
@@ -127,7 +138,7 @@ protected function payWithAlipay(BankCard $bankCard, string $amount, string $ord
127138
128139 $ request ->setRequestID ((string ) Str::orderedUuid ());
129140
130- return $ client ->createAlipayOrder ($ request );
141+ return new ResponseAdapter ( $ client ->createAlipayOrder ($ request) );
131142 }
132143
133144 /**
@@ -144,7 +155,7 @@ public function pay(
144155 string $ payRemark = '' ,
145156 string $ notifyUrl = '' ,
146157 string $ projectId = ''
147- ): CreateBankpayOrderResponse | CreateAlipayOrderResponse {
158+ ): ResponseAdapter {
148159 $ payRemark = ($ payRemark !== '' ) ? $ payRemark : static ::$ payRemark ;
149160 $ notifyUrl = ($ notifyUrl !== '' ) ? $ notifyUrl : static ::$ notifyUrl ;
150161 $ projectId = ($ projectId !== '' ) ? $ projectId : static ::$ projectId ;
@@ -158,6 +169,15 @@ public function pay(
158169 }
159170 }
160171
172+ public function processCallback (): ResponseAdapter
173+ {
174+ $ client = new NotifyClient ($ this ->config );
175+
176+ $ request = new NotifyRequest (request ('data ' ), request ('mess ' ), request ('timestamp ' ), request ('sign ' ));
177+
178+ return new ResponseAdapter ($ client ->verifyAndDecrypt ($ request ));
179+ }
180+
161181 public static function payRemarkUsing (string $ payRemark ): void
162182 {
163183 static ::$ payRemark = $ payRemark ;
0 commit comments