finance-pay/app/api/controller/WechatPayServiceMerchantPay...

47 lines
1.4 KiB
PHP
Raw Normal View History

2023-11-15 12:02:33 +08:00
<?php
namespace app\api\controller;
use app\common\enum\user\UserTerminalEnum;
use app\common\logic\PaymentLogic;
use app\common\logic\WechatPayServiceMerchantPaymentLogic;
use app\common\service\pay\WeChatPayMerchantService;
use app\common\service\pay\WeChatPayService;
class WechatPayServiceMerchantPayController extends BaseApiController
{
2023-11-16 14:04:58 +08:00
public array $notNeedLogin = ['appPrePay'];
2023-11-15 12:02:33 +08:00
/**
* 微信服务商APP支付
*/
public function appPrePay()
{
$params = $this->request->param();
//订单信息
$order = WechatPayServiceMerchantPaymentLogic::createPayOrder($params);
if (false === $order) {
return $this->fail('支付订单创建失败', $params);
}
//支付流程
2023-11-16 14:04:58 +08:00
$result = (new WeChatPayMerchantService())->wechatPayServiceMerchantAppPay($order);
2023-11-15 12:02:33 +08:00
if (false === $result) {
2023-11-16 14:04:58 +08:00
return $this->fail((new WeChatPayMerchantService())->getError(), $params);
2023-11-15 12:02:33 +08:00
}
return $this->success('', $result);
}
/**
* @notes app支付回调
* @return \Psr\Http\Message\ResponseInterface
* @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
* @throws \EasyWeChat\Kernel\Exceptions\RuntimeException
* @throws \ReflectionException
* @throws \Throwable
* @date 2023/2/28 14:21
*/
public function notifyApp()
{
return (new WeChatPayMerchantService())->notify();
}
}