|
|
@@ -218,15 +218,61 @@ class FinanceService extends Service
|
|
|
Redis::setnx($key, 1);
|
|
|
Redis::expire($key, 5); //五秒后过期
|
|
|
|
|
|
- // 发送支付 TODO
|
|
|
- list($status, $msg, $orderNumber) = $this->paymentRequest($data);
|
|
|
- if($status == 201) return [false, $msg];
|
|
|
+ // 发送支付
|
|
|
+ $send = [
|
|
|
+ "customName" => $data['finance_account_name'],
|
|
|
+ "bankAccount" => $data['account'],
|
|
|
+ "ifsc" => $data['ifsc'],
|
|
|
+ "amount" => $data['amount'],
|
|
|
+ ];
|
|
|
+ $send['sign'] = $this->sign($send);
|
|
|
+ list($status, $msg) = $this->paymentRequest($send);
|
|
|
+ if(! $status) return [false, $msg];
|
|
|
+
|
|
|
+ return [true, $msg];
|
|
|
+ }
|
|
|
+
|
|
|
+ //加密
|
|
|
+ public function sign($data){
|
|
|
+ $str = [];
|
|
|
+ sort($data);
|
|
|
+ foreach ($data as $k=>$v){
|
|
|
+ $str[] = $k.'='.$v;
|
|
|
+ }
|
|
|
|
|
|
- return [true, $orderNumber];
|
|
|
+ $vaild = implode(',',$str).'doTAKtnpiG';
|
|
|
+ return md5($vaild);
|
|
|
}
|
|
|
|
|
|
- //发送支付请求返回 TODO
|
|
|
- public function paymentRequest($data){
|
|
|
- return [200,'成功','测试订单号222222'];
|
|
|
+ //发送支付请求返回
|
|
|
+ public function paymentRequest($send){
|
|
|
+ $url = "https://api2.indiacashpayment.in/chargeMoney9321";
|
|
|
+ $result = $this->curlURL($url,$send);
|
|
|
+
|
|
|
+ if($result['status'] == 201){
|
|
|
+ return [false, $result['msg']];
|
|
|
+ }
|
|
|
+
|
|
|
+ return [true, $result['data']['order_no']];
|
|
|
+ }
|
|
|
+
|
|
|
+ public function curlURL($url,$data){
|
|
|
+ $data = json_encode($data);
|
|
|
+ $header[] = "Content-Type:application/json";
|
|
|
+ $ch=curl_init($url);
|
|
|
+ curl_setopt($ch,CURLOPT_POST,1);
|
|
|
+ curl_setopt($ch,CURLOPT_POSTFIELDS,$data);
|
|
|
+ curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
|
|
|
+ curl_setopt($ch,CURLOPT_HTTPHEADER,$header);
|
|
|
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
|
|
|
+ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
|
|
|
+ $response=curl_exec($ch);
|
|
|
+ file_put_contents('charge.txt',$response.PHP_EOL,8);
|
|
|
+ $response=json_decode($response,true);
|
|
|
+
|
|
|
+ if(curl_errno($ch) ){
|
|
|
+ sc(curl_error($ch));
|
|
|
+ }
|
|
|
+ return $response;
|
|
|
}
|
|
|
}
|