Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix stripe redirect #62

Merged
merged 4 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docusaurus/src/css/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
background-color: var(--ifm-navbar-link-hover-color);
}

/* Discord link */
.header-discord-link::before {
content: '';
width: 24px;
Expand Down
24 changes: 22 additions & 2 deletions flutter/lib/screens/payments_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:go_router/go_router.dart';
import 'package:devtodollars/services/auth_notifier.dart';
import 'package:supabase_flutter/supabase_flutter.dart';
import 'package:url_launcher/url_launcher.dart';

class PaymentsScreen extends ConsumerStatefulWidget {
Expand All @@ -16,9 +17,28 @@ class _PaymentsScreenState extends ConsumerState<PaymentsScreen> {
@override
void initState() {
WidgetsBinding.instance.addPostFrameCallback((_) async {
Uri? url;
final authNotif = ref.read(authProvider.notifier);
final url = await authNotif.getUserStripeLink(price: widget.price);
if (url != null && mounted) launchUrl(url, webOnlyWindowName: "_self");
try {
url = await authNotif.getUserStripeLink(price: widget.price);
} on FunctionException catch (e) {
if (!mounted) return;
var msg =
e.details?["message"] ?? "Error retrieving stripe redirect url";
showDialog(
context: context,
builder: (_) => AlertDialog(
title: const Text("Failed to open Stripe"),
content: Text(msg),
actions: [
TextButton(onPressed: context.pop, child: const Text("Ok"))
],
),
);
}
if (url != null) {
launchUrl(url, webOnlyWindowName: "_self");
}
});
super.initState();
}
Expand Down
Loading