Line data Source code
1 : /**
2 : * The host's subscribe options as the generated request body, field for field,
3 : * including the two the workspace client drops when they arrive empty: JSON
4 : * keeps `''`, so an empty credential would reach the server as present but
5 : * meaningless.
6 : *
7 : * `SubscribeOptions` carries nothing the generated body lacks. `SubscribeInput`
8 : * also has `checkout_attempt_id` and `idempotency_key`, which no host caller
9 : * sets: the SDK mints the key itself, and the checkout attempt is carried on
10 : * the quote rather than the subscribe.
11 : *
12 : * Shared so the two call sites that issue a subscribe on the rail — the
13 : * workspace billing adapter and the team deep-link checkout — send one body.
14 : */
15 : import type { SubscribeInput } from '@comfyorg/account-core/billing'
16 :
17 : import type { SubscribeOptions } from '@comfyorg/billing-core'
18 :
19 0 : export function subscribeInputFrom(
20 : planSlug: string,
21 : options: SubscribeOptions = {}
22 : ): SubscribeInput {
23 0 : return {
24 : plan_slug: planSlug,
25 : confirmation_token: options.confirmationToken || undefined,
26 : saved_payment_method_id: options.savedPaymentMethodId || undefined,
27 : promotion_code: options.promotionCode,
28 : quote_id: options.quoteId,
29 : quote_version: options.quoteVersion,
30 : return_url: options.returnUrl,
31 : cancel_url: options.cancelUrl,
32 : team_credit_stop_id: options.teamCreditStopId,
33 : billing_cycle: options.billingCycle,
34 : confirm_reactivation: options.confirmReactivation,
35 : proration_at: options.prorationAt
36 : }
37 : }
|