(Deprecated) B2B Billing (Stripe Abonelik) Akışı
Bu repo’da /company B2B billing akışı kaldırıldı. Bu sayfa tarihsel referans olarak tutulur.
Bu doküman, Achidemy’de eskiden bulunan B2B (company) tarafındaki koltuk bazlı (per-seat) Stripe abonelik akışını açıklar.
Not: Güncel kod tabanında
/companyrotaları,STRIPE_B2B_PRICE_IDve ilgili helper’lar kaldırıldı. B2B billing yerine:
- B2C satışlar: Stripe Checkout (tek seferlik)
- Eğitmen ödemeleri: Stripe Connect / manuel payout
- Academy (storefront): subdomain/custom domain ile tenant + open/closed LMS modu
Güncel mimari için: Academy (Storefront) Tenant Mimarisi
Checkout (Subscription) Oluşturma (tarihsel)
Section titled “Checkout (Subscription) Oluşturma (tarihsel)”Dosya: app/routes/company.billing.tsx (kaldırıldı)
Temel prensip:
- Stripe Checkout session
mode: "subscription" line_items[0].quantity=tenant.seatLimit- Session metadata ile webhook’ta B2B olduğunun güvenli şekilde anlaşılması
Önemli metadata alanları:
metadata.type = "b2b_subscription"metadata.organizationId = <orgId>client_reference_id = org_<orgId>
Gerekli env (kaldırıldı):
STRIPE_SECRET_KEYSTRIPE_B2B_PRICE_ID
Success/Cancel URL’leri (kaldırıldı):
/${lang}/company/billing?success=true/${lang}/company/billing?canceled=true
Webhook: checkout.session.completed → Şirketi Aktifleştir
Section titled “Webhook: checkout.session.completed → Şirketi Aktifleştir”Dosya: app/routes/api.stripe.webhook.ts
Stripe checkout.session.completed event’inde:
session.metadata.type === "b2b_subscription"ise B2B branch’e girerorganizationskaydı güncellenir:stripeCustomerIdstripeSubscriptionIdisActive = true
Bu adım, demo/soft-lock kısıtlarını kaldıran “gizli sinyal” işlevi görür.
Seat (Koltuk) Güncelleme ve Proration
Section titled “Seat (Koltuk) Güncelleme ve Proration”Dosya: app/lib/stripe-b2b.ts
updateStripeSeatCount(secretKey, subscriptionId, newQuantity):
- Aboneliği retrieve eder →
subscription.items.data[0].id(subscription item) stripe.subscriptions.update(subscriptionId, { items: [{ id, quantity: newQuantity }], proration_behavior: "create_prorations" })
Böylece şirket seatLimit arttığında Stripe kalan dönemi prorate eder ve farkı faturaya yansıtır.
Sık Yapılan Hatalar
Section titled “Sık Yapılan Hatalar”- Price ID eksik:
STRIPE_B2B_PRICE_IDolmadan checkout oluşturulamaz. - Metadata unutulursa: webhook B2B olduğunu anlayamaz,
organizationsgüncellenmez. - SeatLimit 0/boş: quantity beklenmeyen faturalara yol açabilir; DB’de default ve UI doğrulaması önemlidir.