PaymentFactory.php 518 B

12345678910111213141516171819202122
  1. <?php
  2. namespace app\common\service;
  3. class PaymentFactory
  4. {
  5. /**
  6. * 创建支付服务实例
  7. */
  8. public static function create($payMethod, $payConfigId = 0)
  9. {
  10. switch ($payMethod) {
  11. case 'wechat':
  12. return new WechatPaymentService($payMethod, $payConfigId);
  13. case 'alipay':
  14. return new AlipayPaymentService($payMethod, $payConfigId);
  15. default:
  16. throw new \Exception('不支持的支付方式');
  17. }
  18. }
  19. }