From e55c2271ae43efbf1b15512630004ddb38b0923c Mon Sep 17 00:00:00 2001 From: rahulr Date: Thu, 14 Dec 2023 01:08:31 +0530 Subject: [PATCH] chore: improvising us bank account code --- .../us_bank_account.dart | 67 ++++++++++--------- 1 file changed, 37 insertions(+), 30 deletions(-) diff --git a/example/lib/screens/regional_payment_methods/us_bank_account.dart b/example/lib/screens/regional_payment_methods/us_bank_account.dart index d9666719b..2059e4452 100644 --- a/example/lib/screens/regional_payment_methods/us_bank_account.dart +++ b/example/lib/screens/regional_payment_methods/us_bank_account.dart @@ -112,11 +112,12 @@ class _UsBankAccountScreenState extends State { void handleNexAction(NextAction? action, String clientSecret) { action?.maybeWhen( - verifyWithMicroDeposits: (_, __, ___) { + verifyWithMicroDeposits: (arrivalDate, redirectUrl, microdepositType) { showDialog( context: context, builder: (context) { return _VerifyMicroDepositsDialog( + microdepositType: microdepositType, clientSecret: clientSecret, ); }); @@ -153,9 +154,11 @@ class _UsBankAccountScreenState extends State { class _VerifyMicroDepositsDialog extends StatefulWidget { const _VerifyMicroDepositsDialog({ required this.clientSecret, + required this.microdepositType, Key? key, }) : super(key: key); final String clientSecret; + final String microdepositType; @override State<_VerifyMicroDepositsDialog> createState() => @@ -190,13 +193,11 @@ class _VerifyMicroDepositsDialogState isPaymentIntent: true, clientSecret: widget.clientSecret, params: VerifyMicroDepositsParams( - descriptorCode: _descriptorController.text.isNotEmpty - ? _descriptorController.text + descriptorCode: widget.microdepositType == "descriptorCode" + ? _descriptorController.text : null, - amounts: _descriptorController.text.isEmpty && - _amount1Controller.text.isNotEmpty && - _amount2Controller.text.isNotEmpty - ? [ + amounts: widget.microdepositType != "descriptorCode" + ? [ int.parse(_amount1Controller.text), int.parse(_amount2Controller.text), ] @@ -221,33 +222,39 @@ class _VerifyMicroDepositsDialogState children: [ Text('Enter the details of the micro deposits verification'), SizedBox(height: 10), - TextField( + Visibility( + visible: widget.microdepositType =="descriptorCode", + child: TextField( controller: _descriptorController, decoration: InputDecoration( border: OutlineInputBorder(), labelText: 'Descriptor', ), - ), - SizedBox(height: 10), - Text('As alternative enter the microdeposits'), - SizedBox(height: 10), - TextField( - keyboardType: TextInputType.number, - controller: _amount1Controller, - decoration: InputDecoration( - border: OutlineInputBorder(), - labelText: 'Microdeposit 1 value', - ), - ), - SizedBox(height: 10), - TextField( - controller: _amount2Controller, - keyboardType: TextInputType.number, - decoration: InputDecoration( - border: OutlineInputBorder(), - labelText: 'Microdeposit 1 value', - ), - ), + ),), + Visibility( + visible: widget.microdepositType !="descriptorCode", + child: Column( + children: [ + SizedBox(height: 10), + TextField( + keyboardType: TextInputType.number, + controller: _amount1Controller, + decoration: InputDecoration( + border: OutlineInputBorder(), + labelText: 'Microdeposit 1 value', + ), + ), + SizedBox(height: 10), + TextField( + controller: _amount2Controller, + keyboardType: TextInputType.number, + decoration: InputDecoration( + border: OutlineInputBorder(), + labelText: 'Microdeposit 2 value', + ), + ), + ], + )), SizedBox(height: 10), LoadingButton( onPressed: () async { @@ -261,4 +268,4 @@ class _VerifyMicroDepositsDialogState ), ); } -} +} \ No newline at end of file