summaryrefslogtreecommitdiffhomepage
path: root/cloud/core/src
diff options
context:
space:
mode:
authorFrank <[email protected]>2025-09-16 17:49:37 -0400
committerFrank <[email protected]>2025-09-16 17:49:39 -0400
commit8c71107a93525183ae3d2417d7c056d997f5e204 (patch)
treea845a7c8fee015c5da3cc6973d3c68b2e8ad0dcb /cloud/core/src
parentef10097329a00fbd2b081b0f94c1f4f1e7185b20 (diff)
downloadopencode-8c71107a93525183ae3d2417d7c056d997f5e204.tar.gz
opencode-8c71107a93525183ae3d2417d7c056d997f5e204.zip
wip: zen
Diffstat (limited to 'cloud/core/src')
-rw-r--r--cloud/core/src/billing.ts17
1 files changed, 17 insertions, 0 deletions
diff --git a/cloud/core/src/billing.ts b/cloud/core/src/billing.ts
index cbf064bfe..2254adc79 100644
--- a/cloud/core/src/billing.ts
+++ b/cloud/core/src/billing.ts
@@ -224,4 +224,21 @@ export namespace Billing {
return session.url
},
)
+
+ export const generateReceiptUrl = fn(
+ z.object({
+ paymentID: z.string(),
+ }),
+ async (input) => {
+ const { paymentID } = input
+
+ const intent = await Billing.stripe().paymentIntents.retrieve(paymentID)
+ if (!intent.latest_charge) throw new Error("No charge found")
+
+ const charge = await Billing.stripe().charges.retrieve(intent.latest_charge as string)
+ if (!charge.receipt_url) throw new Error("No receipt URL found")
+
+ return charge.receipt_url
+ },
+ )
}