-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathex00_checkout_basic.dart
More file actions
37 lines (29 loc) · 1.06 KB
/
ex00_checkout_basic.dart
File metadata and controls
37 lines (29 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import 'package:ex00_checkout_basic/ex00_checkout_basic.dart'
as ex00_checkout_basic;
import 'dart:io';
void main(List<String> args) async {
final example = await ex00_checkout_basic.BasicCheckoutExample.create();
stdout.writeln('=== Basic Checkout Example ===');
stdout.writeln('Enter customer email:');
final email = stdin.readLineSync();
if (email == null || email.isEmpty) {
stderr.writeln('Email is required.');
exit(1);
}
stdout.writeln('Enter amount in Naira:');
final amountInput = stdin.readLineSync();
final amountNaira = int.tryParse(amountInput ?? '');
if (amountNaira == null || amountNaira <= 0) {
stderr.writeln('Invalid amount.');
exit(1);
}
final amountKobo = amountNaira * 100;
await example.startCheckout(email: email, amountKobo: amountKobo);
stdout.writeln('\n=== Optional: Verify payment ===');
stdout.writeln('Enter reference to verify (or press Enter to skip):');
final ref = stdin.readLineSync();
if (ref != null && ref.isNotEmpty) {
await example.verify(ref);
}
stdout.writeln('Done.');
}