Line data Source code
1 : import type { BillingOpStatusResponse } from '@comfyorg/ingest-types'
2 :
3 : export type PlanCheckoutBanner =
4 : | { kind: 'verifyPayment'; opId: string; actionUrl: string | null }
5 : | { kind: 'paymentReceived'; opId: string }
6 :
7 : /** The Billing-tab plan banner for a served `checkout_state`. */
8 0 : export function planCheckoutBannerFor(
9 : operation: BillingOpStatusResponse
10 : ): PlanCheckoutBanner | null {
11 0 : switch (operation.checkout_state) {
12 : case 'verify_payment':
13 0 : return {
14 : kind: 'verifyPayment',
15 : opId: operation.id,
16 : actionUrl: operation.action_url ?? null
17 : }
18 : case 'payment_received':
19 0 : return { kind: 'paymentReceived', opId: operation.id }
20 : default:
21 0 : return null
22 : }
23 : }
|