fix(billing): stop back-office edits from changing Payple renewal charges

This commit is contained in:
Yun Chan 2026-09-28 02:16:21 +09:00
parent 957e136789
commit f456d737c4
8 changed files with 639 additions and 3 deletions

View file

@ -0,0 +1,18 @@
import { PROVIDER_MANAGED_SUBSCRIPTION, subscriptionRpcError } from './rpc-error.ts'
function assert(condition: boolean, message: string): asserts condition {
if (!condition) throw new Error(message)
}
Deno.test('provider-owned subscription edits surface as a specific 409', () => {
const error = subscriptionRpcError({ code: '23514', message: 'provider_managed_subscription' })
assert(error.status === 409, `status 409, got ${error.status}`)
assert(error.code === PROVIDER_MANAGED_SUBSCRIPTION, `code ${error.code}`)
})
Deno.test('other subscription RPC errors keep the shared admin mapping', () => {
const forbidden = subscriptionRpcError({ code: '42501', message: 'admin_role_required' })
assert(forbidden.status === 403 && forbidden.code === 'admin_role_required', 'admin role mapping kept')
const conflict = subscriptionRpcError({ code: '23514', message: 'some_other_check' })
assert(conflict.status === 409 && conflict.code === 'admin_operation_conflict', 'generic conflict kept')
})