-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.dart
51 lines (43 loc) · 1.07 KB
/
main.dart
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import 'dart:math';
import 'package:youcan_pay/youcan_pay.dart';
void main() async {
final random = Random().nextInt(99999999);
final email = "example$random@gmail.com";
final phone = "+2126$random";
final password = "12345678";
try {
final res = await YouCanPay.instance.account.register(
email: email,
firstName: "John",
lastName: "Doe",
password: password,
phone: phone,
);
print(res.message);
} on YouCanPayException catch (e) {
print(e);
}
late String token;
try {
final res = await YouCanPay.instance.account.login(
emailOrPhone: email,
password: password,
);
token = res.token;
print(res.token);
} on YouCanPayException catch (e) {
print(e.message);
print(e.statusCode);
}
try {
final res = await YouCanPay.instance.currencies.conversionRates(
token: token,
);
print(res.baseCurrency);
print(res.conversionRates["MAD"]);
print(res.conversionRates["USD"]);
} on YouCanPayException catch (e) {
print(e.message);
print(e.statusCode);
}
}