fix(billing): stop back-office edits from changing Payple renewal charges
This commit is contained in:
parent
957e136789
commit
f456d737c4
8 changed files with 639 additions and 3 deletions
|
|
@ -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')
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue