Skip to content

Commit

Permalink
chore: improvising us bank account code
Browse files Browse the repository at this point in the history
  • Loading branch information
rahulr committed Dec 13, 2023
1 parent ab3c0fd commit e55c227
Showing 1 changed file with 37 additions and 30 deletions.
67 changes: 37 additions & 30 deletions example/lib/screens/regional_payment_methods/us_bank_account.dart
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,12 @@ class _UsBankAccountScreenState extends State<UsBankAccountScreen> {

void handleNexAction(NextAction? action, String clientSecret) {
action?.maybeWhen(
verifyWithMicroDeposits: (_, __, ___) {
verifyWithMicroDeposits: (arrivalDate, redirectUrl, microdepositType) {
showDialog(
context: context,
builder: (context) {
return _VerifyMicroDepositsDialog(
microdepositType: microdepositType,
clientSecret: clientSecret,
);
});
Expand Down Expand Up @@ -153,9 +154,11 @@ class _UsBankAccountScreenState extends State<UsBankAccountScreen> {
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() =>
Expand Down Expand Up @@ -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),
]
Expand All @@ -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 {
Expand All @@ -261,4 +268,4 @@ class _VerifyMicroDepositsDialogState
),
);
}
}
}

0 comments on commit e55c227

Please sign in to comment.