chore: prepare production release package

This commit is contained in:
wushumin
2026-06-05 16:12:56 +08:00
parent ed87ea1541
commit 995eae3969
15 changed files with 740 additions and 37 deletions

View File

@@ -274,6 +274,22 @@ function latestPayment(int $orderId): array
return $payment;
}
function mockKeyPair(): array
{
$key = openssl_pkey_new([
'private_key_bits' => 2048,
'private_key_type' => OPENSSL_KEYTYPE_RSA,
]);
assertTrue($key !== false, 'mock rsa key generation failed');
$privateKey = '';
assertTrue(openssl_pkey_export($key, $privateKey), 'mock private key export failed');
$details = openssl_pkey_get_details($key);
assertTrue(is_array($details) && !empty($details['key']), 'mock public key export failed');
return [$privateKey, (string)$details['key']];
}
$configKeys = [
'payment.enabled',
'payment.api_domain',
@@ -294,6 +310,7 @@ $configKeys = [
$snapshot = captureConfigs($configKeys);
$client = new MockShouqianbaClient(new ShouqianbaConfigService());
$service = new ShouqianbaPaymentService(null, $client);
[$mockPrivateKey, $mockPublicKey] = mockKeyPair();
try {
cleanupMockData();
@@ -307,8 +324,8 @@ try {
ensureConfig('payment', 'workstation_sn', '0');
ensureConfig('payment', 'industry_code', '0');
ensureConfig('payment', 'order_expire_minutes', '1440');
ensureConfig('payment', 'merchant_private_key', "-----BEGIN PRIVATE KEY-----\nmock\n-----END PRIVATE KEY-----");
ensureConfig('payment', 'shouqianba_public_key', "-----BEGIN PUBLIC KEY-----\nmock\n-----END PUBLIC KEY-----");
ensureConfig('payment', 'merchant_private_key', $mockPrivateKey);
ensureConfig('payment', 'shouqianba_public_key', $mockPublicKey);
ensureConfig('payment', 'notify_url', 'https://api.example.com/api/open/shouqianba/payment/notify');
ensureConfig('payment', 'mini_program_plugin_version', '2.3.70');
ensureConfig('h5', 'page_base_url', 'https://m.example.com');