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
20
server/supabase/functions/admin-subscriptions/rpc-error.ts
Normal file
20
server/supabase/functions/admin-subscriptions/rpc-error.ts
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
// server/supabase/functions/admin-subscriptions/rpc-error.ts
|
||||
// admin_mutate_subscription_v1 오류를 공개 오류 코드로 바꾼다. 구독 전용 거절 사유를
|
||||
// 먼저 판별하고, 나머지는 공통 관리자 RPC 매핑(adminRpcError)에 맡긴다.
|
||||
|
||||
import { AdminPublicError, adminRpcError } from '../_shared/admin-contract.ts'
|
||||
|
||||
type AdminRpcErrorLike = Parameters<typeof adminRpcError>[0]
|
||||
|
||||
/**
|
||||
* 결제 사업자(Payple·스토어)가 소유한 구독의 등급·상태·기간을 관리자 화면에서 바꾸려 할 때
|
||||
* SQL이 던지는 사유. 사업자가 청구 조건의 정본이므로 관리자 수정은 충돌(409)로 거절한다.
|
||||
*/
|
||||
export const PROVIDER_MANAGED_SUBSCRIPTION = 'provider_managed_subscription'
|
||||
|
||||
export function subscriptionRpcError(error: AdminRpcErrorLike): AdminPublicError {
|
||||
if ((error.message ?? '').includes(PROVIDER_MANAGED_SUBSCRIPTION)) {
|
||||
return new AdminPublicError(409, PROVIDER_MANAGED_SUBSCRIPTION)
|
||||
}
|
||||
return adminRpcError(error)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue