-
-
Notifications
You must be signed in to change notification settings - Fork 531
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/flutter-stripe/flutter_stripe…
… into mobile_pay_web # Conflicts: # packages/stripe_js/lib/src/js/payment_requests/payment_request.dart # packages/stripe_web/pubspec.yaml
- Loading branch information
Showing
14 changed files
with
174 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
106 changes: 106 additions & 0 deletions
106
example/lib/screens/others/can_add_to_wallet_screen.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_stripe/flutter_stripe.dart'; | ||
import 'package:stripe_example/utils.dart'; | ||
import 'package:stripe_example/widgets/example_scaffold.dart'; | ||
import 'package:stripe_example/widgets/loading_button.dart'; | ||
import 'package:stripe_example/widgets/response_card.dart'; | ||
|
||
class CanAddToWalletScreen extends StatefulWidget { | ||
@override | ||
_CanAddToWalletScreenState createState() => _CanAddToWalletScreenState(); | ||
} | ||
|
||
class _CanAddToWalletScreenState extends State<CanAddToWalletScreen> { | ||
late TextEditingController _controller; | ||
CanAddCardToWalletResult? canAddCardToWallet; | ||
IsCardInWalletResult? isCardInWallet; | ||
|
||
@override | ||
void initState() { | ||
_controller = TextEditingController(); | ||
super.initState(); | ||
} | ||
|
||
@override | ||
void dispose() { | ||
_controller.dispose(); | ||
super.dispose(); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return ExampleScaffold( | ||
title: 'Can add card to wallet', | ||
tags: ['Provisioning'], | ||
padding: EdgeInsets.all(16), | ||
children: [ | ||
TextField( | ||
controller: _controller, | ||
decoration: InputDecoration( | ||
border: OutlineInputBorder(), | ||
labelText: 'Last4', | ||
), | ||
), | ||
SizedBox(height: 20), | ||
LoadingButton( | ||
onPressed: () async { | ||
final tmp = await _handleCanAddToWallet(_controller.text); | ||
setState(() { | ||
canAddCardToWallet = tmp; | ||
}); | ||
}, | ||
text: 'Can add card to Wallet', | ||
), | ||
SizedBox(height: 20), | ||
LoadingButton( | ||
onPressed: () async { | ||
final tmp = await _isCardInToWallet(_controller.text); | ||
setState(() { | ||
isCardInWallet = tmp; | ||
}); | ||
}, | ||
text: 'Is card in Wallet', | ||
), | ||
SizedBox(height: 20), | ||
if (canAddCardToWallet != null || isCardInWallet != null) | ||
ResponseCard( | ||
response: canAddCardToWallet?.toJson().toPrettyString() ?? | ||
isCardInWallet?.toJson().toPrettyString() ?? | ||
'', | ||
) | ||
], | ||
); | ||
} | ||
|
||
Future<CanAddCardToWalletResult> _handleCanAddToWallet(String last4) async { | ||
try { | ||
final result = await Stripe.instance.canAddCardToWallet( | ||
CanAddCardToWalletParams( | ||
cardLastFour: last4, | ||
), | ||
); | ||
ScaffoldMessenger.of(context).showSnackBar( | ||
SnackBar(content: Text('Can add card to wallet: ${result}')), | ||
); | ||
return result; | ||
} catch (e) { | ||
ScaffoldMessenger.of(context) | ||
.showSnackBar(SnackBar(content: Text('Error: $e'))); | ||
rethrow; | ||
} | ||
} | ||
|
||
Future<IsCardInWalletResult> _isCardInToWallet(String last4) async { | ||
try { | ||
final result = await Stripe.instance.isCardInWallet(last4); | ||
ScaffoldMessenger.of(context).showSnackBar( | ||
SnackBar(content: Text('Can add card to wallet: ${result}')), | ||
); | ||
return result; | ||
} catch (e) { | ||
ScaffoldMessenger.of(context) | ||
.showSnackBar(SnackBar(content: Text('Error: $e'))); | ||
rethrow; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
packages/stripe_js/lib/src/js/payment_requests/payment_request.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters