feat : pay
This commit is contained in:
@@ -12,5 +12,5 @@ namespace App\Service\Common\Pay;
|
||||
|
||||
interface ThirdPayInterface
|
||||
{
|
||||
public function pay(float $money,int $orderId,int $orderType,string $outTradeNo,int $userId);
|
||||
public function pay(float $money,int $orderId,string $outTradeNo,int $userId);
|
||||
}
|
||||
@@ -18,6 +18,11 @@ use function Hyperf\Config\config;
|
||||
|
||||
abstract class WxJsRechargeBaseService implements ThirdPayInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public string $openId;
|
||||
|
||||
/**
|
||||
* 回调地址
|
||||
* @var string
|
||||
@@ -110,7 +115,7 @@ abstract class WxJsRechargeBaseService implements ThirdPayInterface
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
private function setConfig(): void
|
||||
public function setConfig(): void
|
||||
{
|
||||
$this->config = config('ysdPay');
|
||||
}
|
||||
@@ -118,17 +123,16 @@ abstract class WxJsRechargeBaseService implements ThirdPayInterface
|
||||
/**
|
||||
* @param float $money
|
||||
* @param int $orderId
|
||||
* @param int $orderType
|
||||
* @param string $outTradeNo
|
||||
* @param int $userId
|
||||
* @return Collection|Rocket
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function pay(float $money, int $orderId, int $orderType, string $outTradeNo, int $userId): Collection|Rocket
|
||||
public function pay(float $money, int $orderId, string $outTradeNo, int $userId): Collection|Rocket
|
||||
{
|
||||
if (empty($this->config)) throw new ErrException('调起支付失败-微信支付配置项不存在');
|
||||
$userOpenId = '123';
|
||||
|
||||
try {
|
||||
$wxOrder = [
|
||||
'out_trade_no' => $outTradeNo,
|
||||
@@ -138,7 +142,7 @@ abstract class WxJsRechargeBaseService implements ThirdPayInterface
|
||||
'currency' => 'CNY'
|
||||
],
|
||||
'payer' => [
|
||||
'openid' => $userOpenId,
|
||||
'openid' => $this->openId,
|
||||
]
|
||||
];
|
||||
|
||||
|
||||
20
app/Service/Common/Pay/Wx/WxJsRechargeOrderService.php
Normal file
20
app/Service/Common/Pay/Wx/WxJsRechargeOrderService.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Service\Common\Pay\Wx;
|
||||
|
||||
use function Hyperf\Config\config;
|
||||
|
||||
class WxJsRechargeOrderService extends WxJsRechargeBaseService
|
||||
{
|
||||
|
||||
public function callBackHandle()
|
||||
{
|
||||
// TODO: Implement callBackHandle() method.
|
||||
}
|
||||
|
||||
public function setNotify()
|
||||
{
|
||||
//返回的回调地址
|
||||
$this->config['wechat']['default']['notify_url'] = config('system.api_url').'/common/wxPay/order/js/callBack';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user