mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-12-01 12:04:21 +01:00
Flutter upgrade
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:cw_core/monero_amount_format.dart';
|
||||
import 'package:cw_core/monero_transaction_priority.dart';
|
||||
import 'package:cw_core/output_info.dart';
|
||||
@@ -14,7 +13,6 @@ import 'package:cake_wallet/bitcoin/bitcoin.dart';
|
||||
import 'package:cake_wallet/monero/monero.dart';
|
||||
import 'package:cake_wallet/anypay/any_pay_payment_committed_info.dart';
|
||||
import 'package:cake_wallet/ionia/ionia_any_pay_payment_info.dart';
|
||||
import 'package:cake_wallet/ionia/ionia_order.dart';
|
||||
|
||||
class IoniaAnyPay {
|
||||
IoniaAnyPay(this.ioniaService, this.anyPayApi, this.wallet);
|
||||
@@ -24,8 +22,8 @@ class IoniaAnyPay {
|
||||
final WalletBase wallet;
|
||||
|
||||
Future<IoniaAnyPayPaymentInfo> purchase({
|
||||
@required String merchId,
|
||||
@required double amount}) async {
|
||||
required String merchId,
|
||||
required double amount}) async {
|
||||
final invoice = await ioniaService.purchaseGiftCard(
|
||||
merchId: merchId,
|
||||
amount: amount,
|
||||
@@ -40,7 +38,7 @@ class IoniaAnyPay {
|
||||
.map((AnyPayPaymentInstruction instruction) {
|
||||
switch(payment.chain.toUpperCase()) {
|
||||
case AnyPayChain.xmr:
|
||||
return monero.createMoneroTransactionCreationCredentialsRaw(
|
||||
return monero!.createMoneroTransactionCreationCredentialsRaw(
|
||||
outputs: instruction.outputs.map((out) =>
|
||||
OutputInfo(
|
||||
isParsedAddress: false,
|
||||
@@ -50,7 +48,7 @@ class IoniaAnyPay {
|
||||
sendAll: false)).toList(),
|
||||
priority: MoneroTransactionPriority.medium); // FIXME: HARDCODED PRIORITY
|
||||
case AnyPayChain.btc:
|
||||
return bitcoin.createBitcoinTransactionCredentialsRaw(
|
||||
return bitcoin!.createBitcoinTransactionCredentialsRaw(
|
||||
instruction.outputs.map((out) =>
|
||||
OutputInfo(
|
||||
isParsedAddress: false,
|
||||
@@ -59,7 +57,7 @@ class IoniaAnyPay {
|
||||
sendAll: false)).toList(),
|
||||
feeRate: instruction.requiredFeeRate);
|
||||
case AnyPayChain.ltc:
|
||||
return bitcoin.createBitcoinTransactionCredentialsRaw(
|
||||
return bitcoin!.createBitcoinTransactionCredentialsRaw(
|
||||
instruction.outputs.map((out) =>
|
||||
OutputInfo(
|
||||
isParsedAddress: false,
|
||||
@@ -76,8 +74,8 @@ class IoniaAnyPay {
|
||||
.map((PendingTransaction pendingTransaction) {
|
||||
switch (payment.chain.toUpperCase()){
|
||||
case AnyPayChain.xmr:
|
||||
final ptx = monero.pendingTransactionInfo(pendingTransaction);
|
||||
return AnyPayTransaction(ptx['hex'], id: ptx['id'], key: ptx['key']);
|
||||
final ptx = monero!.pendingTransactionInfo(pendingTransaction);
|
||||
return AnyPayTransaction(ptx['hex'] ?? '', id: ptx['id'] ?? '', key: ptx['key']);
|
||||
default:
|
||||
return AnyPayTransaction(pendingTransaction.hex, id: pendingTransaction.id, key: null);
|
||||
}
|
||||
|
||||
+88
-91
@@ -1,7 +1,6 @@
|
||||
import 'dart:convert';
|
||||
import 'package:cake_wallet/ionia/ionia_merchant.dart';
|
||||
import 'package:cake_wallet/ionia/ionia_order.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:http/http.dart';
|
||||
import 'package:cake_wallet/ionia/ionia_user_credentials.dart';
|
||||
import 'package:cake_wallet/ionia/ionia_virtual_card.dart';
|
||||
@@ -27,15 +26,14 @@ class IoniaApi {
|
||||
|
||||
// Create user
|
||||
|
||||
Future<String> createUser(String email, {@required String clientId}) async {
|
||||
Future<String> createUser(String email, {required String clientId}) async {
|
||||
final headers = <String, String>{'clientId': clientId};
|
||||
final query = <String, String>{'emailAddress': email};
|
||||
final uri = createUserUri.replace(queryParameters: query);
|
||||
final response = await put(uri, headers: headers);
|
||||
|
||||
if (response.statusCode != 200) {
|
||||
// throw exception
|
||||
return null;
|
||||
throw Exception('Unexpected http status: ${response.statusCode}');
|
||||
}
|
||||
|
||||
final bodyJson = json.decode(response.body) as Map<String, Object>;
|
||||
@@ -52,10 +50,10 @@ class IoniaApi {
|
||||
// Verify email
|
||||
|
||||
Future<IoniaUserCredentials> verifyEmail({
|
||||
@required String username,
|
||||
@required String email,
|
||||
@required String code,
|
||||
@required String clientId}) async {
|
||||
required String username,
|
||||
required String email,
|
||||
required String code,
|
||||
required String clientId}) async {
|
||||
final headers = <String, String>{
|
||||
'clientId': clientId,
|
||||
'username': username,
|
||||
@@ -65,8 +63,7 @@ class IoniaApi {
|
||||
final response = await put(uri, headers: headers);
|
||||
|
||||
if (response.statusCode != 200) {
|
||||
// throw exception
|
||||
return null;
|
||||
throw Exception('Unexpected http status: ${response.statusCode}');
|
||||
}
|
||||
|
||||
final bodyJson = json.decode(response.body) as Map<String, Object>;
|
||||
@@ -84,15 +81,14 @@ class IoniaApi {
|
||||
|
||||
// Sign In
|
||||
|
||||
Future<String> signIn(String email, {@required String clientId}) async {
|
||||
Future<String> signIn(String email, {required String clientId}) async {
|
||||
final headers = <String, String>{'clientId': clientId};
|
||||
final query = <String, String>{'emailAddress': email};
|
||||
final uri = signInUri.replace(queryParameters: query);
|
||||
final response = await put(uri, headers: headers);
|
||||
|
||||
if (response.statusCode != 200) {
|
||||
// throw exception
|
||||
return null;
|
||||
throw Exception('Unexpected http status: ${response.statusCode}');
|
||||
}
|
||||
|
||||
final bodyJson = json.decode(response.body) as Map<String, Object>;
|
||||
@@ -109,9 +105,9 @@ class IoniaApi {
|
||||
// Get virtual card
|
||||
|
||||
Future<IoniaVirtualCard> getCards({
|
||||
@required String username,
|
||||
@required String password,
|
||||
@required String clientId}) async {
|
||||
required String username,
|
||||
required String password,
|
||||
required String clientId}) async {
|
||||
final headers = <String, String>{
|
||||
'clientId': clientId,
|
||||
'username': username,
|
||||
@@ -119,8 +115,7 @@ class IoniaApi {
|
||||
final response = await post(getCardsUri, headers: headers);
|
||||
|
||||
if (response.statusCode != 200) {
|
||||
// throw exception
|
||||
return null;
|
||||
throw Exception('Unexpected http status: ${response.statusCode}');
|
||||
}
|
||||
|
||||
final bodyJson = json.decode(response.body) as Map<String, Object>;
|
||||
@@ -138,9 +133,9 @@ class IoniaApi {
|
||||
// Create virtual card
|
||||
|
||||
Future<IoniaVirtualCard> createCard({
|
||||
@required String username,
|
||||
@required String password,
|
||||
@required String clientId}) async {
|
||||
required String username,
|
||||
required String password,
|
||||
required String clientId}) async {
|
||||
final headers = <String, String>{
|
||||
'clientId': clientId,
|
||||
'username': username,
|
||||
@@ -148,13 +143,12 @@ class IoniaApi {
|
||||
final response = await post(createCardUri, headers: headers);
|
||||
|
||||
if (response.statusCode != 200) {
|
||||
// throw exception
|
||||
return null;
|
||||
throw Exception('Unexpected http status: ${response.statusCode}');
|
||||
}
|
||||
|
||||
final bodyJson = json.decode(response.body) as Map<String, Object>;
|
||||
final data = bodyJson['Data'] as Map<String, Object>;
|
||||
final isSuccessful = bodyJson['Successful'] as bool;
|
||||
final isSuccessful = bodyJson['Successful'] as bool? ?? false;
|
||||
|
||||
if (!isSuccessful) {
|
||||
throw Exception(data['message'] as String);
|
||||
@@ -166,9 +160,9 @@ class IoniaApi {
|
||||
// Get Merchants
|
||||
|
||||
Future<List<IoniaMerchant>> getMerchants({
|
||||
@required String username,
|
||||
@required String password,
|
||||
@required String clientId}) async {
|
||||
required String username,
|
||||
required String password,
|
||||
required String clientId}) async {
|
||||
final headers = <String, String>{
|
||||
'clientId': clientId,
|
||||
'username': username,
|
||||
@@ -180,32 +174,33 @@ class IoniaApi {
|
||||
}
|
||||
|
||||
final decodedBody = json.decode(response.body) as Map<String, dynamic>;
|
||||
final isSuccessful = decodedBody['Successful'] as bool ?? false;
|
||||
final isSuccessful = decodedBody['Successful'] as bool? ?? false;
|
||||
|
||||
if (!isSuccessful) {
|
||||
return [];
|
||||
}
|
||||
|
||||
final data = decodedBody['Data'] as List<dynamic>;
|
||||
return data.map((dynamic e) {
|
||||
try {
|
||||
final element = e as Map<String, dynamic>;
|
||||
return IoniaMerchant.fromJsonMap(element);
|
||||
} catch(_) {
|
||||
return null;
|
||||
}
|
||||
}).where((e) => e != null)
|
||||
.toList();
|
||||
final merch = <IoniaMerchant>[];
|
||||
|
||||
for (final item in data) {
|
||||
try {
|
||||
final element = item as Map<String, dynamic>;
|
||||
merch.add(IoniaMerchant.fromJsonMap(element));
|
||||
} catch(_) {}
|
||||
}
|
||||
|
||||
return merch;
|
||||
}
|
||||
|
||||
// Get Merchants By Filter
|
||||
|
||||
Future<List<IoniaMerchant>> getMerchantsByFilter({
|
||||
@required String username,
|
||||
@required String password,
|
||||
@required String clientId,
|
||||
String search,
|
||||
List<IoniaCategory> categories,
|
||||
required String username,
|
||||
required String password,
|
||||
required String clientId,
|
||||
String? search,
|
||||
List<IoniaCategory>? categories,
|
||||
int merchantFilterType = 0}) async {
|
||||
// MerchantFilterType: {All = 0, Nearby = 1, Popular = 2, Online = 3, MyFaves = 4, Search = 5}
|
||||
|
||||
@@ -234,34 +229,35 @@ class IoniaApi {
|
||||
}
|
||||
|
||||
final decodedBody = json.decode(response.body) as Map<String, dynamic>;
|
||||
final isSuccessful = decodedBody['Successful'] as bool ?? false;
|
||||
final isSuccessful = decodedBody['Successful'] as bool? ?? false;
|
||||
|
||||
if (!isSuccessful) {
|
||||
return [];
|
||||
}
|
||||
|
||||
final data = decodedBody['Data'] as List<dynamic>;
|
||||
return data.map((dynamic e) {
|
||||
try {
|
||||
final element = e['Merchant'] as Map<String, dynamic>;
|
||||
return IoniaMerchant.fromJsonMap(element);
|
||||
} catch(_) {
|
||||
return null;
|
||||
}
|
||||
}).where((e) => e != null)
|
||||
.toList();
|
||||
final merch = <IoniaMerchant>[];
|
||||
|
||||
for (final item in data) {
|
||||
try {
|
||||
final element = item['Merchant'] as Map<String, dynamic>;
|
||||
merch.add(IoniaMerchant.fromJsonMap(element));
|
||||
} catch(_) {}
|
||||
}
|
||||
|
||||
return merch;
|
||||
}
|
||||
|
||||
// Purchase Gift Card
|
||||
|
||||
Future<IoniaOrder> purchaseGiftCard({
|
||||
@required String requestedUUID,
|
||||
@required String merchId,
|
||||
@required double amount,
|
||||
@required String currency,
|
||||
@required String username,
|
||||
@required String password,
|
||||
@required String clientId}) async {
|
||||
required String requestedUUID,
|
||||
required String merchId,
|
||||
required double amount,
|
||||
required String currency,
|
||||
required String username,
|
||||
required String password,
|
||||
required String clientId}) async {
|
||||
final headers = <String, String>{
|
||||
'clientId': clientId,
|
||||
'username': username,
|
||||
@@ -279,7 +275,7 @@ class IoniaApi {
|
||||
}
|
||||
|
||||
final decodedBody = json.decode(response.body) as Map<String, dynamic>;
|
||||
final isSuccessful = decodedBody['Successful'] as bool ?? false;
|
||||
final isSuccessful = decodedBody['Successful'] as bool? ?? false;
|
||||
|
||||
if (!isSuccessful) {
|
||||
throw Exception(decodedBody['ErrorMessage'] as String);
|
||||
@@ -292,9 +288,9 @@ class IoniaApi {
|
||||
// Get Current User Gift Card Summaries
|
||||
|
||||
Future<List<IoniaGiftCard>> getCurrentUserGiftCardSummaries({
|
||||
@required String username,
|
||||
@required String password,
|
||||
@required String clientId}) async {
|
||||
required String username,
|
||||
required String password,
|
||||
required String clientId}) async {
|
||||
final headers = <String, String>{
|
||||
'clientId': clientId,
|
||||
'username': username,
|
||||
@@ -306,32 +302,33 @@ class IoniaApi {
|
||||
}
|
||||
|
||||
final decodedBody = json.decode(response.body) as Map<String, dynamic>;
|
||||
final isSuccessful = decodedBody['Successful'] as bool ?? false;
|
||||
final isSuccessful = decodedBody['Successful'] as bool? ?? false;
|
||||
|
||||
if (!isSuccessful) {
|
||||
return [];
|
||||
}
|
||||
|
||||
final data = decodedBody['Data'] as List<dynamic>;
|
||||
return data.map((dynamic e) {
|
||||
try {
|
||||
final element = e as Map<String, dynamic>;
|
||||
return IoniaGiftCard.fromJsonMap(element);
|
||||
} catch(e) {
|
||||
return null;
|
||||
}
|
||||
}).where((e) => e != null)
|
||||
.toList();
|
||||
final cards = <IoniaGiftCard>[];
|
||||
|
||||
for (final item in data) {
|
||||
try {
|
||||
final element = item as Map<String, dynamic>;
|
||||
cards.add(IoniaGiftCard.fromJsonMap(element));
|
||||
} catch(_) {}
|
||||
}
|
||||
|
||||
return cards;
|
||||
}
|
||||
|
||||
// Charge Gift Card
|
||||
|
||||
Future<void> chargeGiftCard({
|
||||
@required String username,
|
||||
@required String password,
|
||||
@required String clientId,
|
||||
@required int giftCardId,
|
||||
@required double amount}) async {
|
||||
required String username,
|
||||
required String password,
|
||||
required String clientId,
|
||||
required int giftCardId,
|
||||
required double amount}) async {
|
||||
final headers = <String, String>{
|
||||
'clientId': clientId,
|
||||
'username': username,
|
||||
@@ -350,11 +347,11 @@ class IoniaApi {
|
||||
}
|
||||
|
||||
final decodedBody = json.decode(response.body) as Map<String, dynamic>;
|
||||
final isSuccessful = decodedBody['Successful'] as bool ?? false;
|
||||
final isSuccessful = decodedBody['Successful'] as bool? ?? false;
|
||||
|
||||
if (!isSuccessful) {
|
||||
final data = decodedBody['Data'] as Map<String, dynamic>;
|
||||
final msg = data['Message'] as String ?? '';
|
||||
final msg = data['Message'] as String? ?? '';
|
||||
|
||||
if (msg.isNotEmpty) {
|
||||
throw Exception(msg);
|
||||
@@ -367,10 +364,10 @@ class IoniaApi {
|
||||
// Get Gift Card
|
||||
|
||||
Future<IoniaGiftCard> getGiftCard({
|
||||
@required String username,
|
||||
@required String password,
|
||||
@required String clientId,
|
||||
@required int id}) async {
|
||||
required String username,
|
||||
required String password,
|
||||
required String clientId,
|
||||
required int id}) async {
|
||||
final headers = <String, String>{
|
||||
'clientId': clientId,
|
||||
'username': username,
|
||||
@@ -387,7 +384,7 @@ class IoniaApi {
|
||||
}
|
||||
|
||||
final decodedBody = json.decode(response.body) as Map<String, dynamic>;
|
||||
final isSuccessful = decodedBody['Successful'] as bool ?? false;
|
||||
final isSuccessful = decodedBody['Successful'] as bool? ?? false;
|
||||
|
||||
if (!isSuccessful) {
|
||||
final msg = decodedBody['ErrorMessage'] as String ?? '';
|
||||
@@ -406,11 +403,11 @@ class IoniaApi {
|
||||
// Payment Status
|
||||
|
||||
Future<int> getPaymentStatus({
|
||||
@required String username,
|
||||
@required String password,
|
||||
@required String clientId,
|
||||
@required String orderId,
|
||||
@required String paymentId}) async {
|
||||
required String username,
|
||||
required String password,
|
||||
required String clientId,
|
||||
required String orderId,
|
||||
required String paymentId}) async {
|
||||
final headers = <String, String>{
|
||||
'clientId': clientId,
|
||||
'username': username,
|
||||
@@ -429,7 +426,7 @@ class IoniaApi {
|
||||
}
|
||||
|
||||
final decodedBody = json.decode(response.body) as Map<String, dynamic>;
|
||||
final isSuccessful = decodedBody['Successful'] as bool ?? false;
|
||||
final isSuccessful = decodedBody['Successful'] as bool? ?? false;
|
||||
|
||||
if (!isSuccessful) {
|
||||
final msg = decodedBody['ErrorMessage'] as String ?? '';
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
class IoniaCategory {
|
||||
const IoniaCategory({this.index, this.title, this.ids, this.iconPath});
|
||||
const IoniaCategory({
|
||||
required this.index,
|
||||
required this.title,
|
||||
required this.ids,
|
||||
required this.iconPath});
|
||||
|
||||
static const allCategories = <IoniaCategory>[all, apparel, onlineOnly, food, entertainment, delivery, travel];
|
||||
static const all = IoniaCategory(index: 0, title: 'All', ids: [], iconPath: 'assets/images/category.png');
|
||||
|
||||
@@ -10,7 +10,7 @@ class IoniaCreateStateSuccess extends IoniaCreateAccountState {}
|
||||
class IoniaCreateStateLoading extends IoniaCreateAccountState {}
|
||||
|
||||
class IoniaCreateStateFailure extends IoniaCreateAccountState {
|
||||
IoniaCreateStateFailure({@required this.error});
|
||||
IoniaCreateStateFailure({required this.error});
|
||||
|
||||
final String error;
|
||||
}
|
||||
@@ -26,7 +26,7 @@ class IoniaOtpSendDisabled extends IoniaOtpState {}
|
||||
class IoniaOtpSendEnabled extends IoniaOtpState {}
|
||||
|
||||
class IoniaOtpFailure extends IoniaOtpState {
|
||||
IoniaOtpFailure({@required this.error});
|
||||
IoniaOtpFailure({required this.error});
|
||||
|
||||
final String error;
|
||||
}
|
||||
@@ -38,7 +38,7 @@ class IoniaCreateCardSuccess extends IoniaCreateCardState {}
|
||||
class IoniaCreateCardLoading extends IoniaCreateCardState {}
|
||||
|
||||
class IoniaCreateCardFailure extends IoniaCreateCardState {
|
||||
IoniaCreateCardFailure({@required this.error});
|
||||
IoniaCreateCardFailure({required this.error});
|
||||
|
||||
final String error;
|
||||
}
|
||||
@@ -52,13 +52,15 @@ class IoniaFetchingCard extends IoniaFetchCardState {}
|
||||
class IoniaFetchCardFailure extends IoniaFetchCardState {}
|
||||
|
||||
class IoniaCardSuccess extends IoniaFetchCardState {
|
||||
IoniaCardSuccess({@required this.card});
|
||||
IoniaCardSuccess({required this.card});
|
||||
|
||||
final IoniaVirtualCard card;
|
||||
}
|
||||
|
||||
abstract class IoniaMerchantState {}
|
||||
|
||||
class InitialIoniaMerchantLoadingState extends IoniaMerchantState {}
|
||||
|
||||
class IoniaLoadingMerchantState extends IoniaMerchantState {}
|
||||
|
||||
class IoniaLoadedMerchantState extends IoniaMerchantState {}
|
||||
|
||||
@@ -4,25 +4,25 @@ import 'package:flutter/foundation.dart';
|
||||
|
||||
class IoniaGiftCard {
|
||||
IoniaGiftCard({
|
||||
@required this.id,
|
||||
@required this.merchantId,
|
||||
@required this.legalName,
|
||||
@required this.systemName,
|
||||
@required this.barcodeUrl,
|
||||
@required this.cardNumber,
|
||||
@required this.cardPin,
|
||||
@required this.instructions,
|
||||
@required this.tip,
|
||||
@required this.purchaseAmount,
|
||||
@required this.actualAmount,
|
||||
@required this.totalTransactionAmount,
|
||||
@required this.totalDashTransactionAmount,
|
||||
@required this.remainingAmount,
|
||||
@required this.createdDateFormatted,
|
||||
@required this.lastTransactionDateFormatted,
|
||||
@required this.isActive,
|
||||
@required this.isEmpty,
|
||||
@required this.logoUrl});
|
||||
required this.id,
|
||||
required this.merchantId,
|
||||
required this.legalName,
|
||||
required this.systemName,
|
||||
required this.barcodeUrl,
|
||||
required this.cardNumber,
|
||||
required this.cardPin,
|
||||
required this.instructions,
|
||||
required this.tip,
|
||||
required this.purchaseAmount,
|
||||
required this.actualAmount,
|
||||
required this.totalTransactionAmount,
|
||||
required this.totalDashTransactionAmount,
|
||||
required this.remainingAmount,
|
||||
required this.createdDateFormatted,
|
||||
required this.lastTransactionDateFormatted,
|
||||
required this.isActive,
|
||||
required this.isEmpty,
|
||||
required this.logoUrl});
|
||||
|
||||
factory IoniaGiftCard.fromJsonMap(Map<String, dynamic> element) {
|
||||
return IoniaGiftCard(
|
||||
|
||||
@@ -6,7 +6,7 @@ class IoniaGiftCardInstruction {
|
||||
|
||||
factory IoniaGiftCardInstruction.fromJsonMap(Map<String, dynamic> element) {
|
||||
return IoniaGiftCardInstruction(
|
||||
toBeginningOfSentenceCase(element['title'] as String ?? ''),
|
||||
toBeginningOfSentenceCase(element['title'] as String? ?? '') ?? '',
|
||||
element['description'] as String);
|
||||
}
|
||||
|
||||
|
||||
+35
-129
@@ -1,63 +1,31 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:cake_wallet/ionia/ionia_gift_card_instruction.dart';
|
||||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
|
||||
class IoniaMerchant {
|
||||
IoniaMerchant({
|
||||
@required this.id,
|
||||
@required this.legalName,
|
||||
@required this.systemName,
|
||||
@required this.description,
|
||||
@required this.website,
|
||||
@required this.termsAndConditions,
|
||||
@required this.logoUrl,
|
||||
@required this.cardImageUrl,
|
||||
@required this.cardholderAgreement,
|
||||
@required this.purchaseFee,
|
||||
@required this.revenueShare,
|
||||
@required this.marketingFee,
|
||||
@required this.minimumDiscount,
|
||||
@required this.level1,
|
||||
@required this.level2,
|
||||
@required this.level3,
|
||||
@required this.level4,
|
||||
@required this.level5,
|
||||
@required this.level6,
|
||||
@required this.level7,
|
||||
@required this.isActive,
|
||||
@required this.isDeleted,
|
||||
@required this.isOnline,
|
||||
@required this.isPhysical,
|
||||
@required this.isVariablePurchase,
|
||||
@required this.minimumCardPurchase,
|
||||
@required this.maximumCardPurchase,
|
||||
@required this.acceptsTips,
|
||||
@required this.createdDateFormatted,
|
||||
@required this.createdBy,
|
||||
@required this.isRegional,
|
||||
@required this.modifiedDateFormatted,
|
||||
@required this.modifiedBy,
|
||||
@required this.usageInstructions,
|
||||
@required this.usageInstructionsBak,
|
||||
@required this.paymentGatewayId,
|
||||
@required this.giftCardGatewayId,
|
||||
@required this.isHtmlDescription,
|
||||
@required this.purchaseInstructions,
|
||||
@required this.balanceInstructions,
|
||||
@required this.amountPerCard,
|
||||
@required this.processingMessage,
|
||||
@required this.hasBarcode,
|
||||
@required this.hasInventory,
|
||||
@required this.isVoidable,
|
||||
@required this.receiptMessage,
|
||||
@required this.cssBorderCode,
|
||||
@required this.instructions,
|
||||
@required this.alderSku,
|
||||
@required this.ngcSku,
|
||||
@required this.acceptedCurrency,
|
||||
@required this.deepLink,
|
||||
@required this.isPayLater,
|
||||
@required this.savingsPercentage});
|
||||
required this.id,
|
||||
required this.legalName,
|
||||
required this.systemName,
|
||||
required this.description,
|
||||
required this.website,
|
||||
required this.termsAndConditions,
|
||||
required this.logoUrl,
|
||||
required this.cardImageUrl,
|
||||
required this.cardholderAgreement,
|
||||
required this.isActive,
|
||||
required this.isOnline,
|
||||
required this.isPhysical,
|
||||
required this.isVariablePurchase,
|
||||
required this.minimumCardPurchase,
|
||||
required this.maximumCardPurchase,
|
||||
required this.acceptsTips,
|
||||
required this.createdDateFormatted,
|
||||
required this.modifiedDateFormatted,
|
||||
required this.usageInstructions,
|
||||
required this.usageInstructionsBak,
|
||||
required this.hasBarcode,
|
||||
required this.instructions,
|
||||
required this.savingsPercentage});
|
||||
|
||||
factory IoniaMerchant.fromJsonMap(Map<String, dynamic> element) {
|
||||
return IoniaMerchant(
|
||||
@@ -70,50 +38,19 @@ class IoniaMerchant {
|
||||
logoUrl: element["LogoUrl"] as String,
|
||||
cardImageUrl: element["CardImageUrl"] as String,
|
||||
cardholderAgreement: element["CardholderAgreement"] as String,
|
||||
purchaseFee: element["PurchaseFee"] as double,
|
||||
revenueShare: element["RevenueShare"] as double,
|
||||
marketingFee: element["MarketingFee"] as double,
|
||||
minimumDiscount: element["MinimumDiscount"] as double,
|
||||
level1: element["Level1"] as double,
|
||||
level2: element["Level2"] as double,
|
||||
level3: element["Level3"] as double,
|
||||
level4: element["Level4"] as double,
|
||||
level5: element["Level5"] as double,
|
||||
level6: element["Level6"] as double,
|
||||
level7: element["Level7"] as double,
|
||||
isActive: element["IsActive"] as bool,
|
||||
isDeleted: element["IsDeleted"] as bool,
|
||||
isActive: element["IsActive"] as bool?,
|
||||
isOnline: element["IsOnline"] as bool,
|
||||
isPhysical: element["IsPhysical"] as bool,
|
||||
isVariablePurchase: element["IsVariablePurchase"] as bool,
|
||||
minimumCardPurchase: element["MinimumCardPurchase"] as double,
|
||||
maximumCardPurchase: element["MaximumCardPurchase"] as double,
|
||||
acceptsTips: element["AcceptsTips"] as bool,
|
||||
createdDateFormatted: element["CreatedDate"] as String,
|
||||
createdBy: element["CreatedBy"] as int,
|
||||
isRegional: element["IsRegional"] as bool,
|
||||
modifiedDateFormatted: element["ModifiedDate"] as String,
|
||||
modifiedBy: element["ModifiedBy"] as int,
|
||||
usageInstructions: element["UsageInstructions"] as String,
|
||||
usageInstructionsBak: element["UsageInstructionsBak"] as String,
|
||||
paymentGatewayId: element["PaymentGatewayId"] as int,
|
||||
giftCardGatewayId: element["GiftCardGatewayId"] as int ,
|
||||
isHtmlDescription: element["IsHtmlDescription"] as bool,
|
||||
purchaseInstructions: element["PurchaseInstructions"] as String,
|
||||
balanceInstructions: element["BalanceInstructions"] as String,
|
||||
amountPerCard: element["AmountPerCard"] as double,
|
||||
processingMessage: element["ProcessingMessage"] as String,
|
||||
createdDateFormatted: element["CreatedDate"] as String?,
|
||||
modifiedDateFormatted: element["ModifiedDate"] as String?,
|
||||
usageInstructions: element["UsageInstructions"] as String?,
|
||||
usageInstructionsBak: element["UsageInstructionsBak"] as String?,
|
||||
hasBarcode: element["HasBarcode"] as bool,
|
||||
hasInventory: element["HasInventory"] as bool,
|
||||
isVoidable: element["IsVoidable"] as bool,
|
||||
receiptMessage: element["ReceiptMessage"] as String,
|
||||
cssBorderCode: element["CssBorderCode"] as String,
|
||||
instructions: IoniaGiftCardInstruction.parseListOfInstructions(element['PaymentInstructions'] as String),
|
||||
alderSku: element["AlderSku"] as String,
|
||||
ngcSku: element["NgcSku"] as String,
|
||||
acceptedCurrency: element["AcceptedCurrency"] as String,
|
||||
deepLink: element["DeepLink"] as String,
|
||||
isPayLater: element["IsPayLater"] as bool,
|
||||
savingsPercentage: element["SavingsPercentage"] as double);
|
||||
}
|
||||
|
||||
@@ -126,50 +63,19 @@ class IoniaMerchant {
|
||||
final String logoUrl;
|
||||
final String cardImageUrl;
|
||||
final String cardholderAgreement;
|
||||
final double purchaseFee;
|
||||
final double revenueShare;
|
||||
final double marketingFee;
|
||||
final double minimumDiscount;
|
||||
final double level1;
|
||||
final double level2;
|
||||
final double level3;
|
||||
final double level4;
|
||||
final double level5;
|
||||
final double level6;
|
||||
final double level7;
|
||||
final bool isActive;
|
||||
final bool isDeleted;
|
||||
final bool? isActive;
|
||||
final bool isOnline;
|
||||
final bool isPhysical;
|
||||
final bool? isPhysical;
|
||||
final bool isVariablePurchase;
|
||||
final double minimumCardPurchase;
|
||||
final double maximumCardPurchase;
|
||||
final bool acceptsTips;
|
||||
final String createdDateFormatted;
|
||||
final int createdBy;
|
||||
final bool isRegional;
|
||||
final String modifiedDateFormatted;
|
||||
final int modifiedBy;
|
||||
final String usageInstructions;
|
||||
final String usageInstructionsBak;
|
||||
final int paymentGatewayId;
|
||||
final int giftCardGatewayId;
|
||||
final bool isHtmlDescription;
|
||||
final String purchaseInstructions;
|
||||
final String balanceInstructions;
|
||||
final double amountPerCard;
|
||||
final String processingMessage;
|
||||
final String? createdDateFormatted;
|
||||
final String? modifiedDateFormatted;
|
||||
final String? usageInstructions;
|
||||
final String? usageInstructionsBak;
|
||||
final bool hasBarcode;
|
||||
final bool hasInventory;
|
||||
final bool isVoidable;
|
||||
final String receiptMessage;
|
||||
final String cssBorderCode;
|
||||
final List<IoniaGiftCardInstruction> instructions;
|
||||
final String alderSku;
|
||||
final String ngcSku;
|
||||
final String acceptedCurrency;
|
||||
final String deepLink;
|
||||
final bool isPayLater;
|
||||
final double savingsPercentage;
|
||||
|
||||
double get discount => savingsPercentage;
|
||||
@@ -181,7 +87,7 @@ class IoniaMerchant {
|
||||
status += S.current.online;
|
||||
}
|
||||
|
||||
if (isPhysical) {
|
||||
if (isPhysical ?? false) {
|
||||
if (status.isNotEmpty) {
|
||||
status = '$status & ';
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
class IoniaOrder {
|
||||
IoniaOrder({@required this.id,
|
||||
@required this.uri,
|
||||
@required this.currency,
|
||||
@required this.amount,
|
||||
@required this.paymentId});
|
||||
IoniaOrder({required this.id,
|
||||
required this.uri,
|
||||
required this.currency,
|
||||
required this.amount,
|
||||
required this.paymentId});
|
||||
factory IoniaOrder.fromMap(Map<String, dynamic> obj) {
|
||||
return IoniaOrder(
|
||||
id: obj['order_id'] as String,
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import 'package:cake_wallet/ionia/ionia_merchant.dart';
|
||||
import 'package:cake_wallet/ionia/ionia_order.dart';
|
||||
import 'package:cake_wallet/ionia/ionia_virtual_card.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||
import 'package:cake_wallet/.secrets.g.dart' as secrets;
|
||||
import 'package:cake_wallet/ionia/ionia_api.dart';
|
||||
@@ -32,8 +31,8 @@ class IoniaService {
|
||||
// Verify email
|
||||
|
||||
Future<void> verifyEmail(String code) async {
|
||||
final username = await secureStorage.read(key: ioniaUsernameStorageKey);
|
||||
final email = await secureStorage.read(key: ioniaEmailStorageKey);
|
||||
final username = (await secureStorage.read(key: ioniaUsernameStorageKey))!;
|
||||
final email = (await secureStorage.read(key: ioniaEmailStorageKey))!;
|
||||
final credentials = await ioniaApi.verifyEmail(email: email, username: username, code: code, clientId: clientId);
|
||||
await secureStorage.write(key: ioniaPasswordStorageKey, value: credentials.password);
|
||||
await secureStorage.write(key: ioniaUsernameStorageKey, value: credentials.username);
|
||||
@@ -48,7 +47,7 @@ class IoniaService {
|
||||
}
|
||||
|
||||
Future<String> getUserEmail() async {
|
||||
return secureStorage.read(key: ioniaEmailStorageKey);
|
||||
return (await secureStorage.read(key: ioniaEmailStorageKey))!;
|
||||
}
|
||||
|
||||
// Check is user logined
|
||||
@@ -69,35 +68,35 @@ class IoniaService {
|
||||
// Create virtual card
|
||||
|
||||
Future<IoniaVirtualCard> createCard() async {
|
||||
final username = await secureStorage.read(key: ioniaUsernameStorageKey);
|
||||
final password = await secureStorage.read(key: ioniaPasswordStorageKey);
|
||||
final username = (await secureStorage.read(key: ioniaUsernameStorageKey))!;
|
||||
final password = (await secureStorage.read(key: ioniaPasswordStorageKey))!;
|
||||
return ioniaApi.createCard(username: username, password: password, clientId: clientId);
|
||||
}
|
||||
|
||||
// Get virtual card
|
||||
|
||||
Future<IoniaVirtualCard> getCard() async {
|
||||
final username = await secureStorage.read(key: ioniaUsernameStorageKey);
|
||||
final password = await secureStorage.read(key: ioniaPasswordStorageKey);
|
||||
final username = (await secureStorage.read(key: ioniaUsernameStorageKey))!;
|
||||
final password = (await secureStorage.read(key: ioniaPasswordStorageKey))!;
|
||||
return ioniaApi.getCards(username: username, password: password, clientId: clientId);
|
||||
}
|
||||
|
||||
// Get Merchants
|
||||
|
||||
Future<List<IoniaMerchant>> getMerchants() async {
|
||||
final username = await secureStorage.read(key: ioniaUsernameStorageKey);
|
||||
final password = await secureStorage.read(key: ioniaPasswordStorageKey);
|
||||
final username = (await secureStorage.read(key: ioniaUsernameStorageKey))!;
|
||||
final password = (await secureStorage.read(key: ioniaPasswordStorageKey))!;
|
||||
return ioniaApi.getMerchants(username: username, password: password, clientId: clientId);
|
||||
}
|
||||
|
||||
// Get Merchants By Filter
|
||||
|
||||
Future<List<IoniaMerchant>> getMerchantsByFilter({
|
||||
String search,
|
||||
List<IoniaCategory> categories,
|
||||
String? search,
|
||||
List<IoniaCategory>? categories,
|
||||
int merchantFilterType = 0}) async {
|
||||
final username = await secureStorage.read(key: ioniaUsernameStorageKey);
|
||||
final password = await secureStorage.read(key: ioniaPasswordStorageKey);
|
||||
final username = (await secureStorage.read(key: ioniaUsernameStorageKey))!;
|
||||
final password = (await secureStorage.read(key: ioniaPasswordStorageKey))!;
|
||||
return ioniaApi.getMerchantsByFilter(
|
||||
username: username,
|
||||
password: password,
|
||||
@@ -110,14 +109,14 @@ class IoniaService {
|
||||
// Purchase Gift Card
|
||||
|
||||
Future<IoniaOrder> purchaseGiftCard({
|
||||
@required String merchId,
|
||||
@required double amount,
|
||||
@required String currency}) async {
|
||||
final username = await secureStorage.read(key: ioniaUsernameStorageKey);
|
||||
final password = await secureStorage.read(key: ioniaPasswordStorageKey);
|
||||
required String merchId,
|
||||
required double amount,
|
||||
required String currency}) async {
|
||||
final username = (await secureStorage.read(key: ioniaUsernameStorageKey))!;
|
||||
final password = (await secureStorage.read(key: ioniaPasswordStorageKey))!;
|
||||
final deviceId = await PlatformDeviceId.getDeviceId;
|
||||
return ioniaApi.purchaseGiftCard(
|
||||
requestedUUID: deviceId,
|
||||
requestedUUID: deviceId!,
|
||||
merchId: merchId,
|
||||
amount: amount,
|
||||
currency: currency,
|
||||
@@ -129,18 +128,18 @@ class IoniaService {
|
||||
// Get Current User Gift Card Summaries
|
||||
|
||||
Future<List<IoniaGiftCard>> getCurrentUserGiftCardSummaries() async {
|
||||
final username = await secureStorage.read(key: ioniaUsernameStorageKey);
|
||||
final password = await secureStorage.read(key: ioniaPasswordStorageKey);
|
||||
final username = (await secureStorage.read(key: ioniaUsernameStorageKey))!;
|
||||
final password = (await secureStorage.read(key: ioniaPasswordStorageKey))!;
|
||||
return ioniaApi.getCurrentUserGiftCardSummaries(username: username, password: password, clientId: clientId);
|
||||
}
|
||||
|
||||
// Charge Gift Card
|
||||
|
||||
Future<void> chargeGiftCard({
|
||||
@required int giftCardId,
|
||||
@required double amount}) async {
|
||||
final username = await secureStorage.read(key: ioniaUsernameStorageKey);
|
||||
final password = await secureStorage.read(key: ioniaPasswordStorageKey);
|
||||
required int giftCardId,
|
||||
required double amount}) async {
|
||||
final username = (await secureStorage.read(key: ioniaUsernameStorageKey))!;
|
||||
final password = (await secureStorage.read(key: ioniaPasswordStorageKey))!;
|
||||
await ioniaApi.chargeGiftCard(
|
||||
username: username,
|
||||
password: password,
|
||||
@@ -157,19 +156,19 @@ class IoniaService {
|
||||
|
||||
// Get Gift Card
|
||||
|
||||
Future<IoniaGiftCard> getGiftCard({@required int id}) async {
|
||||
final username = await secureStorage.read(key: ioniaUsernameStorageKey);
|
||||
final password = await secureStorage.read(key: ioniaPasswordStorageKey);
|
||||
Future<IoniaGiftCard> getGiftCard({required int id}) async {
|
||||
final username = (await secureStorage.read(key: ioniaUsernameStorageKey))!;
|
||||
final password = (await secureStorage.read(key: ioniaPasswordStorageKey))!;
|
||||
return ioniaApi.getGiftCard(username: username, password: password, clientId: clientId,id: id);
|
||||
}
|
||||
|
||||
// Payment Status
|
||||
|
||||
Future<int> getPaymentStatus({
|
||||
@required String orderId,
|
||||
@required String paymentId}) async {
|
||||
final username = await secureStorage.read(key: ioniaUsernameStorageKey);
|
||||
final password = await secureStorage.read(key: ioniaPasswordStorageKey);
|
||||
required String orderId,
|
||||
required String paymentId}) async {
|
||||
final username = (await secureStorage.read(key: ioniaUsernameStorageKey))!;
|
||||
final password = (await secureStorage.read(key: ioniaPasswordStorageKey))!;
|
||||
return ioniaApi.getPaymentStatus(username: username, password: password, clientId: clientId, orderId: orderId, paymentId: paymentId);
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,13 @@
|
||||
class IoniaTip {
|
||||
const IoniaTip({this.originalAmount, this.percentage, this.isCustom = false});
|
||||
const IoniaTip({
|
||||
required this.originalAmount,
|
||||
required this.percentage,
|
||||
this.isCustom = false});
|
||||
|
||||
final double originalAmount;
|
||||
final double percentage;
|
||||
final bool isCustom;
|
||||
|
||||
double get additionalAmount => double.parse((originalAmount * percentage / 100).toStringAsFixed(2));
|
||||
|
||||
static const tipList = [
|
||||
|
||||
@@ -2,7 +2,7 @@ import 'package:flutter/foundation.dart';
|
||||
import 'dart:convert';
|
||||
|
||||
class IoniaTokenData {
|
||||
IoniaTokenData({@required this.accessToken, @required this.tokenType, @required this.expiredAt});
|
||||
IoniaTokenData({required this.accessToken, required this.tokenType, required this.expiredAt});
|
||||
|
||||
factory IoniaTokenData.fromJson(String source) {
|
||||
final decoded = json.decode(source) as Map<String, dynamic>;
|
||||
|
||||
@@ -1,17 +1,15 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
class IoniaVirtualCard {
|
||||
IoniaVirtualCard({
|
||||
@required this.token,
|
||||
@required this.createdAt,
|
||||
@required this.lastFour,
|
||||
@required this.state,
|
||||
@required this.pan,
|
||||
@required this.cvv,
|
||||
@required this.expirationMonth,
|
||||
@required this.expirationYear,
|
||||
@required this.fundsLimit,
|
||||
@required this.spendLimit});
|
||||
required this.token,
|
||||
required this.createdAt,
|
||||
required this.lastFour,
|
||||
required this.state,
|
||||
required this.pan,
|
||||
required this.cvv,
|
||||
required this.expirationMonth,
|
||||
required this.expirationYear,
|
||||
required this.fundsLimit,
|
||||
required this.spendLimit});
|
||||
|
||||
factory IoniaVirtualCard.fromMap(Map<String, Object> source) {
|
||||
final created = source['created'] as String;
|
||||
@@ -37,7 +35,7 @@ class IoniaVirtualCard {
|
||||
final String cvv;
|
||||
final String expirationMonth;
|
||||
final String expirationYear;
|
||||
final DateTime createdAt;
|
||||
final DateTime? createdAt;
|
||||
final double fundsLimit;
|
||||
final double spendLimit;
|
||||
}
|
||||
Reference in New Issue
Block a user