Skip to content

Commit

Permalink
feat: add onconfirm handler
Browse files Browse the repository at this point in the history
  • Loading branch information
Remon committed Sep 23, 2024
1 parent 31d4e4a commit c2f20ef
Show file tree
Hide file tree
Showing 46 changed files with 2,868 additions and 1,036 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ class _ThemeCardExampleState extends State<ExpressCheckoutElementExample> {

@override
void initState() {
getClientSecret();
super.initState();
getClientSecret();
}

Future<void> getClientSecret() async {
Expand All @@ -45,14 +45,20 @@ class _ThemeCardExampleState extends State<ExpressCheckoutElementExample> {
appBar: AppBar(
title: Text('Flutter App'),
),
body: Column(
children: [
Container(
child: clientSecret != null
? ExpressCheckoutWidget(clientSecret)
: Center(child: CircularProgressIndicator())),
LoadingButton(onPressed: pay, text: 'Pay'),
],
body: Center(
child: Container(
constraints: BoxConstraints(maxWidth: 600),
padding: EdgeInsets.symmetric(horizontal: 16, vertical: 52),
child: Column(
children: [
SizedBox(
child: clientSecret != null
? ExpressCheckoutWidget(clientSecret)
: Center(child: CircularProgressIndicator())),
LoadingButton(onPressed: pay, text: 'Pay'),
],
),
),
),
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import 'package:flutter/widgets.dart';
import 'package:flutter_stripe_web/flutter_stripe_web.dart';
import 'package:stripe_example/screens/payment_sheet/express_checkout/platforms/express_checkout_element_web.dart';

Future<void> pay() async {
throw UnimplementedError();
await WebStripe.instance.confirmPaymentElement(
ConfirmPaymentElementOptions(
confirmParams: ConfirmPaymentParams(return_url: getReturnUrl()),
),
);
}

class ExpressCheckoutWidget extends StatelessWidget {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ class ExpressCheckoutWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return ExpressCheckoutElement(
onConfirm: (value) {
pay();
},
clientSecret: clientSecret ?? '',
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ class AffirmScreen extends StatelessWidget {
}),
);

print('blaat ${json.decode(response.body)}');
return json.decode(response.body);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
add here your apple dev association file
66 changes: 46 additions & 20 deletions packages/stripe_js/lib/src/api/core/billing_details.freezed.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 22 additions & 10 deletions packages/stripe_js/lib/src/api/core/error.freezed.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit c2f20ef

Please sign in to comment.