You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
72 lines
3.0 KiB
PHP
72 lines
3.0 KiB
PHP
<?php
|
|
|
|
$root = dirname(__DIR__);
|
|
$read = static function (string $path) use ($root): string {
|
|
$value = file_get_contents($root . '/' . $path);
|
|
if ($value === false) {
|
|
fwrite(STDERR, 'Could not read ' . $path . PHP_EOL);
|
|
exit(1);
|
|
}
|
|
return $value;
|
|
};
|
|
$assert = static function (bool $condition, string $message): void {
|
|
if (!$condition) {
|
|
fwrite(STDERR, $message . PHP_EOL);
|
|
exit(1);
|
|
}
|
|
};
|
|
|
|
$baseSchema = $read('sql/ss.sql');
|
|
$migration = $read('sql/stripe_payment.sql');
|
|
$cloudSchema = $read('sql/cloud.sql');
|
|
$routes = $read('config/routes.php');
|
|
$invoiceService = $read('app/Services/Cloud/CloudInvoicePaymentService.php');
|
|
$rechargeMethods = $read('app/Services/Payment/RechargeMethodsService.php');
|
|
$rechargeScript = $read('public/theme/venix/js/recharge.js');
|
|
$adminNav = $read('resources/views/venix/admin/static_header.tpl');
|
|
|
|
foreach (['stripe_orders', 'stripe_webhook_events'] as $table) {
|
|
$assert(str_contains($baseSchema, 'CREATE TABLE `' . $table . '` ('),
|
|
'Fresh schema is missing ' . $table . '.');
|
|
$assert(str_contains($migration, 'CREATE TABLE `' . $table . '` ('),
|
|
'Stripe migration is missing ' . $table . '.');
|
|
}
|
|
foreach (['chk_stripe_order_method', 'chk_stripe_order_status',
|
|
'uniq_stripe_checkout_session', 'uniq_stripe_payment_intent',
|
|
'uniq_stripe_event_id'] as $contract) {
|
|
$assert(str_contains($baseSchema, $contract)
|
|
&& str_contains($migration, $contract),
|
|
'Stripe schema contract is missing ' . $contract . '.');
|
|
}
|
|
$assert(str_contains($cloudSchema,
|
|
"'failed','expired','not_created','creation_unknown'")
|
|
&& str_contains($migration, 'chk_cloud_invoice_payment_status'),
|
|
'Cloud invoice payment terminal states were not updated.');
|
|
|
|
foreach ([
|
|
"/stripe/order', 'App\\Controllers\\StripeController:create",
|
|
"/stripe/status', 'App\\Controllers\\StripeController:status",
|
|
"/stripe/webhook', 'App\\Controllers\\StripeController:webhook",
|
|
"/stripe/return', 'App\\Controllers\\StripeController:handleReturn",
|
|
"/stripe/config', 'App\\Controllers\\Admin\\StripeController:save",
|
|
] as $route) {
|
|
$assert(str_contains($routes, $route),
|
|
'Stripe route is missing: ' . $route);
|
|
}
|
|
$assert(str_contains($invoiceService, "'stripe_card'")
|
|
&& str_contains($invoiceService, "'stripe_alipay'")
|
|
&& str_contains($invoiceService, 'new StripePaymentService()'),
|
|
'Cloud invoice Stripe integration is incomplete.');
|
|
$assert(str_contains($rechargeMethods, "'stripe_' . \$method")
|
|
&& str_contains($rechargeScript, 'stripe_card:')
|
|
&& str_contains($rechargeScript,
|
|
'definition.type === "stripe"'),
|
|
'Wallet recharge Stripe integration is incomplete.');
|
|
$assert(str_contains($adminNav, 'href="/admin/stripe"')
|
|
&& str_contains($read('resources/views/venix/admin/stripe/index.tpl'),
|
|
'name="stripe_alipay_enabled"'),
|
|
'Stripe admin configuration entry is missing.');
|
|
|
|
echo 'Stripe schema, route, admin and user payment contracts passed.'
|
|
. PHP_EOL;
|