|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace App\Controller\Payment;
|
|
|
|
|
|
|
|
use Hyperf\HttpServer\Contract\RequestInterface;
|
|
|
|
use App\Service\PaymentService;
|
|
|
|
use App\Service\UserService;
|
|
|
|
use Hyperf\Context\Context;
|
|
|
|
|
|
|
|
class PayController extends AbstractController
|
|
|
|
{
|
|
|
|
private UserService $userService;
|
|
|
|
private PaymentService $paymentService;
|
|
|
|
|
|
|
|
public function __construct(PaymentService $paymentService, UserService $userService)
|
|
|
|
{
|
|
|
|
$this->userService = $userService;
|
|
|
|
$this->paymentService = $paymentService;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function register(RequestInterface $request)
|
|
|
|
{
|
|
|
|
$requestLog = Context::get('requestLog');
|
|
|
|
$url = $this->userService->register($request->all(), $requestLog->request_token);
|
|
|
|
return $this->success(['url' => $url]);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function bindCard(RequestInterface $request)
|
|
|
|
{
|
|
|
|
$requestLog = Context::get('requestLog');
|
|
|
|
$url = $this->userService->bindCard($request->all(), $requestLog->request_token);
|
|
|
|
return $this->success(['url' => $url]);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function unbindCard(RequestInterface $request)
|
|
|
|
{
|
|
|
|
$data = $this->userService->unbindCard($request->all());
|
|
|
|
return $this->success($data);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function bindCardPay(RequestInterface $request)
|
|
|
|
{
|
|
|
|
$requestLog = Context::get('requestLog');
|
|
|
|
$data = $this->paymentService->bindCardPay($request->all(), $requestLog->request_token);
|
|
|
|
return $this->success($data);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function protocolPayConfirm(RequestInterface $request)
|
|
|
|
{
|
|
|
|
$data = $this->paymentService->protocolPayConfirm($request->all());
|
|
|
|
return $this->success($data);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function refund(RequestInterface $request) {
|
|
|
|
$data = $this->paymentService->refund($request->all());
|
|
|
|
return $this->success($data);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function refundQuery(RequestInterface $request) {
|
|
|
|
$data = $this->paymentService->refundQuery($request->all());
|
|
|
|
return $this->success($data);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function paymentQuery(RequestInterface $request) {
|
|
|
|
$data = $this->paymentService->paymentQuery($request->all());
|
|
|
|
return $this->success($data);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function query(RequestInterface $request) {
|
|
|
|
$data = $this->paymentService->query($request->all());
|
|
|
|
return $this->success($data);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function payment(RequestInterface $request) {
|
|
|
|
$data = $this->paymentService->payment($request->all());
|
|
|
|
return $this->success($data);
|
|
|
|
}
|
|
|
|
}
|