diff --git a/src/factory/object/trade/DeviceInfo.php b/src/factory/object/trade/DeviceInfo.php index 39c70d4..f08b5c8 100644 --- a/src/factory/object/trade/DeviceInfo.php +++ b/src/factory/object/trade/DeviceInfo.php @@ -2,6 +2,8 @@ namespace Tansilu\HfPayLib\factory\object\trade; +use JsonSerializable; +use PHPUnit\Util\Json; use Tansilu\HfPayLib\exception\ParamsException; /** @@ -31,7 +33,7 @@ use Tansilu\HfPayLib\exception\ParamsException; * @property $serviceProviderIp 商户服务IP地址 * @property $merUrl 商户网址 */ -class DeviceInfo +class DeviceInfo implements JsonSerializable { public static function make( string $devType, @@ -62,6 +64,14 @@ class DeviceInfo $this->data[$name] = $value; } + /** + * @throws ParamsException + */ + public function __toString() + { + return $this->toJson(); + } + public function toJSON(): string { @@ -76,4 +86,9 @@ class DeviceInfo } return json_encode($this->data, JSON_UNESCAPED_UNICODE); } + + public function jsonSerialize(): array + { + return $this->data; + } } \ No newline at end of file diff --git a/src/factory/object/trade/DivDetail.php b/src/factory/object/trade/DivDetail.php index 5dfa368..a440b12 100644 --- a/src/factory/object/trade/DivDetail.php +++ b/src/factory/object/trade/DivDetail.php @@ -2,13 +2,15 @@ namespace Tansilu\HfPayLib\factory\object\trade; +use JsonSerializable; + /** * @property $divCustId 分账客户号 * @property $divAcctId 分账账户号 * @property $divAmt 分账金额 * @property $riskDivType 风控分账用途 */ -class DivDetail +class DivDetail implements JsonSerializable { public static function make(string $divCustId, string $divAcctId, string $amount, string $riskDivType): self { @@ -35,9 +37,18 @@ class DivDetail $this->data[$name] = $value; } + public function __toString() + { + return $this->toJSON(); + } public function toJSON(): string { return json_encode($this->data, JSON_UNESCAPED_UNICODE); } + + public function jsonSerialize(): array + { + return $this->data; + } } \ No newline at end of file diff --git a/src/factory/object/trade/ObjectInfo.php b/src/factory/object/trade/ObjectInfo.php index fb2c613..d709455 100644 --- a/src/factory/object/trade/ObjectInfo.php +++ b/src/factory/object/trade/ObjectInfo.php @@ -2,6 +2,8 @@ namespace Tansilu\HfPayLib\factory\object\trade; +use JsonSerializable; + /** * 藏品信息 * @@ -22,7 +24,7 @@ namespace Tansilu\HfPayLib\factory\object\trade; * @property string $regCustId 买家注册用户ID * */ -class ObjectInfo +class ObjectInfo implements JsonSerializable { public static function make(int $marketType): self { @@ -46,9 +48,18 @@ class ObjectInfo $this->data[$name] = $value; } + public function __toString() + { + return $this->toJSON(); + } public function toJSON(): string { return json_encode($this->data, JSON_UNESCAPED_UNICODE); } + + public function jsonSerialize(): array + { + return $this->data; + } } \ No newline at end of file