From 049de7d325ac0af231e416df4270b9dba4c98d63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E6=99=AF=E7=AB=8B?= Date: Tue, 23 Mar 2021 18:16:40 +0800 Subject: [PATCH] Update BasicWePay.php --- WePayV3/Contracts/BasicWePay.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/WePayV3/Contracts/BasicWePay.php b/WePayV3/Contracts/BasicWePay.php index 4f40e14..0394a86 100644 --- a/WePayV3/Contracts/BasicWePay.php +++ b/WePayV3/Contracts/BasicWePay.php @@ -71,6 +71,22 @@ abstract class BasicWePay throw new InvalidArgumentException("Missing Config -- [cert_public]"); } + if (stripos($options['cert_public'], '-----BEGIN CERTIFICATE-----') === false) { + if (file_exists($options['cert_public'])) { + $options['cert_public'] = file_get_contents($options['cert_public']); + } else { + throw new InvalidArgumentException("File Non-Existent -- [cert_public]"); + } + } + + if (stripos($options['cert_private'], '-----BEGIN PRIVATE KEY-----') === false) { + if (file_exists($options['cert_private'])) { + $options['cert_private'] = file_get_contents($options['cert_private']); + } else { + throw new InvalidArgumentException("File Non-Existent -- [cert_private]"); + } + } + $this->config['appid'] = isset($options['appid']) ? $options['appid'] : ''; $this->config['mch_id'] = $options['mch_id']; $this->config['mch_v3_key'] = $options['mch_v3_key']; @@ -88,7 +104,7 @@ abstract class BasicWePay * @param array $config * @return static */ - public static function instance(array $config) + public static function instance($config) { $key = md5(get_called_class() . serialize($config)); if (isset(self::$cache[$key])) return self::$cache[$key];