PaymentFactory.php
661 Bytes
<?php
/**
* Created by PhpStorm.
* User: lishuai
* Date: 2022/2/15
* Time: 4:25 PM
*/
namespace App\Payment;
class PaymentFactory
{
public function init($pay_type)
{
switch ($pay_type){
case 'alipay':
return new AliPayment();
case 'wechat':
return new WechatPayment();
case 'paypal':
return new PaypalPayment();
case 'google':
return new GooglePayment();
case 'apple':
return new ApplePayment();
default:
return new \Exception('未知的支付方式');
}
}
}