diff --git a/WePayV3/Contracts/BasicWePay.php b/WePayV3/Contracts/BasicWePay.php index 3d87c2c..53a3eb9 100644 --- a/WePayV3/Contracts/BasicWePay.php +++ b/WePayV3/Contracts/BasicWePay.php @@ -14,9 +14,11 @@ namespace WePayV3\Contracts; +use WeChat\Contracts\Tools; use WeChat\Exceptions\InvalidArgumentException; use WeChat\Exceptions\InvalidDecryptException; use WeChat\Exceptions\InvalidResponseException; +use WeChat\Exceptions\LocalCacheException; use WePayV3\Cert; /** @@ -100,6 +102,7 @@ abstract class BasicWePay * @param bool $verify 是否验证 * @return array * @throws InvalidResponseException + * @throws LocalCacheException */ public function doRequest($method, $pathinfo, $jsondata = '', $verify = false) { @@ -178,6 +181,7 @@ abstract class BasicWePay * @param string $serial 证书序号 * @return int * @throws InvalidResponseException + * @throws LocalCacheException */ protected function signVerify($data, $sign, $serial = '') { @@ -190,15 +194,15 @@ abstract class BasicWePay * 写入或读取临时文件 * @param string $name * @param null|string $content - * @return false|int|string + * @return string + * @throws LocalCacheException */ protected function tmpFile($name, $content = null) { - $tmpname = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'wxpay-' . md5($name); if (is_null($content)) { - return file_exists($tmpname) ? base64_decode(file_get_contents($tmpname)) : ''; + return Tools::getCache($name) ?: ''; } else { - return file_put_contents($tmpname, base64_encode($content)); + return Tools::setCache($name, $content, 7200); } } diff --git a/WePayV3/Order.php b/WePayV3/Order.php index bba63db..0901d4b 100644 --- a/WePayV3/Order.php +++ b/WePayV3/Order.php @@ -16,6 +16,7 @@ namespace WePayV3; use WeChat\Exceptions\InvalidArgumentException; use WeChat\Exceptions\InvalidResponseException; +use WeChat\Exceptions\LocalCacheException; use WePayV3\Contracts\BasicWePay; /** @@ -36,6 +37,7 @@ class Order extends BasicWePay * @param string $options * @return array * @throws InvalidResponseException + * @throws LocalCacheException */ public function create($type, $options) { @@ -57,6 +59,7 @@ class Order extends BasicWePay * @param string $orderNo * @return array * @throws InvalidResponseException + * @throws LocalCacheException */ public function query($orderNo) { diff --git a/WePayV3/Refund.php b/WePayV3/Refund.php index a48c7c9..82c5dfc 100644 --- a/WePayV3/Refund.php +++ b/WePayV3/Refund.php @@ -14,6 +14,8 @@ namespace WePayV3; +use WeChat\Exceptions\InvalidResponseException; +use WeChat\Exceptions\LocalCacheException; use WePayV3\Contracts\BasicWePay; /** @@ -27,7 +29,8 @@ class Refund extends BasicWePay * 创建支付订单 * @param string $data * @return array - * @throws \WeChat\Exceptions\InvalidResponseException + * @throws InvalidResponseException + * @throws LocalCacheException */ public function create($data) { @@ -38,7 +41,8 @@ class Refund extends BasicWePay * 退款信息查询 * @param string $refundNo * @return array - * @throws \WeChat\Exceptions\InvalidResponseException + * @throws InvalidResponseException + * @throws LocalCacheException */ public function query($refundNo) {