mirror of
https://github.com/anomalyco/opencode.git
synced 2026-08-26 18:12:25 +00:00
zen: void invoice of cancelled subscription
This commit is contained in:
parent
322e2b9dd5
commit
69aaa22793
1 changed files with 7 additions and 0 deletions
|
|
@ -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 (
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue