|
|
@@ -18,7 +18,7 @@ class SanJinService extends BaseService
|
|
|
// 获取异步的通知地址
|
|
|
public static function getNotifyUrl()
|
|
|
{
|
|
|
- return 'https://botpc28.testx2.cc/';
|
|
|
+ return 'https://botpc28.testx2.cc/api/pay/notify';
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -60,18 +60,19 @@ class SanJinService extends BaseService
|
|
|
return json_decode($body->getContents(), true);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- public static function pay($amount, $order_no, $notify_url, $return_url)
|
|
|
+ // 代收
|
|
|
+ public static function pay($amount, $order_no, $payType = self::ALIPAY_TO_ALIPAY)
|
|
|
{
|
|
|
$data = [];
|
|
|
$merchant_id = config('app.tree_payment_merchant_id');
|
|
|
$secret = config('app.tree_payment_secret');
|
|
|
-
|
|
|
+ $notify_url = self::getNotifyUrl();
|
|
|
$data['merchantNum'] = $merchant_id;
|
|
|
$data['amount'] = $amount;
|
|
|
$data['orderNo'] = $order_no;
|
|
|
$data['notifyUrl'] = $notify_url;
|
|
|
- $data['returnUrl'] = $return_url;
|
|
|
+ $data['payType'] = $payType;
|
|
|
+ // $data['returnUrl'] = $return_url;
|
|
|
|
|
|
$signStr = $merchant_id . $order_no . $amount . $secret;
|
|
|
$sign = md5($signStr);
|
|
|
@@ -79,9 +80,45 @@ class SanJinService extends BaseService
|
|
|
|
|
|
$client = self::getClient();
|
|
|
$response = $client->post('api/pay', [
|
|
|
- 'json' => $data,
|
|
|
+ 'form_params' => $data,
|
|
|
+ 'headers' => [
|
|
|
+ 'Content-Type' => 'application/x-www-form-urlencoded',
|
|
|
+ ]
|
|
|
+ ]);
|
|
|
+ $body = $response->getBody();
|
|
|
+ $result = json_decode($body->getContents(), true);
|
|
|
+
|
|
|
+ return $result;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 代付
|
|
|
+ public static function payout($amount, $order_no, $bank_name, $account, $card_no, $payType = self::ALIPAY_TO_ALIPAY)
|
|
|
+ {
|
|
|
+ $data = [];
|
|
|
+ $merchant_id = config('app.tree_payment_merchant_id');
|
|
|
+ $secret = config('app.tree_payment_secret');
|
|
|
+ $notify_url = self::getNotifyUrl();
|
|
|
+
|
|
|
+ $data['merchantNum'] = $merchant_id;
|
|
|
+ $data['amount'] = $amount;
|
|
|
+ $data['orderNo'] = $order_no;
|
|
|
+ $data['notifyUrl'] = $notify_url;
|
|
|
+ $data['payType'] = $payType;
|
|
|
+
|
|
|
+ $signStr = $merchant_id . $order_no . $amount . $secret;
|
|
|
+ $sign = md5($signStr);
|
|
|
+ $data['sign'] = $sign;
|
|
|
+
|
|
|
+ $data['bankName'] = $bank_name;
|
|
|
+ $data['account'] = $account;
|
|
|
+ $data['cardNumber'] = $card_no;
|
|
|
+
|
|
|
+
|
|
|
+ $client = self::getClient();
|
|
|
+ $response = $client->post('api/payout', [
|
|
|
+ 'form_params' => $data,
|
|
|
'headers' => [
|
|
|
- 'Content-Type' => 'application/json',
|
|
|
+ 'Content-Type' => 'application/x-www-form-urlencoded',
|
|
|
]
|
|
|
]);
|
|
|
$body = $response->getBody();
|