This commit is contained in:
root 2020-01-14 00:29:59 +08:00
parent db9743a67f
commit 9fc4a6129c
4 changed files with 42 additions and 5 deletions

View File

@ -52,7 +52,11 @@ class ConfigController extends Controller
'stripe_webhook_key' => config('v2board.stripe_webhook_key'),
// bitpayx
'bitpayx_enable' => config('v2board.bitpayx_enable'),
'bitpayx_appsecret' => config('v2board.bitpayx_appsecret')
'bitpayx_appsecret' => config('v2board.bitpayx_appsecret'),
// paytaro
'paytaro_enable' => config('v2board.paytaro_enable'),
'paytaro_app_id' => config('v2board.paytaro_app_id'),
'paytaro_app_secret' => config('v2board.paytaro_app_secret')
],
'server' => [
'server_token' => config('v2board.server_token')

View File

@ -17,6 +17,7 @@ use Omnipay\Omnipay;
use Stripe\Stripe;
use Stripe\Source;
use Library\BitpayX;
use Library\PayTaro;
class OrderController extends Controller
{
@ -220,6 +221,14 @@ class OrderController extends Controller
'type' => 1,
'data' => $this->bitpayX($order)
]);
case 5:
if (!(int)config('v2board.paytaro_enable')) {
abort(500, '支付方式不可用');
}
return response([
'type' => 1,
'data' => $this->payTaro($order)
]);
default:
abort(500, '支付方式不存在');
}
@ -274,6 +283,14 @@ class OrderController extends Controller
array_push($data, $bitpayX);
}
if ((int)config('v2board.paytaro_enable')) {
$obj = new \StdClass();
$obj->name = '支付宝';
$obj->method = 5;
$obj->icon = 'alipay';
array_push($data, $obj);
}
return response([
'data' => $data
]);
@ -394,4 +411,17 @@ class OrderController extends Controller
Log::info('bitpayXSubmit: ' . json_encode($result));
return isset($result['payment_url']) ? $result['payment_url'] : false;
}
private function payTaro($order)
{
$payTaro = new PayTaro(config('v2board.paytaro_app_id'), config('v2board.paytaro_app_secret'));
$result = $payTaro->pay([
'app_id' => config('v2board.paytaro_app_id'),
'out_trade_no' => $order->trade_no,
'total_amount' => $order->total_amount,
'notify_url' => url('/api/v1/guest/order/payTaroNotify'),
'return_url' => url('/api/v1/guest/order/payTaroReturn')
]);
return $result;
}
}

View File

@ -37,6 +37,10 @@ class ConfigSave extends FormRequest
// bitpayx
'bitpayx_enable' => 'in:0,1',
'bitpayx_appsecret' => '',
// paytaro
'paytaro_enable' => 'in:0,1',
'paytaro_app_id' => '',
'paytaro_app_secret' => '',
// tutorial
'apple_id' => 'email',
'apple_id_password' => ''

View File

@ -22,16 +22,15 @@ class PayTaro
$params['sign'] = md5($str);
$curl = new Curl();
$curl->post('http://api.paytaro.com/v1/gateway/fetch', http_build_query($params));
var_dump($str, $params, $curl->response);exit;
if ($curl->error) {
abort(500, '接口请求失败');
}
$result = json_decode($curl->response);
$result = $curl->response;
$curl->close();
if ($result->code !== 1) {
if (!isset($result->data->trade_no)) {
abort(500, '接口请求失败');
}
return $result->code_url;
return $result->data->pay_url;
}
public function verify($params)