mirror of
https://github.com/SoPat712/RUSwipeShare.git
synced 2025-08-21 19:08:46 -04:00
htiesh
This commit is contained in:
@@ -62,19 +62,6 @@ class AuthGate extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
User? user = auth.currentUser;
|
|
||||||
|
|
||||||
if (user != null) {
|
|
||||||
bool isNewUser =
|
|
||||||
user.metadata.creationTime == user.metadata.lastSignInTime;
|
|
||||||
|
|
||||||
if (isNewUser) {
|
|
||||||
final name = user.displayName;
|
|
||||||
final uid = user.uid;
|
|
||||||
|
|
||||||
addUser("TOAA", uid);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return const HomeScreen();
|
return const HomeScreen();
|
||||||
},
|
},
|
||||||
|
43
lib/buy.dart
43
lib/buy.dart
@@ -1,7 +1,11 @@
|
|||||||
|
import 'dart:convert';
|
||||||
import 'dart:ui';
|
import 'dart:ui';
|
||||||
|
import 'package:firebase_auth/firebase_auth.dart';
|
||||||
|
import 'package:http/http.dart' as http;
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_stripe/flutter_stripe.dart';
|
||||||
import 'package:ruswipeshare/main.dart';
|
import 'package:ruswipeshare/main.dart';
|
||||||
|
import 'package:flutter_email_sender/flutter_email_sender.dart';
|
||||||
|
|
||||||
enum CampusState { campuses, list_options, offers }
|
enum CampusState { campuses, list_options, offers }
|
||||||
|
|
||||||
@@ -636,7 +640,42 @@ class _BuyScreenState extends State<BuyScreen> {
|
|||||||
)),
|
)),
|
||||||
// add close button
|
// add close button
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
onPressed: () {},
|
onPressed: () async {
|
||||||
|
try {
|
||||||
|
// 1. create payment intent on the server
|
||||||
|
|
||||||
|
var Ddata = await http.get(Uri.parse('http://172.20.10.2:5000/payment-sheet?price=50'));
|
||||||
|
|
||||||
|
var data = jsonDecode(Ddata.body);
|
||||||
|
print("wtf");
|
||||||
|
|
||||||
|
// 2. initialize the payment sheet
|
||||||
|
await Stripe.instance.initPaymentSheet(
|
||||||
|
paymentSheetParameters: SetupPaymentSheetParameters(
|
||||||
|
// Enable custom flow
|
||||||
|
customFlow: true,
|
||||||
|
// Main params
|
||||||
|
merchantDisplayName: 'RU SwipeTrade',
|
||||||
|
paymentIntentClientSecret: data['paymentIntent'],
|
||||||
|
// Customer keys
|
||||||
|
customerEphemeralKeySecret: data['ephemeralKey'],
|
||||||
|
customerId: data['customer'],
|
||||||
|
// Extra options
|
||||||
|
style: ThemeMode.dark,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
} catch (e) {
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
SnackBar(content: Text('Error: $e')),
|
||||||
|
);
|
||||||
|
rethrow;
|
||||||
|
}
|
||||||
|
|
||||||
|
await Stripe.instance.presentPaymentSheet();
|
||||||
|
|
||||||
|
|
||||||
|
},
|
||||||
child: Text(
|
child: Text(
|
||||||
"Purchase",
|
"Purchase",
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
|
@@ -280,17 +280,24 @@ class ProfileScreenCustom extends MultiProviderScreen {
|
|||||||
String url = data['url'];
|
String url = data['url'];
|
||||||
final uri = Uri.parse(url);
|
final uri = Uri.parse(url);
|
||||||
|
|
||||||
await launchUrl(uri);
|
launch(url);
|
||||||
|
|
||||||
final FirebaseAuth auth = FirebaseAuth.instance;
|
final FirebaseAuth auth = FirebaseAuth.instance;
|
||||||
final User? user = auth.currentUser;
|
final User? user = auth.currentUser;
|
||||||
final uid = user?.uid;
|
final uid = user?.uid;
|
||||||
String acc = "";
|
String acc = "";
|
||||||
for(String element in url.split("/")){
|
for(String element in url.split("/")){
|
||||||
if(element.contains("acc"))
|
if(element.contains("acc")) {
|
||||||
acc = element;
|
acc = element;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
CollectionReference users = FirebaseFirestore.instance.collection('users');
|
CollectionReference users = FirebaseFirestore.instance.collection('users');
|
||||||
users.add(ASell(acc, uid));
|
users.add({
|
||||||
|
'suid': acc,
|
||||||
|
'uid': uid,
|
||||||
|
})
|
||||||
|
.then((value) => print(""))
|
||||||
|
.catchError((error) => print("ERROR ADDING DATA: $error"));;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
try {
|
try {
|
||||||
|
@@ -270,6 +270,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "5.0.2"
|
version: "5.0.2"
|
||||||
|
flutter_email_sender:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: flutter_email_sender
|
||||||
|
sha256: "9e253c69617f43d4cb5de672e93a7a19c12a21fb6a75e66c6ce7626336c4c1bc"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "5.2.0"
|
||||||
flutter_facebook_auth:
|
flutter_facebook_auth:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@@ -51,6 +51,7 @@ dependencies:
|
|||||||
webview_flutter: any
|
webview_flutter: any
|
||||||
url_launcher: ^6.1.7
|
url_launcher: ^6.1.7
|
||||||
flutter_datetime_picker: ^1.5.1
|
flutter_datetime_picker: ^1.5.1
|
||||||
|
flutter_email_sender: ^5.0.2
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
Reference in New Issue
Block a user