Cashier.php 662 Bytes
<?php

/**
 * Created by PhpStorm.
 * User: ziy
 * Date: 14-7-8
 * Time: 下午6:04
 */
class YOHOPay_Cashier
{

    /**
     * @param $platform
     * @param bool $debug
     * @return YOHOPay_Package_Abstract
     * @throws Exception
     */
    static function factory($platform = 'Alipay', $debug = false)
    {
        if (empty($platform)) {
            throw new Exception('支付平台不能为空.');
        }
        $className = "YOHOPay_Package_" . ucfirst($platform) . "_Service";
        if (!class_exists($className)) {
            throw new Exception('没有 ' . $platform . ' 支付方式');
        }
        return new $className ();
    }
}