mirror of
https://github.com/anomalyco/opencode.git
synced 2026-09-28 13:33:35 +08:00
zen: void invoice of cancelled subscription
This commit is contained in:
@@ -205,6 +205,13 @@ export async function POST(input: APIEvent) {
|
||||
} else if (productID === BlackData.productID()) {
|
||||
await Billing.unsubscribeBlack({ subscriptionID })
|
||||
}
|
||||
|
||||
const latestInvoice = body.data.object.latest_invoice
|
||||
const invoiceID = typeof latestInvoice === "string" ? latestInvoice : latestInvoice?.id
|
||||
if (invoiceID) {
|
||||
const invoice = await Billing.stripe().invoices.retrieve(invoiceID)
|
||||
if (invoice.status === "open") await Billing.stripe().invoices.voidInvoice(invoiceID)
|
||||
}
|
||||
}
|
||||
if (body.type === "invoice.payment_succeeded") {
|
||||
if (
|
||||
|
||||
Reference in New Issue
Block a user