2
0

🐛 (payment) Fix payment redirection

This commit is contained in:
Baptiste Arnaud
2024-06-26 10:59:11 +02:00
parent 6db0464fd7
commit 6af47a8cfe
16 changed files with 182 additions and 38 deletions

View File

@@ -1,4 +1,4 @@
import { BotContext, InitialChatReply } from '@/types'
import { BotContext } from '@/types'
import { guessApiHost } from '@/utils/guessApiHost'
import { isNotDefined, isNotEmpty } from '@typebot.io/lib'
import {
@@ -6,7 +6,9 @@ import {
removePaymentInProgressFromStorage,
} from '@/features/blocks/inputs/payment/helpers/paymentInProgressStorage'
import {
ContinueChatResponse,
StartChatInput,
StartChatResponse,
StartFrom,
StartPreviewChatInput,
} from '@typebot.io/schemas'
@@ -65,9 +67,14 @@ export async function startChatQuery({
timeout: false,
}
)
.json<InitialChatReply>()
.json<ContinueChatResponse>()
return { data }
return {
data: {
...data,
...paymentInProgressState,
} satisfies StartChatResponse,
}
} catch (error) {
return { error }
}
@@ -94,7 +101,7 @@ export async function startChatQuery({
timeout: false,
}
)
.json<InitialChatReply>()
.json<StartChatResponse>()
return { data }
} catch (error) {
@@ -138,7 +145,7 @@ export async function startChatQuery({
)
throw new CorsError(corsAllowOrigin)
return { data: await response.json<InitialChatReply>() }
return { data: await response.json<StartChatResponse>() }
} catch (error) {
return { error }
}