summaryrefslogtreecommitdiffhomepage
path: root/packages/console/core/script
diff options
context:
space:
mode:
Diffstat (limited to 'packages/console/core/script')
-rw-r--r--packages/console/core/script/onboard-zen-black.ts8
1 files changed, 8 insertions, 0 deletions
diff --git a/packages/console/core/script/onboard-zen-black.ts b/packages/console/core/script/onboard-zen-black.ts
index 06e5afe12..6ae4f2a2a 100644
--- a/packages/console/core/script/onboard-zen-black.ts
+++ b/packages/console/core/script/onboard-zen-black.ts
@@ -39,6 +39,9 @@ if (amountInCents !== 20000) {
process.exit(1)
}
+const subscriptionData = await Billing.stripe().subscriptions.retrieve(subscription.id, { expand: ["discounts"] })
+const couponID = subscriptionData.discounts[0]?.coupon?.id
+
// Check if subscription is already tied to another workspace
const existingSubscription = await Database.use((tx) =>
tx
@@ -122,6 +125,7 @@ await Database.transaction(async (tx) => {
.set({
customerID,
subscriptionID,
+ subscriptionCouponID: couponID,
paymentMethodID,
paymentMethodLast4,
paymentMethodType,
@@ -143,6 +147,10 @@ await Database.transaction(async (tx) => {
customerID,
invoiceID,
paymentID,
+ enrichment: {
+ type: "subscription",
+ couponID,
+ },
})
})