diff --git a/example/lib/screens/checkout/checkout_screen.dart b/example/lib/screens/checkout/checkout_screen.dart deleted file mode 100644 index ed9aa380e..000000000 --- a/example/lib/screens/checkout/checkout_screen.dart +++ /dev/null @@ -1,81 +0,0 @@ -import 'dart:convert'; -import 'dart:developer'; - -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:http/http.dart' as http; -import 'package:stripe_checkout/stripe_checkout.dart'; -import 'package:stripe_example/.env.dart'; -import 'package:stripe_example/widgets/example_scaffold.dart'; - -import '../../config.dart'; -import 'platforms/stripe_checkout.dart' - if (dart.library.js) 'platforms/stripe_checkout_web.dart'; - -class CheckoutScreenExample extends StatefulWidget { - CheckoutScreenExample({ - Key? key, - }) : super(key: key); - - @override - _CheckoutScreenExample createState() => _CheckoutScreenExample(); -} - -class _CheckoutScreenExample extends State { - @override - Widget build(BuildContext context) { - return ExampleScaffold( - title: 'Checkout Page', - padding: EdgeInsets.all(16), - children: [ - SizedBox(height: 120), - Center( - child: ElevatedButton( - onPressed: getCheckout, - child: Text('Open Checkout'), - ), - ) - ], - ); - } - - Future getCheckout() async { - final String sessionId = await _createCheckoutSession(); - final result = await redirectToCheckout( - context: context, - sessionId: sessionId, - publishableKey: stripePublishableKey, - successUrl: 'https://checkout.stripe.dev/success', - canceledUrl: 'https://checkout.stripe.dev/cancel', - ); - - if (mounted) { - final text = result?.when( - success: () => 'Paid succesfully', - canceled: () => 'Checkout canceled', - error: (e) => 'Error $e', - redirected: () => 'Redirected succesfully', - ); - ScaffoldMessenger.of(context).showSnackBar( - SnackBar(content: Text(text ?? '')), - ); - } - } - - Future _createCheckoutSession() async { - final url = Uri.parse('$kApiUrl/create-checkout-session'); - final response = await http.post( - url, - headers: { - 'Content-Type': 'application/json', - }, - body: json.encode({ - if (kIsWeb) 'port': getUrlPort(), - }), - ); - final Map bodyResponse = json.decode(response.body); - final id = bodyResponse['id'] as String; - log('Checkout session id $id'); - return id; - } -} diff --git a/example/lib/screens/checkout/platforms/stripe_checkout.dart b/example/lib/screens/checkout/platforms/stripe_checkout.dart deleted file mode 100644 index fdb841f6c..000000000 --- a/example/lib/screens/checkout/platforms/stripe_checkout.dart +++ /dev/null @@ -1,8 +0,0 @@ -//@dart= 2.12 -String getUrlPort() { - throw 'Not implemented'; -} - -String getReturnUrl() { - return 'Not implemented'; -} diff --git a/example/lib/screens/payment_sheet/payment_element/platforms/payment_element_web.dart b/example/lib/screens/payment_sheet/payment_element/platforms/payment_element_web.dart index 720d93b6d..a57d9060e 100644 --- a/example/lib/screens/payment_sheet/payment_element/platforms/payment_element_web.dart +++ b/example/lib/screens/payment_sheet/payment_element/platforms/payment_element_web.dart @@ -1,7 +1,7 @@ import 'package:flutter/widgets.dart'; import 'package:flutter_stripe_web/flutter_stripe_web.dart'; -import '../../../checkout/platforms/stripe_checkout_web.dart'; +import 'stripe_checkout_web.dart'; Future pay() async { await WebStripe.instance.confirmPaymentElement( diff --git a/example/lib/screens/checkout/platforms/stripe_checkout_web.dart b/example/lib/screens/payment_sheet/payment_element/platforms/stripe_checkout_web.dart similarity index 100% rename from example/lib/screens/checkout/platforms/stripe_checkout_web.dart rename to example/lib/screens/payment_sheet/payment_element/platforms/stripe_checkout_web.dart diff --git a/example/lib/screens/screens.dart b/example/lib/screens/screens.dart index d821c4411..6fdf97ece 100644 --- a/example/lib/screens/screens.dart +++ b/example/lib/screens/screens.dart @@ -1,5 +1,4 @@ import 'package:flutter/material.dart'; -import 'package:stripe_example/screens/checkout/checkout_screen.dart'; import 'package:stripe_example/screens/customer_sheet/customer_sheet_screen.dart'; import 'package:stripe_example/screens/payment_sheet/payment_element/payment_element.dart'; import 'package:stripe_example/screens/payment_sheet/payment_sheet_deffered_screen.dart'; @@ -370,14 +369,5 @@ class Example extends StatelessWidget { ], ), ]), - Example( - title: 'Checkout', - builder: (c) => CheckoutScreenExample(), - platformsSupported: [ - DevicePlatform.android, - DevicePlatform.ios, - DevicePlatform.web - ], - ), ]; } diff --git a/example/pubspec.yaml b/example/pubspec.yaml index c3fd3d081..e1306647f 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -12,7 +12,6 @@ dependencies: sdk: flutter flutter_stripe: ^10.2.0 flutter_stripe_web: ^5.1.0 - stripe_checkout: ^1.0.1 pay: ^1.1.0 http: ^1.1.0 font_awesome_flutter: ^10.6.0 diff --git a/example/pubspec_overrides.yaml b/example/pubspec_overrides.yaml index 2f0eeb35c..8e6f15169 100644 --- a/example/pubspec_overrides.yaml +++ b/example/pubspec_overrides.yaml @@ -1,4 +1,4 @@ -# melos_managed_dependency_overrides: flutter_stripe,stripe_platform_interface,stripe_android,stripe_ios,stripe_checkout,flutter_stripe_web,stripe_js +# melos_managed_dependency_overrides: flutter_stripe,stripe_platform_interface,stripe_android,stripe_ios,flutter_stripe_web,stripe_js dependency_overrides: flutter_stripe: path: ../packages/stripe @@ -8,8 +8,6 @@ dependency_overrides: path: ../packages/stripe_android stripe_ios: path: ../packages/stripe_ios - stripe_checkout: - path: ../packages/stripe_checkout flutter_stripe_web: path: ../packages/stripe_web stripe_js: