diff --git a/.flutter-plugins-dependencies b/.flutter-plugins-dependencies new file mode 100644 index 0000000..0adb765 --- /dev/null +++ b/.flutter-plugins-dependencies @@ -0,0 +1 @@ +{"_info":"// This is a generated file; do not edit or check into version control.","dependencyGraph":[{"name":"cloud_firestore","dependencies":["firebase_core"]},{"name":"cloud_functions","dependencies":["firebase_core"]},{"name":"firebase_auth","dependencies":["firebase_core"]},{"name":"firebase_core","dependencies":[]},{"name":"fluttertoast","dependencies":[]},{"name":"stripe_payment","dependencies":[]}]} \ No newline at end of file diff --git a/ios/Flutter/Flutter.podspec b/ios/Flutter/Flutter.podspec new file mode 100644 index 0000000..5ca3041 --- /dev/null +++ b/ios/Flutter/Flutter.podspec @@ -0,0 +1,18 @@ +# +# NOTE: This podspec is NOT to be published. It is only used as a local source! +# + +Pod::Spec.new do |s| + s.name = 'Flutter' + s.version = '1.0.0' + s.summary = 'High-performance, high-fidelity mobile apps.' + s.description = <<-DESC +Flutter provides an easy and productive way to build and deploy high-performance mobile apps for Android and iOS. + DESC + s.homepage = 'https://flutter.io' + s.license = { :type => 'MIT' } + s.author = { 'Flutter Dev Team' => 'flutter-dev@googlegroups.com' } + s.source = { :git => 'https://github.com/flutter/engine', :tag => s.version.to_s } + s.ios.deployment_target = '8.0' + s.vendored_frameworks = 'Flutter.framework' +end diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 733a609..7c1c1a1 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -9,6 +9,10 @@ PODS: - Firebase/Core - Firebase/Firestore (~> 6.0) - Flutter + - cloud_functions (0.0.1): + - Firebase/Core + - Firebase/Functions (~> 6.0) + - Flutter - Firebase/Auth (6.12.0): - Firebase/CoreOnly - FirebaseAuth (~> 6.3.1) @@ -20,6 +24,9 @@ PODS: - Firebase/Firestore (6.12.0): - Firebase/CoreOnly - FirebaseFirestore (~> 1.7.0) + - Firebase/Functions (6.12.0): + - Firebase/CoreOnly + - FirebaseFunctions (~> 2.5.1) - firebase_auth (0.0.1): - Firebase/Auth (~> 6.0) - Firebase/Core @@ -70,6 +77,10 @@ PODS: - leveldb-library (~> 1.22) - nanopb (~> 0.3.901) - Protobuf (>= 3.9.2, ~> 3.9) + - FirebaseFunctions (2.5.1): + - FirebaseAuthInterop (~> 1.0) + - FirebaseCore (~> 6.0) + - GTMSessionFetcher/Core (~> 1.1) - FirebaseInstanceID (4.2.7): - FirebaseCore (~> 6.0) - GoogleUtilities/Environment (~> 6.0) @@ -129,13 +140,19 @@ PODS: - nanopb/decode (0.3.9011) - nanopb/encode (0.3.9011) - Protobuf (3.10.0) + - Stripe (18.3.0) + - stripe_payment (1.0.0): + - Flutter + - Stripe (>= 18.0.0) DEPENDENCIES: - cloud_firestore (from `.symlinks/plugins/cloud_firestore/ios`) + - cloud_functions (from `.symlinks/plugins/cloud_functions/ios`) - firebase_auth (from `.symlinks/plugins/firebase_auth/ios`) - firebase_core (from `.symlinks/plugins/firebase_core/ios`) - Flutter (from `.symlinks/flutter/ios`) - fluttertoast (from `.symlinks/plugins/fluttertoast/ios`) + - stripe_payment (from `.symlinks/plugins/stripe_payment/ios`) SPEC REPOS: trunk: @@ -148,6 +165,7 @@ SPEC REPOS: - FirebaseCoreDiagnostics - FirebaseCoreDiagnosticsInterop - FirebaseFirestore + - FirebaseFunctions - FirebaseInstanceID - GoogleAppMeasurement - GoogleDataTransport @@ -159,10 +177,13 @@ SPEC REPOS: - leveldb-library - nanopb - Protobuf + - Stripe EXTERNAL SOURCES: cloud_firestore: :path: ".symlinks/plugins/cloud_firestore/ios" + cloud_functions: + :path: ".symlinks/plugins/cloud_functions/ios" firebase_auth: :path: ".symlinks/plugins/firebase_auth/ios" firebase_core: @@ -171,10 +192,13 @@ EXTERNAL SOURCES: :path: ".symlinks/flutter/ios" fluttertoast: :path: ".symlinks/plugins/fluttertoast/ios" + stripe_payment: + :path: ".symlinks/plugins/stripe_payment/ios" SPEC CHECKSUMS: BoringSSL-GRPC: db8764df3204ccea016e1c8dd15d9a9ad63ff318 cloud_firestore: 187530401afa261d255791ea75580591e345fa7b + cloud_functions: c4bd92b7867760f21811061e8a2ef34a1a4e764c Firebase: da031bc7012374e3bed17a6731b89327b29863b9 firebase_auth: 3735c80c0a290fd04a34e9bbbecbeec8f79a216a firebase_core: ebf6a934345d646bf7820a6685427bb3741f01ed @@ -185,6 +209,7 @@ SPEC CHECKSUMS: FirebaseCoreDiagnostics: af29e43048607588c050889d19204f4d7b758c9f FirebaseCoreDiagnosticsInterop: e9b1b023157e3a2fc6418b5cb601e79b9af7b3a0 FirebaseFirestore: 1c7ed32c09d6b0148034e035d0c07783ca45bac3 + FirebaseFunctions: 5af7c35d1c5e41608fecbb667eb6c4e672e318d0 FirebaseInstanceID: ebd2ea79ee38db0cb5f5167b17a0d387e1cc7b6e Flutter: 0e3d915762c693b495b44d77113d4970485de6ec fluttertoast: b644586ef3b16f67fae9a1f8754cef6b2d6b634b @@ -198,6 +223,8 @@ SPEC CHECKSUMS: leveldb-library: 55d93ee664b4007aac644a782d11da33fba316f7 nanopb: 18003b5e52dab79db540fe93fe9579f399bd1ccd Protobuf: a4dc852ad69c027ca2166ed287b856697814375b + Stripe: 35b9a54e698c82163d2ef105187a996d009fd386 + stripe_payment: 1baf1bbf556f7a35c210dc9e2eccf2075947b6be PODFILE CHECKSUM: 097b64e1c00903a097fa4231dd174c10dfb3b629 diff --git a/ios/Runner/Info.plist b/ios/Runner/Info.plist index cb521dc..fc7275d 100644 --- a/ios/Runner/Info.plist +++ b/ios/Runner/Info.plist @@ -27,7 +27,7 @@ CFBundleURLSchemes - com.googleusercontent.apps.646708585532-275gn6d9v1d42rb830ce7jdt3fhtj83l + com.googleusercontent.apps.629329838645-svil8341dqf4vkorh0irskjf0mr5a9a7 diff --git a/lib/home.dart b/lib/home.dart index 2e85f55..bfd24cb 100644 --- a/lib/home.dart +++ b/lib/home.dart @@ -1,5 +1,6 @@ import 'package:firebase_auth/firebase_auth.dart'; import 'package:firebase_tutorials/app.dart'; +import 'package:firebase_tutorials/stripe.dart'; import 'package:flutter/material.dart'; class HomePage extends StatelessWidget { @@ -24,6 +25,17 @@ class HomePage extends StatelessWidget { context, MaterialPageRoute(builder: (context) => App())); }, ), + RaisedButton( + child: Text("Make Payment"), + onPressed: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => StripePaymentMethod( + amount: 900.0, + ))); + }, + ), Center( child: Text(user.phoneNumber), ), diff --git a/lib/stripe.dart b/lib/stripe.dart new file mode 100644 index 0000000..b8e8b9d --- /dev/null +++ b/lib/stripe.dart @@ -0,0 +1,88 @@ +import 'package:cloud_functions/cloud_functions.dart'; +import 'package:flutter/material.dart'; +import 'package:stripe_payment/stripe_payment.dart'; +import 'package:fluttertoast/fluttertoast.dart'; + +class StripePaymentMethod extends StatefulWidget { + final double amount; + + StripePaymentMethod({Key key, @required this.amount}) : super(key: key); + + @override + _StripePaymentMethodState createState() => _StripePaymentMethodState(); +} + +class _StripePaymentMethodState extends State { + @override + initState() { + super.initState(); + + StripePayment.setOptions(StripeOptions( + publishableKey: "pk_test_BPshyoidS9yNHQ95JbPq1ozJ00ovD2VZcR", + merchantId: "Test", + androidPayMode: "test")); + + Future.delayed(Duration.zero, () { + StripePayment.paymentRequestWithCardForm(CardFormPaymentRequest( + requiredBillingAddressFields: "", + )).then((paymentMethod) async { + print(paymentMethod.id); + + final HttpsCallable callable = CloudFunctions.instance.getHttpsCallable( + functionName: 'createStripeCharge', + ); + + try { + final HttpsCallableResult resp = + await callable.call({'fees': 900}); + + print("RESP DATA ${resp.data}"); + StripePayment.confirmPaymentIntent(PaymentIntent( + clientSecret: resp.data['client_secret'], + paymentMethodId: paymentMethod.id, + )).then((data) { + print("Status ${data.status}"); + }).catchError(setError); + } catch (e) { + print(e.message); + + setError(e); + } + }).catchError(setError); + }); + } + + void setError(dynamic error) { + print("SWR $error"); + Fluttertoast.showToast( + msg: "${error.message.toString()}", + toastLength: Toast.LENGTH_LONG, + gravity: ToastGravity.CENTER, + timeInSecForIos: 2, + backgroundColor: Colors.red, + textColor: Colors.white, + fontSize: 16.0); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + leading: IconButton( + icon: Icon( + Icons.arrow_back_ios, + color: Theme.of(context).colorScheme.background, + ), + onPressed: () { + Navigator.of(context).pop(); + }), + backgroundColor: Theme.of(context).primaryColor, + elevation: 0.0, + ), + body: Container( + child: Center( + child: CircularProgressIndicator(), + )), + ); + } +} diff --git a/pubspec.lock b/pubspec.lock index 2428238..4afdfa6 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1,13 +1,27 @@ # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: + archive: + dependency: transitive + description: + name: archive + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.11" + args: + dependency: transitive + description: + name: args + url: "https://pub.dartlang.org" + source: hosted + version: "1.5.2" async: dependency: transitive description: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.3.0" + version: "2.4.0" boolean_selector: dependency: transitive description: @@ -29,6 +43,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.12.10" + cloud_functions: + dependency: "direct main" + description: + name: cloud_functions + url: "https://pub.dartlang.org" + source: hosted + version: "0.4.1+6" collection: dependency: transitive description: @@ -36,6 +57,20 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.14.11" + convert: + dependency: transitive + description: + name: convert + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.1" + crypto: + dependency: transitive + description: + name: crypto + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.3" cupertino_icons: dependency: "direct main" description: @@ -74,20 +109,27 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "3.1.3" + image: + dependency: transitive + description: + name: image + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.4" matcher: dependency: transitive description: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.5" + version: "0.12.6" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.1.7" + version: "1.1.8" path: dependency: transitive description: @@ -102,6 +144,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.8.0+1" + petitparser: + dependency: transitive + description: + name: petitparser + url: "https://pub.dartlang.org" + source: hosted + version: "2.4.0" quiver: dependency: transitive description: @@ -142,6 +191,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.0.5" + stripe_payment: + dependency: "direct main" + description: + name: stripe_payment + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.6" term_glyph: dependency: transitive description: @@ -155,7 +211,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.5" + version: "0.2.11" typed_data: dependency: transitive description: @@ -170,6 +226,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.0.8" + xml: + dependency: transitive + description: + name: xml + url: "https://pub.dartlang.org" + source: hosted + version: "3.5.0" sdks: - dart: ">=2.2.2 <3.0.0" - flutter: ">=1.9.1+hotfix.5 <2.0.0" + dart: ">=2.4.0 <3.0.0" + flutter: ">=1.10.0 <2.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index 05d8fbc..fa1a5c3 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -14,6 +14,8 @@ dependencies: cloud_firestore: ^0.12.10 firebase_auth: ^0.14.0+8 fluttertoast: ^3.1.3 + stripe_payment: ^1.0.6 + cloud_functions: ^0.4.1+6 dev_dependencies: flutter_test: pFad - Phonifier reborn Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved. Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages. Alternative Proxies:Alternative ProxypFad ProxypFad v3 ProxypFad v4 Proxy
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies:
Alternative Proxy
pFad Proxy
pFad v3 Proxy
pFad v4 Proxy