feat : pay
This commit is contained in:
@@ -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,
|
||||
]
|
||||
];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user