32 lines
740 B
PHP

<?php
namespace app\common\service\pay;
use app\common\enum\PayEnum;
/**
* 支付
* Class PayTool
* @package app\common\service\pay
*/
abstract class PayTool
{
/**
* @param int $type
* @param $params
* @return BalancePay|CashPay|PurchaseFundPay|WeChatPay
*/
public static function getInstance(int $type, $params = [])
{
return match ($type) {
PayEnum::WECHAT_PAY, PayEnum::WECHAT_PAY_BARCODE, PayEnum::WECHAT_PAY_MINI => new WeChatPay($params),
PayEnum::BALANCE_PAY => new BalancePay($params),
PayEnum::PURCHASE_FUNDS => new PurchaseFundPay($params),
default => new CashPay(),
};
}
abstract function refund($amount, $order);
}