Skip to content

Commit 01e1010

Browse files
m13vclaude
andcommitted
Add Stripe checkout redirect flow and subscription URL handler
- Backend: Add /api/stripe/redirect endpoint that trampolines from https:// to fazm:// custom URL scheme (required by Stripe Checkout) - Backend: Add payment_method_types[0]=card to checkout params - Backend: Skip webhook signature check when secret is "placeholder" - App: Handle fazm://subscription/success URL to refresh status and dismiss paywall after successful payment - App: Remove hardcoded success/cancel URLs from SubscriptionService (backend now constructs them using its own redirect endpoint) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 4d8229c commit 01e1010

2 files changed

Lines changed: 17 additions & 4 deletions

File tree

Desktop/Sources/FazmApp.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -973,6 +973,20 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate {
973973
for window in NSApp.windows where window.title.hasPrefix("Fazm") {
974974
window.makeKeyAndOrderFront(nil)
975975
}
976+
case "subscription":
977+
// Handle subscription success/cancel redirects from Stripe Checkout
978+
let path = url.path
979+
log("FazmApp: Subscription URL callback: \(path)")
980+
NSApp.activate(ignoringOtherApps: true)
981+
if path == "/success" {
982+
// Refresh subscription status and dismiss paywall
983+
Task {
984+
await SubscriptionService.shared.refreshStatus()
985+
await MainActor.run {
986+
PaywallWindowController.shared.close()
987+
}
988+
}
989+
}
976990
default:
977991
log("FazmApp AppDelegate: Unhandled URL path: \(url.host ?? "nil")")
978992
}

Desktop/Sources/Providers/SubscriptionService.swift

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,9 @@ final class SubscriptionService {
9595
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
9696
request.timeoutInterval = 15
9797

98-
let body: [String: String] = [
99-
"success_url": "fazm://subscription/success",
100-
"cancel_url": "fazm://subscription/cancel",
101-
]
98+
// The backend constructs the actual success/cancel URLs using its own
99+
// redirect endpoint, so we don't need to send them from the client.
100+
let body: [String: String] = [:]
102101
request.httpBody = try JSONSerialization.data(withJSONObject: body)
103102

104103
let (data, response) = try await URLSession.shared.data(for: request)

0 commit comments

Comments
 (0)