|
@@ -9,9 +9,8 @@ use Auth;
|
|
|
use Illuminate\Http\JsonResponse;
|
|
|
use Illuminate\Http\Request;
|
|
|
use Response;
|
|
|
-use Illuminate\Support\Facades\Http;
|
|
|
-use Illuminate\Support\Facades\Log;
|
|
|
-
|
|
|
+use Http;
|
|
|
+use Log;
|
|
|
|
|
|
class Zypay extends AbstractPayment
|
|
|
{
|
|
@@ -32,41 +31,54 @@ class Zypay extends AbstractPayment
|
|
|
// $type = 'alipay';
|
|
|
// break;
|
|
|
// }
|
|
|
- $key = "6f13dd44826918a5fc7ab6baa255d99c51b505b3";
|
|
|
+
|
|
|
+// Log::info("[河马支付]请求金额". var_export($payment->amount, true));
|
|
|
+// Log::info("[河马支付]格式化金额". var_export(number_format($payment->amount,2,'.',''), true));
|
|
|
+ $key = "ef32cf2c4b1a352b7340a2465a563cdc9daaf3af";
|
|
|
$data = [
|
|
|
- 'app_id' => "WTQwSt5Dytzs",
|
|
|
- 'out_trade_no' => $payment->trade_no,
|
|
|
- 'total_amount' => $payment->amount * 100,
|
|
|
- 'notify_url' => route('payment.notify', ['method' => 'zpay']),
|
|
|
- 'return_url' => route('invoice'),
|
|
|
+ 'version' => '1.0',
|
|
|
+ 'customerid' => "11635",
|
|
|
+ 'sdorderno' => $payment->trade_no,
|
|
|
+ 'total_fee' => number_format($payment->amount,2,'.',''),
|
|
|
+ 'notifyurl' => route('payment.notify', ['method' => 'zpay']),
|
|
|
+ 'returnurl' => route('invoice'),
|
|
|
+ 'paytype' => 'alipay',
|
|
|
+ 'bankcode' => '',
|
|
|
+ 'remark' => '测试',
|
|
|
+ 'get_code' => 1,
|
|
|
+
|
|
|
];
|
|
|
- ksort($data);
|
|
|
- $str = http_build_query($data);
|
|
|
- $data['sign'] = strtolower(md5($str . $key));
|
|
|
-
|
|
|
- $curl = curl_init();
|
|
|
- curl_setopt($curl, CURLOPT_URL, "https://api.hmcheckout.com" . '/api/v1/tron');
|
|
|
- curl_setopt($curl, CURLOPT_HEADER, 0);
|
|
|
- curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
|
|
|
- curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
|
|
|
- curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
|
|
|
- curl_setopt($curl, CURLOPT_POST, 1);
|
|
|
- curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
|
|
|
- curl_setopt($curl, CURLOPT_HTTPHEADER, ['User-Agent: Alpha']);
|
|
|
- $res = curl_exec($curl);
|
|
|
- curl_close($curl);
|
|
|
- $result = json_decode($res, true);
|
|
|
- if (!$result) {
|
|
|
- return Response::json(['status' => 'success', 'url' => "", 'message' => '网络异常!']);
|
|
|
- }
|
|
|
+ #ksort($data);
|
|
|
|
|
|
- Log::info("[河马支付]请求支付接口". var_export($result, true));
|
|
|
- if ($result["code"] === 0 ){
|
|
|
- return Response::json(['status' => 'fail', 'message' => '创建订单失败!'.$result['error']]);
|
|
|
- }
|
|
|
- return Response::json(['status' => 'success', 'url' => $result['url'], 'message' => '创建订单成功!']);
|
|
|
|
|
|
+ // 构建签名字符串
|
|
|
+ $signStr = 'version=' . $data["version"] .
|
|
|
+ '&customerid=' . $data["customerid"] .
|
|
|
+ '&total_fee=' . $data["total_fee"] .
|
|
|
+ '&sdorderno=' . $data["sdorderno"] .
|
|
|
+ '¬ifyurl=' . $data["notifyurl"] .
|
|
|
+ '&returnurl=' . $data["returnurl"] .
|
|
|
+ '&' . $key;
|
|
|
+
|
|
|
+ Log::info("[河马支付]原始构建签名字符串". var_export($data, true));
|
|
|
+ Log::info("[河马支付]构建签名字符串". var_export($signStr, true));
|
|
|
+ // 计算签名
|
|
|
+ $data['sign'] = md5($signStr);
|
|
|
+
|
|
|
+
|
|
|
+ Log::info("[河马支付]构建参数". var_export($data, true));
|
|
|
+
|
|
|
+ $response = Http::get('http://pay.mssdk.com/apisubmit', $data);
|
|
|
+ if ($response->ok()) {
|
|
|
|
|
|
+ $result = $response->json();
|
|
|
+ Log::error('【河马支付】 返回错误信息:'.var_export($result, true));
|
|
|
+ if ($result['status'] === 1) {
|
|
|
+ return Response::json(['status' => 'success', 'url' => $result['page_url'], 'message' => '创建订单成功!']);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return Response::json(['status' => 'fail', 'message' => '创建在线订单失败,请工单通知管理员!']);
|
|
|
}
|
|
|
|
|
|
public function notify(Request $request): void
|
|
@@ -74,8 +86,8 @@ class Zypay extends AbstractPayment
|
|
|
if ($this->verifySign($request->post())){
|
|
|
exit('SIGN FAIL');
|
|
|
}
|
|
|
- if ($request->has(['out_trade_no']) && $this->paymentReceived($request->input(['out_trade_no'])) ) {
|
|
|
- $this->addPamentCallback($request->input('out_trade_no'),$request->input('trade_no'),"");
|
|
|
+ if ($request->has(['sdorderno']) && $this->paymentReceived($request->input(['sdorderno'])) ) {
|
|
|
+ $this->addPamentCallback($request->input('sdorderno'),$request->input('sdpayno'),"");
|
|
|
Log::info('【河马支付】paymentReceived:'.var_export($request->all(), true));
|
|
|
exit(json_encode(['status' => 200]));
|
|
|
}
|
|
@@ -83,30 +95,29 @@ class Zypay extends AbstractPayment
|
|
|
|
|
|
function verifySign($params)
|
|
|
{
|
|
|
- $key = "6e13274fe90055e38f0751c3e242af1882abc849";
|
|
|
+ $key = "ef32cf2c4b1a352b7340a2465a563cdc9daaf3af";
|
|
|
$sign = $params['sign'];
|
|
|
- unset($params['sign']);
|
|
|
- ksort($params);
|
|
|
- $str = strtolower(http_build_query($params) . $key);
|
|
|
- if ($sign !== md5($str)) {
|
|
|
+ $data = [
|
|
|
+ 'customerid' => $params['customerid'],
|
|
|
+ 'status' => $params['status'],
|
|
|
+ 'sdpayno' => $params['sdpayno'],
|
|
|
+ 'sdorderno' => $params['sdorderno'],
|
|
|
+ 'total_fee' => $params['total_fee'],
|
|
|
+ 'paytype' => $params['paytype'],
|
|
|
+ ];
|
|
|
+ // 构建签名字符串
|
|
|
+ $signStr = 'customerid=' . $params["customerid"] .
|
|
|
+ '&status=' . $params["status"] .
|
|
|
+ '&sdpayno=' . $params["sdpayno"] .
|
|
|
+ '&sdorderno=' . $params["sdorderno"] .
|
|
|
+ '&total_fee=' . $params["total_fee"] .
|
|
|
+ '&paytype=' . $params["paytype"] .
|
|
|
+ '&' . $key;
|
|
|
+
|
|
|
+ //$str = http_build_query($data) . '&' . $key;
|
|
|
+ if ($sign !== md5($signStr)) {
|
|
|
return false;
|
|
|
}
|
|
|
- return $str;
|
|
|
-
|
|
|
- // 剃离sign,sign_type,空值
|
|
|
-// unset($data['sign'], $data['sign_type'] , $data["method"]);
|
|
|
-
|
|
|
-
|
|
|
-// if ($filter) {
|
|
|
-// $data = array_filter($data);
|
|
|
-// }
|
|
|
-
|
|
|
- // 排序
|
|
|
-// ksort($data, SORT_STRING);
|
|
|
-// reset($data);
|
|
|
-//
|
|
|
-//
|
|
|
-// $data["key"] = $key;
|
|
|
-// return strtoupper(md5(urldecode(http_build_query($data))));
|
|
|
+ return true;
|
|
|
}
|
|
|
}
|