Store the customized Shopro mall so it can be kept on the remote.
Co-authored-by: Cursor <cursoragent@cursor.com>
这个提交包含在:
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Yansongda\Pay\Packer;
|
||||
|
||||
use Yansongda\Pay\Contract\PackerInterface;
|
||||
|
||||
class JsonPacker implements PackerInterface
|
||||
{
|
||||
public function pack(array $payload): string
|
||||
{
|
||||
return json_encode($payload, JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
|
||||
public function unpack(string $payload): ?array
|
||||
{
|
||||
$data = json_decode($payload, true);
|
||||
|
||||
if (JSON_ERROR_NONE === json_last_error()) {
|
||||
return $data;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Yansongda\Pay\Packer;
|
||||
|
||||
use Yansongda\Pay\Contract\PackerInterface;
|
||||
use Yansongda\Supports\Str;
|
||||
|
||||
class QueryPacker implements PackerInterface
|
||||
{
|
||||
public function pack(array $payload): string
|
||||
{
|
||||
return http_build_query($payload, '', '&');
|
||||
}
|
||||
|
||||
public function unpack(string $payload): ?array
|
||||
{
|
||||
if (empty($payload) || !Str::contains($payload, '=')) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$result = [];
|
||||
|
||||
foreach (explode('&', $payload) as $item) {
|
||||
$pos = strpos($item, '=');
|
||||
|
||||
$result[substr($item, 0, $pos)] = substr($item, $pos + 1);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Yansongda\Pay\Packer;
|
||||
|
||||
use Yansongda\Pay\Contract\PackerInterface;
|
||||
|
||||
class XmlPacker implements PackerInterface
|
||||
{
|
||||
public function pack(array $payload): string
|
||||
{
|
||||
$xml = '<xml>';
|
||||
|
||||
foreach ($payload as $key => $val) {
|
||||
$xml .= is_numeric($val) ? '<'.$key.'>'.$val.'</'.$key.'>' :
|
||||
'<'.$key.'><![CDATA['.$val.']]></'.$key.'>';
|
||||
}
|
||||
|
||||
$xml .= '</xml>';
|
||||
|
||||
return $xml;
|
||||
}
|
||||
|
||||
public function unpack(string $payload): ?array
|
||||
{
|
||||
if (empty($payload)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
if (PHP_VERSION_ID < 80000) {
|
||||
libxml_disable_entity_loader();
|
||||
}
|
||||
|
||||
$data = json_decode(json_encode(
|
||||
simplexml_load_string($payload, 'SimpleXMLElement', LIBXML_NOCDATA),
|
||||
JSON_UNESCAPED_UNICODE
|
||||
), true);
|
||||
|
||||
if (JSON_ERROR_NONE === json_last_error()) {
|
||||
return $data;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
在新工单中引用
屏蔽一个用户