You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
payment/app/Controller/Payment/PayController.php

98 lines
3.0 KiB
PHTML

2 years ago
<?php
declare(strict_types=1);
namespace App\Controller\Payment;
2 years ago
use App\Exception\BusinessException;
use App\Helper\Efps\Api;
use App\Request\BindCardConfirmRequest;
use App\Request\BindCardRequest;
2 years ago
use App\Request\JsapiPayRequest;
2 years ago
use App\Request\ProtocolPayConfirmRequest;
use App\Request\ProtocolPayPreRequest;
use App\Request\RegisterRequest;
use App\Request\UnBindCardRequest;
2 years ago
use Hyperf\HttpServer\Contract\RequestInterface;
use App\Service\PaymentService;
class PayController extends AbstractController
{
private PaymentService $paymentService;
public function __construct(PaymentService $paymentService)
{
$this->paymentService = $paymentService;
}
public function jsapi(RequestInterface $request)
{
$form = new JsapiPayRequest($request->all());
$order = $this->paymentService->jsapiPay($form->getApp(), $form->getData());
return $this->success([
'pay_url' => $order->pay_url,
'order_no' => $order->order_no,
]);
}
2 years ago
2 years ago
public function register(RequestInterface $request)
2 years ago
{
2 years ago
$req = new RegisterRequest($request->all());
$result = Api::register($req->getData());
if (!$result->isSuccess()) {
throw new BusinessException($result->getMessage());
}
return $this->success($result->getData());
}
public function bindCard(RequestInterface $request)
{
$req = new BindCardRequest($request->all());
$result = Api::bindCard($req->getData());
if (!$result->isSuccess()) {
throw new BusinessException($result->getMessage());
}
return $this->success($result->getData());
}
public function bindCardConfirm(RequestInterface $request)
{
$req = new BindCardConfirmRequest($request->all());
$result = Api::bindCardConfirm($req->getData());
if (!$result->isSuccess()) {
throw new BusinessException($result->getMessage());
}
return $this->success($result->getData());
}
public function unBindCard(RequestInterface $request)
{
$req = new UnBindCardRequest($request->all());
$result = Api::unBindCard($req->getData());
if (!$result->isSuccess()) {
throw new BusinessException($result->getMessage());
}
return $this->success($result->getData());
}
public function protocolPayPreRequest(RequestInterface $request)
{
$req = new ProtocolPayPreRequest($request->all());
$result = Api::protocolPayPre($req->getData());
if (!$result->isSuccess()) {
throw new BusinessException($result->getMessage());
}
return $this->success($result->getData());
}
public function protocolPayConfirm(RequestInterface $request)
{
$req = new ProtocolPayConfirmRequest($request->all());
$result = Api::protocolPayConfirm($req->getData());
if (!$result->isSuccess()) {
throw new BusinessException($result->getMessage());
}
return $this->success($result->getData());
2 years ago
}
2 years ago
}