|
|
|
|
@ -31,6 +31,9 @@ $invoicePageService = file_get_contents($root . '/app/Services/Cloud/CloudInvoic
|
|
|
|
|
$invoiceDetailPageService = file_get_contents(
|
|
|
|
|
$root . '/app/Services/Cloud/CloudInvoiceDetailPageService.php'
|
|
|
|
|
);
|
|
|
|
|
$invoicePresentation = file_get_contents(
|
|
|
|
|
$root . '/app/Services/Cloud/CloudInvoicePresentation.php'
|
|
|
|
|
);
|
|
|
|
|
$invoiceDetailTemplate = file_get_contents(
|
|
|
|
|
$root . '/resources/views/venix/cloud/pages/invoice-detail.tpl'
|
|
|
|
|
);
|
|
|
|
|
@ -116,7 +119,7 @@ $assert(str_contains($lineItemRuntime, "byId('invoice-line-items-panel')")
|
|
|
|
|
&& str_contains($lineItemRuntime, 'replaceChildren(')
|
|
|
|
|
&& !str_contains($lineItemRuntime, 'innerHTML')
|
|
|
|
|
&& !str_contains($lineItemRuntime, 'snapshot_json')
|
|
|
|
|
&& str_contains($invoiceDetailRuntime, 'renderInvoiceLineItems(invoice);'),
|
|
|
|
|
&& str_contains($invoiceDetailRuntime, 'renderInvoiceLineItems(presentation);'),
|
|
|
|
|
'Invoice-detail refresh must replace safe text-only line items.');
|
|
|
|
|
$assert(str_contains($invoiceDetailTemplate, 'id="invoice-payment-title"')
|
|
|
|
|
&& str_contains($invoiceDetailTemplate, 'id="invoice-payment-description"')
|
|
|
|
|
@ -128,12 +131,11 @@ $assert(str_contains($invoiceDetailTemplate, 'id="invoice-payment-title"')
|
|
|
|
|
&& str_contains($invoiceDetailRuntime,
|
|
|
|
|
'state.activePayment = payload.active_payment')
|
|
|
|
|
&& str_contains($invoiceDetailRuntime,
|
|
|
|
|
'renderActiveInvoicePayment(activePayment, result);'),
|
|
|
|
|
'renderActiveInvoicePayment(activePayment, presentation, result);'),
|
|
|
|
|
'Invoice detail must restore durable payment attempts while retaining payment choices.');
|
|
|
|
|
$assert(str_contains($pageController,
|
|
|
|
|
$assert(str_contains($invoicePresentation,
|
|
|
|
|
"\$invoice['renews_expires_at'] ?? \$invoice['due_at'] ?? null")
|
|
|
|
|
&& str_contains($invoiceDetailRuntime,
|
|
|
|
|
'invoice.renews_expires_at ?? invoice.due_at'),
|
|
|
|
|
&& str_contains($invoiceDetailRuntime, 'payload.presentation'),
|
|
|
|
|
'Renewal invoice details must render their authoritative target expiry.');
|
|
|
|
|
|
|
|
|
|
$listMethod = $section($apiController, 'public function invoices(',
|
|
|
|
|
@ -203,10 +205,11 @@ $assert(!str_contains($invoiceDetailRuntime, '/api/v1/jobs/')
|
|
|
|
|
'/api/v1/invoices/${encodeURIComponent(invoice.id)}/status') === 1
|
|
|
|
|
&& str_contains($invoiceDetailRuntime, "actionButton('刷新账单状态'")
|
|
|
|
|
&& str_contains($invoiceDetailRuntime,
|
|
|
|
|
'const nextInvoice = mergeInvoiceStatus(state.selectedInvoice, update);'),
|
|
|
|
|
'const nextPresentation = mergePresentationPatch(state.presentation, patch);'),
|
|
|
|
|
'Manual creation-progress refresh must use one invoice-scoped lightweight request.');
|
|
|
|
|
$manualProgress = $section($invoiceDetailRuntime,
|
|
|
|
|
'function appendProvisionInvoiceActions(', ' if (data.instanceId) {');
|
|
|
|
|
'function appendProvisionInvoiceActions(',
|
|
|
|
|
'function renderInvoiceFulfillment(');
|
|
|
|
|
$manualProgressCatch = $section($manualProgress,
|
|
|
|
|
'} catch (error) {', ' }');
|
|
|
|
|
$assert(str_contains($manualProgress, 'const readSequence = ++state.readSequence;')
|
|
|
|
|
@ -215,6 +218,7 @@ $assert(str_contains($manualProgress, 'const readSequence = ++state.readSequence
|
|
|
|
|
< strpos($manualProgress, 'try {')
|
|
|
|
|
&& str_contains($manualProgressCatch,
|
|
|
|
|
'if (readSequence < state.appliedReadSequence) return;')
|
|
|
|
|
&& str_contains($manualProgress, 'applyActivePaymentPatch(patch, result);')
|
|
|
|
|
&& !str_contains($manualProgressCatch, 'state.invoiceJobProgress.set('),
|
|
|
|
|
'Manual creation-progress errors must ignore stale reads and remain transient.');
|
|
|
|
|
$assert(substr_count($invoiceDetailPageService, '->sharedLock()') >= 4
|
|
|
|
|
@ -247,34 +251,29 @@ $assert(str_contains($apiMiddleware, 'CloudAccess::actor(!$databaseOnly)')
|
|
|
|
|
'Invoice-only API calls must authenticate without a cloud_sessions lookup.');
|
|
|
|
|
$pollMethod = $section($invoiceDetailRuntime, 'async function pollInvoiceStatus(',
|
|
|
|
|
'function scheduleInvoicePoll(');
|
|
|
|
|
$activePaymentPatch = $section($invoiceDetailRuntime,
|
|
|
|
|
'function applyActivePaymentPatch(', 'async function pollInvoiceStatus(');
|
|
|
|
|
$assert(str_contains($pollMethod,
|
|
|
|
|
'api(`/api/v1/invoices/${encodeURIComponent(state.pollInvoiceId)}/status`')
|
|
|
|
|
&& substr_count($pollMethod, 'api(') === 1
|
|
|
|
|
&& str_contains($pollMethod,
|
|
|
|
|
"Object.prototype.hasOwnProperty.call(result || {}, 'active_payment')")
|
|
|
|
|
&& str_contains($pollMethod,
|
|
|
|
|
'state.activePayment = result.active_payment')
|
|
|
|
|
&& str_contains($pollMethod, 'clearOnlinePaymentState(true);')
|
|
|
|
|
&& str_contains($pollMethod, 'const patch = result?.presentation_patch;')
|
|
|
|
|
&& str_contains($pollMethod, 'applyActivePaymentPatch(patch, result);')
|
|
|
|
|
&& str_contains($activePaymentPatch, 'state.activePayment = source.active_payment')
|
|
|
|
|
&& str_contains($activePaymentPatch, 'clearOnlinePaymentState(true);')
|
|
|
|
|
&& str_contains($pollMethod, 'entersProvisioningAfterPayment(')
|
|
|
|
|
&& str_contains($pollMethod, 'resetProvisioningPollWindow();')
|
|
|
|
|
&& !str_contains($pollMethod, 'refreshInvoiceDetail('),
|
|
|
|
|
'Each invoice poll must issue one lightweight request and preserve the provisioning window.');
|
|
|
|
|
&& str_contains($pollMethod,
|
|
|
|
|
'const refreshed = await refreshInvoiceDetail(nextInvoice.id);')
|
|
|
|
|
&& str_contains($pollMethod, 'if (refreshed !== null)')
|
|
|
|
|
&& str_contains($pollMethod, 'renderInvoiceDetail(nextPresentation);'),
|
|
|
|
|
'Each invoice poll must consume one lightweight presentation patch and fully refresh terminal state.');
|
|
|
|
|
$needsPolling = $section($invoiceDetailRuntime, 'function invoiceNeedsPolling(',
|
|
|
|
|
'function stopInvoicePoll(');
|
|
|
|
|
$provisionFinished = $section($invoiceDetailRuntime, 'function provisionFinished(',
|
|
|
|
|
'function invoiceFact(');
|
|
|
|
|
$assert(str_contains($needsPolling, 'state.onlinePaymentPending')
|
|
|
|
|
$assert(str_contains($needsPolling, 'state.presentation?.polling_required === true')
|
|
|
|
|
&& str_contains($needsPolling, '!onlinePaymentHasExpired()')
|
|
|
|
|
&& str_contains($needsPolling, 'invoiceCanPay(invoice)')
|
|
|
|
|
&& str_contains($needsPolling, "['creating', 'pending', 'review'].includes(")
|
|
|
|
|
&& str_contains($needsPolling, 'return false;')
|
|
|
|
|
&& !str_contains($needsPolling, 'provisionFinished(invoice)')
|
|
|
|
|
&& str_contains($provisionFinished,
|
|
|
|
|
"['succeeded', 'failed', 'expired', 'refunded', 'cancelled'].includes(status)")
|
|
|
|
|
&& !str_contains($provisionFinished, "'active'")
|
|
|
|
|
&& !str_contains($provisionFinished, "'uncertain'")
|
|
|
|
|
&& !str_contains($provisionFinished, "'needs_attention'"),
|
|
|
|
|
'Invoice polling must be bounded to active provider payment while task receipts expose provisioning outcome.');
|
|
|
|
|
&& !str_contains($needsPolling, "['creating', 'pending', 'review'].includes(")
|
|
|
|
|
&& !str_contains($invoiceDetailRuntime, 'function provisionFinished('),
|
|
|
|
|
'Invoice polling must consume the server projection instead of rebuilding task state.');
|
|
|
|
|
$paymentExpiry = $section($invoiceDetailRuntime,
|
|
|
|
|
'function onlinePaymentFallbackExpiresAt(', 'function invoiceNeedsPolling(');
|
|
|
|
|
$onlinePaymentRender = $section($invoiceDetailRuntime,
|
|
|
|
|
@ -289,7 +288,7 @@ $assert(!str_contains($invoiceDetailRuntime, 'function hasPendingInvoicePaymentK
|
|
|
|
|
'state.onlinePaymentPending = Boolean(serverPendingPayment);')
|
|
|
|
|
&& str_contains($invoiceDetailRuntime, 'resumeInvoicePolling();')
|
|
|
|
|
&& str_contains($paymentExpiry, 'STATUS_POLL_MAX_LIFETIME_MS')
|
|
|
|
|
&& str_contains($paymentExpiry, 'invoicePaymentDeadlineTimestamp(invoice)')
|
|
|
|
|
&& str_contains($paymentExpiry, 'serviceTimestamp(')
|
|
|
|
|
&& str_contains($paymentExpiry, 'function onlinePaymentHasExpired(')
|
|
|
|
|
&& str_contains($paymentExpiry, 'function expireOnlinePaymentInstructions(')
|
|
|
|
|
&& str_contains($paymentExpiry, 'clearOnlinePaymentState(true);')
|
|
|
|
|
@ -355,16 +354,21 @@ $balanceRequest = strpos($balancePayment,
|
|
|
|
|
'api(`/api/v1/invoices/${encodeURIComponent(invoice.id)}/pay-balance`');
|
|
|
|
|
$assert(str_contains($balancePayment,
|
|
|
|
|
'state.appliedReadSequence = ++state.readSequence;')
|
|
|
|
|
&& strpos($balancePayment,
|
|
|
|
|
'state.appliedReadSequence = ++state.readSequence;')
|
|
|
|
|
< strpos($balancePayment, 'renderInvoiceDetail(paid,'),
|
|
|
|
|
&& str_contains($balancePayment, 'await refreshInvoiceDetail(invoice.id);'),
|
|
|
|
|
'A successful balance payment must invalidate every older in-flight read.');
|
|
|
|
|
$balanceReset = strpos($balancePayment, 'resetProvisioningPollWindow();');
|
|
|
|
|
$balanceRefreshAfterReset = $balanceReset === false ? false : strpos(
|
|
|
|
|
$balancePayment,
|
|
|
|
|
'await refreshInvoiceDetail(invoice.id);',
|
|
|
|
|
$balanceReset
|
|
|
|
|
);
|
|
|
|
|
$assert(str_contains($balancePayment,
|
|
|
|
|
"const startsProvisioning = invoicePurpose(paid) === 'provision';")
|
|
|
|
|
"String(paid?.purpose || '').toLowerCase() === 'provision'")
|
|
|
|
|
&& str_contains($balancePayment,
|
|
|
|
|
'if (startsProvisioning) resetProvisioningPollWindow();')
|
|
|
|
|
&& strpos($balancePayment, 'resetProvisioningPollWindow();')
|
|
|
|
|
< strpos($balancePayment, 'renderInvoiceDetail(paid,'),
|
|
|
|
|
&& $balanceReset !== false
|
|
|
|
|
&& $balanceRefreshAfterReset !== false
|
|
|
|
|
&& $balanceReset < $balanceRefreshAfterReset,
|
|
|
|
|
'Balance payment must start a fresh provisioning poll window before rendering paid state.');
|
|
|
|
|
$assert(str_contains($balancePayment,
|
|
|
|
|
'if ([403, 409].includes(Number(error.status || 0)))')
|
|
|
|
|
@ -416,17 +420,17 @@ $assert(!str_contains($providerPayment, 'confirm(')
|
|
|
|
|
$assert(str_contains($onlinePaymentRender, 'container.replaceChildren(box);'),
|
|
|
|
|
'Rendered provider instructions must replace stale task-status notices.');
|
|
|
|
|
$paymentChoices = $section($invoiceDetailRuntime,
|
|
|
|
|
'function renderInvoicePaymentMethods(', 'function invoiceProgressText(');
|
|
|
|
|
'function renderInvoicePaymentMethods(',
|
|
|
|
|
'function appendProvisionInvoiceActions(');
|
|
|
|
|
$activePaymentRender = strpos($paymentChoices,
|
|
|
|
|
'renderActiveInvoicePayment(activePayment, result);');
|
|
|
|
|
$choicesStart = strpos($paymentChoices, 'const choices = [];');
|
|
|
|
|
$assert(str_contains($invoiceDetailRuntime, 'balancePaymentAllowed: false')
|
|
|
|
|
&& str_contains($invoiceDetailRuntime,
|
|
|
|
|
'state.balancePaymentAllowed = payload?.balance_payment_allowed === true')
|
|
|
|
|
&& str_contains($paymentChoices, 'if (state.balancePaymentAllowed)')
|
|
|
|
|
'renderActiveInvoicePayment(activePayment, presentation, result);');
|
|
|
|
|
$choicesStart = strpos($paymentChoices,
|
|
|
|
|
'Array.isArray(presentation?.payment_methods)');
|
|
|
|
|
$assert(str_contains($paymentChoices, 'if (!choices.length)')
|
|
|
|
|
&& str_contains($paymentChoices, "id === 'balance' ? 'balance' : 'online'")
|
|
|
|
|
&& str_contains($paymentChoices, 'if (!choices.length)')
|
|
|
|
|
&& str_contains($paymentChoices,
|
|
|
|
|
'state.selectedInvoicePaymentMethod = String(choices[0].id);')
|
|
|
|
|
'choices.find(choice => choice.selected === true) || choices[0]')
|
|
|
|
|
&& $activePaymentRender !== false
|
|
|
|
|
&& $choicesStart !== false
|
|
|
|
|
&& $activePaymentRender < $choicesStart,
|
|
|
|
|
@ -506,11 +510,10 @@ $assert(str_contains($statusService,
|
|
|
|
|
"->where('user_id', \$invoice->user_id)")
|
|
|
|
|
&& str_contains($statusService, '$instanceId = $linkedInstance?->id;'),
|
|
|
|
|
'Polling must validate the linked instance owner before exposing its id.');
|
|
|
|
|
$assert(str_contains($displayMethod, "'recharge' => '余额充值'")
|
|
|
|
|
&& str_contains($displayMethod, "'provision' => '实例开通'")
|
|
|
|
|
&& str_contains($displayMethod, "'renewal' => '实例续费'")
|
|
|
|
|
&& str_contains($displayMethod, "'title' => \$title")
|
|
|
|
|
&& str_contains($displayMethod, "'type_label' => \$title"),
|
|
|
|
|
$assert(str_contains($invoicePresentation, "'recharge' => '余额充值'")
|
|
|
|
|
&& str_contains($invoicePresentation, "'provision' => '实例开通'")
|
|
|
|
|
&& str_contains($invoicePresentation, "'renewal' => '实例续费'")
|
|
|
|
|
&& str_contains($invoicePresentation, "'title' => self::invoiceTitle("),
|
|
|
|
|
'Invoice purpose labels are incomplete.');
|
|
|
|
|
$assert(!str_contains($displayMethod, "'invoice_no' =>"),
|
|
|
|
|
'The internal invoice number is still exposed to users.');
|
|
|
|
|
|