array( 'sandbox' => array( 'host' => 'esqa.moneris.com', 'path' => '/gateway2/servlet/MpgRequest', 'protocol' => YOONE_MONERIS_DEFAULT_PROTOCOL, 'port' => YOONE_MONERIS_DEFAULT_PORT, ), 'production' => array( 'host' => 'www3.moneris.com', 'path' => '/gateway2/servlet/MpgRequest', 'protocol' => YOONE_MONERIS_DEFAULT_PROTOCOL, 'port' => YOONE_MONERIS_DEFAULT_PORT, ), ), 'US' => array( 'sandbox' => array( 'host' => 'esplusqa.moneris.com', 'path' => '/gateway_us/servlet/MpgRequest', 'protocol' => YOONE_MONERIS_DEFAULT_PROTOCOL, 'port' => YOONE_MONERIS_DEFAULT_PORT, ), 'production' => array( // 注意:US 生产主机需根据商户环境确认,建议在设置中显式覆盖;此处仅提供路径与端口默认值。 'host' => '', 'path' => '/gateway_us/servlet/MpgRequest', 'protocol' => YOONE_MONERIS_DEFAULT_PROTOCOL, 'port' => YOONE_MONERIS_DEFAULT_PORT, ), ), ); /** * 判断是否启用沙箱(环境值统一为 'yes'/'no')。 * * @param string $sandboxOption 'yes' 或 'no' * @return bool */ function yoone_moneris_is_sandbox($sandboxOption) { return strtolower((string) $sandboxOption) === 'yes'; } /** * 获取端点默认配置(主机/路径/端口/协议)。 * * @param string $countryCode 'CA' 或 'US' * @param bool $isSandbox 是否沙箱 * @return array{host:string,path:string,protocol:string,port:int} */ function yoone_moneris_endpoint_defaults($countryCode, $isSandbox) { $cc = strtoupper((string) $countryCode); $env = $isSandbox ? 'sandbox' : 'production'; $map = $GLOBALS['YOONE_MONERIS_ENDPOINTS']; if (isset($map[$cc][$env])) { return $map[$cc][$env]; } // 回退 CA 生产 return $map['CA']['production']; }