This commit is contained in:
Hitesh Ale
2023-02-26 11:39:24 -05:00
parent 6c71586d57
commit ea39a87676
8 changed files with 55 additions and 7 deletions

View File

@@ -1,6 +1,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.ruswipeshare">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:label="ruswipeshare"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher">
@@ -25,6 +27,7 @@
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data

View File

@@ -1,6 +1,8 @@
package com.example.ruswipeshare
import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.android.FlutterFragmentActivity
class MainActivity: FlutterActivity() {
class MainActivity: FlutterFragmentActivity() {
}

View File

@@ -12,7 +12,7 @@
running.
This Theme is only used starting with V2 of Flutter's Android embedding. -->
<style name="NormalTheme" parent="@android:style/Theme.Black.NoTitleBar">
<style name="NormalTheme" parent="Theme.MaterialComponents">
<item name="android:windowBackground">?android:colorBackground</item>
</style>
</resources>

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode setting is off -->
<style name="LaunchTheme" parent="@android:style/Theme.Light.NoTitleBar">
<style name="LaunchTheme" parent="Theme.MaterialComponents">
<!-- Show a splash screen on the activity. Automatically removed when
the Flutter engine draws its first frame -->
<item name="android:windowBackground">@drawable/launch_background</item>

View File

@@ -1,5 +1,6 @@
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'package:flutter_stripe/flutter_stripe.dart';
import 'firebase_options.dart';
import 'auth_gate.dart';
@@ -7,8 +8,9 @@ import 'auth_gate.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);
runApp(const MyApp());
Stripe.publishableKey = "pk_test_51MfY7PFVdcWv896FKvDhgKabYeDq4AnoFcWxCAg4hquj6TBAsN0kznXPVyKA7M1pMq5PsieGQwsx6QY5ld5ZQzJ500rVCMPPXp";
runApp(const MyApp());
}
class MyApp extends StatelessWidget {

View File

@@ -4,6 +4,8 @@
// ignore_for_file: implementation_imports
import 'dart:convert';
import 'package:firebase_auth/firebase_auth.dart' show ActionCodeSettings, FirebaseAuth, FirebaseAuthException, User;
import 'package:flutter/cupertino.dart' hide Title;
import 'package:flutter/material.dart';
@@ -11,6 +13,8 @@ import 'package:flutter/material.dart' hide Title;
import 'package:flutter/material.dart';
import 'package:flutter_credit_card/credit_card_brand.dart';
import 'package:flutter_credit_card/flutter_credit_card.dart';
import 'package:flutter_stripe/flutter_stripe.dart';
import 'package:http/http.dart' as http;
import 'package:flutterfire_ui/auth.dart';
import 'package:flutterfire_ui/src/auth/widgets/internal/loading_button.dart';
@@ -257,7 +261,43 @@ class ProfileScreenCustom extends MultiProviderScreen {
style: ButtonStyle(
foregroundColor: MaterialStateProperty.all<Color>(Colors.red),
),
onPressed: () {Navigator.push(context, MaterialPageRoute(builder: (context)=> CreditView())); },
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('Setup Seller'),
),
Align(

View File

@@ -390,7 +390,7 @@ packages:
source: hosted
version: "0.10.2+1"
http:
dependency: transitive
dependency: "direct main"
description:
name: http
sha256: "6aa2946395183537c8b880962d935877325d6a09a2867c3970c05c0fed6ac482"

View File

@@ -43,6 +43,7 @@ dependencies:
geolocator: ^9.0.2
flutter_credit_card: any
flutter_stripe: any
http: any
dev_dependencies:
flutter_test: