src/ChargeContext.php
public function initCharge($channel, array $config)
    {
        // 初始化时，可能抛出异常，再次统一再抛出给客户端进行处理
        try {
            switch ($channel) {
                case Config::ALI_CHANNEL_WAP:
                    $this->channel = new AliWapCharge($config);
                    break;
                case Config::ALI_CHANNEL_APP:
                    $this->channel = new AliAppCharge($config);
                    break;
                case Config::ALI_CHANNEL_WEB:
                    $this->channel = new AliWebCharge($config);
                    break;
                case Config::ALI_CHANNEL_QR:
                    $this->channel = new AliQrCharge($config);
                    break;
                case Config::ALI_CHANNEL_BAR:
                    $this->channel = new AliBarCharge($config);
                    break;

                case Config::WX_CHANNEL_APP:
                    $this->channel = new WxAppCharge($config);
                    break;
                case Config::WX_CHANNEL_LITE:// 小程序支付与公众号支付一样，仅仅是客户端的调用方式不同
                case Config::WX_CHANNEL_PUB:
                    $this->channel = new WxPubCharge($config);
                    break;
                case Config::WX_CHANNEL_WAP:
                    $this->channel = new WxWapCharge($config);
                    break;
                case Config::WX_CHANNEL_QR:
                    $this->channel = new WxQrCharge($config);
                    break;
                case Config::WX_CHANNEL_BAR:
                    $this->channel = new WxBarCharge($config);
                    break;

                case Config::CMB_CHANNEL_WAP:
                case Config::CMB_CHANNEL_APP:
                    $this->channel = new CmbCharge($config);
                    break;
                case Config::CCB_CHANNEL_WEB:
                    $this->channel = new CcbWebCharge($config);
                    break;
                default:
                    throw new PayException('当前仅支持：支付宝  微信 招商一网通 建设银行');
            }
        } catch (PayException $e) {
            throw $e;
        }
    }
public function initCharge($channel, array $config)
    {
        // 初始化时，可能抛出异常，再次统一再抛出给客户端进行处理
        try {
            switch ($channel) {
                case Config::ALI_CHANNEL_WAP:
                    $this->channel = new AliWapCharge($config);
                    break;
                case Config::ALI_CHANNEL_APP:
                    $this->channel = new AliAppCharge($config);
                    break;
                case Config::ALI_CHANNEL_WEB:
                    $this->channel = new AliWebCharge($config);
                    break;
                case Config::ALI_CHANNEL_QR:
                    $this->channel = new AliQrCharge($config);
                    break;
                case Config::ALI_CHANNEL_BAR:
                    $this->channel = new AliBarCharge($config);
                    break;

                case Config::WX_CHANNEL_APP:
                    $this->channel = new WxAppCharge($config);
                    break;
                case Config::WX_CHANNEL_LITE:// 小程序支付与公众号支付一样，仅仅是客户端的调用方式不同
                case Config::WX_CHANNEL_PUB:
                    $this->channel = new WxPubCharge($config);
                    break;
                case Config::WX_CHANNEL_WAP:
                    $this->channel = new WxWapCharge($config);
                    break;
                case Config::WX_CHANNEL_QR:
                    $this->channel = new WxQrCharge($config);
                    break;
                case Config::WX_CHANNEL_BAR:
                    $this->channel = new WxBarCharge($config);
                    break;

                case Config::CMB_CHANNEL_WAP:
                case Config::CMB_CHANNEL_APP:
                    $this->channel = new CmbCharge($config);
                    break;
                case Config::CCB_CHANNEL_WEB:
                    $this->channel = new CcbWebCharge($config);
                    break;
                default:
                    throw new PayException('当前仅支持：支付宝  微信 招商一网通 建设银行');
            }
        } catch (PayException $e) {
            throw $e;
        }
    }
public function initCharge ( $ channel , array $ config ) { // 初始化时，可能抛出异常，再次统一再抛出给客户端进行处理 try { switch ( $ channel ) { case Config :: ALI_CHANNEL_WAP : $ this -> channel = new AliWapCharge ( $ config ) ; break ; case Config :: ALI_CHANNEL_APP : $ this -> channel = new AliAppCharge ( $ config ) ; break ; case Config :: ALI_CHANNEL_WEB : $ this -> channel = new AliWebCharge ( $ config ) ; break ; case Config :: ALI_CHANNEL_QR : $ this -> channel = new AliQrCharge ( $ config ) ; break ; case Config :: ALI_CHANNEL_BAR : $ this -> channel = new AliBarCharge ( $ config ) ; break ; case Config :: WX_CHANNEL_APP : $ this -> channel = new WxAppCharge ( $ config ) ; break ; case Config :: WX_CHANNEL_LITE : // 小程序支付与公众号支付一样，仅仅是客户端的调用方式不同 case Config :: WX_CHANNEL_PUB : $ this -> channel = new WxPubCharge ( $ config ) ; break ; case Config :: WX_CHANNEL_WAP : $ this -> channel = new WxWapCharge ( $ config ) ; break ; case Config :: WX_CHANNEL_QR : $ this -> channel = new WxQrCharge ( $ config ) ; break ; case Config :: WX_CHANNEL_BAR : $ this -> channel = new WxBarCharge ( $ config ) ; break ; case Config :: CMB_CHANNEL_WAP : case Config :: CMB_CHANNEL_APP : $ this -> channel = new CmbCharge ( $ config ) ; break ; case Config :: CCB_CHANNEL_WEB : $ this -> channel = new CcbWebCharge ( $ config ) ; break ; default : throw new PayException ( '当前仅支持：支付宝  微信 招商一网通 建设银行'); } } catch ( PayException $ e ) { throw $ e ; } }
设置对应的支付渠道
@param string $channel 支付渠道
- @see Config
@param array $config 配置文件
@throws PayException
@author helei
设置对应的支付渠道