Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions packages/console/core/src/billing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,21 @@ export namespace Billing {
async (input) => {
const { paymentID } = input

const payment = await Database.use((tx) =>
tx
.select()
.from(PaymentTable)
.where(
and(
eq(PaymentTable.workspaceID, Actor.workspace()),
eq(PaymentTable.paymentID, paymentID),
isNull(PaymentTable.timeDeleted),
),
)
.then((rows) => rows[0]),
)
if (!payment) throw new Error("Payment not found")

const intent = await Billing.stripe().paymentIntents.retrieve(paymentID)
if (!intent.latest_charge) throw new Error("No charge found")

Expand Down
Loading