From a911a04cf7a37455cc2815ebc3f8a91e98685b67 Mon Sep 17 00:00:00 2001 From: Abdullahi Addow Date: Tue, 20 Apr 2021 16:09:12 +0300 Subject: [PATCH 1/7] Fixed android app crash when pressed android back button in flutter. --- .../company/go_sell_sdk_flutter/GoSellSdkFlutterPlugin.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/android/src/main/java/tap/company/go_sell_sdk_flutter/GoSellSdkFlutterPlugin.java b/android/src/main/java/tap/company/go_sell_sdk_flutter/GoSellSdkFlutterPlugin.java index 32037ec..300e38c 100644 --- a/android/src/main/java/tap/company/go_sell_sdk_flutter/GoSellSdkFlutterPlugin.java +++ b/android/src/main/java/tap/company/go_sell_sdk_flutter/GoSellSdkFlutterPlugin.java @@ -224,7 +224,10 @@ private void tearDown() { activityBinding.removeActivityResultListener(delegate); activityBinding.removeRequestPermissionsResultListener(delegate); activityBinding = null; - lifecycle.removeObserver(observer); + if(lifecycle!=null) + { + lifecycle.removeObserver(observer); + } lifecycle = null; delegate = null; channel.setMethodCallHandler(null); From e338bab451c80419cba1d77faa7d7dd4cae6abee Mon Sep 17 00:00:00 2001 From: Abdullahi Addow Date: Sun, 11 Jul 2021 12:18:27 +0300 Subject: [PATCH 2/7] solve merge conflicts --- CHANGELOG.md | 8 ++++++++ README.md | 4 ++-- android/build.gradle | 2 +- .../go_sell_sdk_flutter/GoSellSdkFlutterPlugin.java | 4 +--- .../deserializers/DeserializationUtil.java | 11 +++++++---- example/lib/main.dart | 2 +- lib/model/models.dart | 2 +- pubspec.yaml | 2 +- 8 files changed, 22 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c0e1ae..097d6f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +## 2.0.7 - 2021-05-30 + +- Added ALL for allowedCardTypes to allow both Credit and Debit cards. + +## 2.0.6 - 2021-04-22 + +- Fix Back button click Crash in android + ## 2.0.5 - 2021-03-17 - Added customer details in the results diff --git a/README.md b/README.md index aafab0d..c92b370 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ To use the SDK the following requirements must be met: ```dart dependencies: - go_sell_sdk_flutter: ^2.0.5 + go_sell_sdk_flutter: ^2.0.6 ``` --- @@ -191,7 +191,7 @@ Future setupSDKSession() async { // merchant id merchantID: "", // Allowed cards - allowedCadTypes: CardType.CREDIT, + allowedCadTypes: CardType.ALL, applePayMerchantID: "applePayMerchantID", allowsToSaveSameCardMoreThanOnce: false, // pass the card holder name to the SDK diff --git a/android/build.gradle b/android/build.gradle index 702a4f0..8787664 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -65,7 +65,7 @@ dependencies { implementation 'androidx.constraintlayout:constraintlayout:1.1.3' androidTestImplementation 'androidx.test.ext:junit:1.1.1' androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' - implementation 'com.github.Tap-Payments:goSellSDK-AndroidX:3.11.2' + implementation 'com.github.Tap-Payments:goSellSDK-AndroidX:3.12.2' implementation 'com.google.code.gson:gson:2.8.5' implementation 'com.squareup.retrofit2:converter-gson:2.6.0' } diff --git a/android/src/main/java/tap/company/go_sell_sdk_flutter/GoSellSdkFlutterPlugin.java b/android/src/main/java/tap/company/go_sell_sdk_flutter/GoSellSdkFlutterPlugin.java index 300e38c..58e4b6b 100644 --- a/android/src/main/java/tap/company/go_sell_sdk_flutter/GoSellSdkFlutterPlugin.java +++ b/android/src/main/java/tap/company/go_sell_sdk_flutter/GoSellSdkFlutterPlugin.java @@ -224,10 +224,8 @@ private void tearDown() { activityBinding.removeActivityResultListener(delegate); activityBinding.removeRequestPermissionsResultListener(delegate); activityBinding = null; - if(lifecycle!=null) - { + if(lifecycle != null) lifecycle.removeObserver(observer); - } lifecycle = null; delegate = null; channel.setMethodCallHandler(null); diff --git a/android/src/main/java/tap/company/go_sell_sdk_flutter/deserializers/DeserializationUtil.java b/android/src/main/java/tap/company/go_sell_sdk_flutter/deserializers/DeserializationUtil.java index 2e038f4..d772c6c 100644 --- a/android/src/main/java/tap/company/go_sell_sdk_flutter/deserializers/DeserializationUtil.java +++ b/android/src/main/java/tap/company/go_sell_sdk_flutter/deserializers/DeserializationUtil.java @@ -177,13 +177,16 @@ public static TransactionMode getTransactionMode(String jsonString) { } public static CardType getCardType(String jsonString) { - if (jsonString == null || + if (jsonString == null || jsonString == CardType.ALL.toString() || "null".equalsIgnoreCase(jsonString) || "".equalsIgnoreCase(jsonString.trim()) - ) return null; + ) return CardType.ALL; System.out.println("card type >>>> " + jsonString); - if ("CardType.CREDIT".equalsIgnoreCase(jsonString)) return CardType.CREDIT; - return CardType.DEBIT; + if ("CardType.CREDIT".equalsIgnoreCase(jsonString)) { + return CardType.CREDIT; + } + else if ("CardType.DEBIT".equalsIgnoreCase(jsonString)) return CardType.DEBIT; + return CardType.ALL; } public static String getPaymentType(String jsonString) { diff --git a/example/lib/main.dart b/example/lib/main.dart index 3bff824..58c9e66 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -111,7 +111,7 @@ class _MyAppState extends State { // merchant id merchantID: "", // Allowed cards - allowedCadTypes: CardType.CREDIT, + allowedCadTypes: CardType.ALL, applePayMerchantID: "applePayMerchantID", allowsToSaveSameCardMoreThanOnce: false, // pass the card holder name to the SDK diff --git a/lib/model/models.dart b/lib/model/models.dart index c3438af..6b355ee 100644 --- a/lib/model/models.dart +++ b/lib/model/models.dart @@ -254,4 +254,4 @@ class AuthorizeAction { enum AuthorizeActionType { CAPTURE, VOID } -enum CardType { DEBIT, CREDIT } +enum CardType { DEBIT, CREDIT, ALL } diff --git a/pubspec.yaml b/pubspec.yaml index f38715a..dfe9fd2 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: go_sell_sdk_flutter description: Flutter plugin compatible version of goSellSDK library for both Android and iOS. -version: 2.0.5 +version: 2.0.7 homepage: https://github.com/Tap-Payments/gosellSDK-Flutter.git environment: From da34bc54cbc471c1400a05437e9e6bd048333564 Mon Sep 17 00:00:00 2001 From: Abdullahi Addow Date: Sun, 11 Jul 2021 16:40:30 +0300 Subject: [PATCH 3/7] upgrade packages to null safety --- example/pubspec.lock | 40 ++++++++++++++++++++-------------------- pubspec.lock | 38 +++++++++++++++++++------------------- pubspec.yaml | 2 +- 3 files changed, 40 insertions(+), 40 deletions(-) diff --git a/example/pubspec.lock b/example/pubspec.lock index 476d078..d94c56b 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -7,42 +7,42 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.5.0-nullsafety.1" + version: "2.6.1" boolean_selector: dependency: transitive description: name: boolean_selector url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.1" + version: "2.1.0" characters: dependency: transitive description: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.3" + version: "1.1.0" charcode: dependency: transitive description: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.1" + version: "1.2.0" clock: dependency: transitive description: name: clock url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.1" + version: "1.1.0" collection: dependency: transitive description: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.15.0-nullsafety.3" + version: "1.15.0" cupertino_icons: dependency: "direct main" description: @@ -56,7 +56,7 @@ packages: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.1" + version: "1.2.0" flutter: dependency: "direct main" description: flutter @@ -73,28 +73,28 @@ packages: path: ".." relative: true source: path - version: "2.0.5" + version: "2.0.7" matcher: dependency: transitive description: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.10-nullsafety.1" + version: "0.12.10" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.3.0-nullsafety.3" + version: "1.3.0" path: dependency: transitive description: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.8.0-nullsafety.1" + version: "1.8.0" sky_engine: dependency: transitive description: flutter @@ -106,56 +106,56 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.0-nullsafety.2" + version: "1.8.1" stack_trace: dependency: transitive description: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.10.0-nullsafety.1" + version: "1.10.0" stream_channel: dependency: transitive description: name: stream_channel url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.1" + version: "2.1.0" string_scanner: dependency: transitive description: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.1" + version: "1.1.0" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.1" + version: "1.2.0" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.19-nullsafety.2" + version: "0.3.0" typed_data: dependency: transitive description: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.3.0-nullsafety.3" + version: "1.3.0" vector_math: dependency: transitive description: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.3" + version: "2.1.0" sdks: - dart: ">=2.10.0-110 <2.11.0" + dart: ">=2.12.0 <3.0.0" flutter: ">=1.10.0" diff --git a/pubspec.lock b/pubspec.lock index 706519b..6dc48a2 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -7,49 +7,49 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.5.0-nullsafety.1" + version: "2.6.1" boolean_selector: dependency: transitive description: name: boolean_selector url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.1" + version: "2.1.0" characters: dependency: transitive description: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.3" + version: "1.1.0" charcode: dependency: transitive description: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.1" + version: "1.2.0" clock: dependency: transitive description: name: clock url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.1" + version: "1.1.0" collection: dependency: transitive description: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.15.0-nullsafety.3" + version: "1.15.0" fake_async: dependency: transitive description: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.1" + version: "1.2.0" flutter: dependency: "direct main" description: flutter @@ -66,21 +66,21 @@ packages: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.10-nullsafety.1" + version: "0.12.10" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.3.0-nullsafety.3" + version: "1.3.0" path: dependency: transitive description: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.8.0-nullsafety.1" + version: "1.8.0" sky_engine: dependency: transitive description: flutter @@ -92,56 +92,56 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.0-nullsafety.2" + version: "1.8.1" stack_trace: dependency: transitive description: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.10.0-nullsafety.1" + version: "1.10.0" stream_channel: dependency: transitive description: name: stream_channel url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.1" + version: "2.1.0" string_scanner: dependency: transitive description: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.1" + version: "1.1.0" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.1" + version: "1.2.0" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.19-nullsafety.2" + version: "0.3.0" typed_data: dependency: transitive description: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.3.0-nullsafety.3" + version: "1.3.0" vector_math: dependency: transitive description: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.3" + version: "2.1.0" sdks: - dart: ">=2.10.0-110 <2.11.0" + dart: ">=2.12.0 <3.0.0" flutter: ">=1.10.0" diff --git a/pubspec.yaml b/pubspec.yaml index dfe9fd2..220f85c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -4,7 +4,7 @@ version: 2.0.7 homepage: https://github.com/Tap-Payments/gosellSDK-Flutter.git environment: - sdk: ">=2.1.0 <3.0.0" + sdk: ">=2.12.0 <3.0.0" flutter: ">=1.10.0" dependencies: From 56bca48e4b01527b1c29b4822855d8448242188b Mon Sep 17 00:00:00 2001 From: Abdullahi Addow Date: Sun, 11 Jul 2021 16:41:08 +0300 Subject: [PATCH 4/7] migrate the code to null safety --- lib/go_sell_sdk_flutter.dart | 117 ++++++++++++++++++++++------------- lib/model/models.dart | 92 ++++++++++++++------------- 2 files changed, 122 insertions(+), 87 deletions(-) diff --git a/lib/go_sell_sdk_flutter.dart b/lib/go_sell_sdk_flutter.dart index 845aef6..05a2f36 100644 --- a/lib/go_sell_sdk_flutter.dart +++ b/lib/go_sell_sdk_flutter.dart @@ -9,16 +9,21 @@ class GoSellSdkFlutter { static const String ERROR_CODE_INVALID_APP_CONFIGURATION = "501"; static Map _tapSDKResult = Map(); - static const MethodChannel _channel = const MethodChannel('go_sell_sdk_flutter'); + static const MethodChannel _channel = + const MethodChannel('go_sell_sdk_flutter'); static Future get startPaymentSDK async { if (!_validateSessionArge() || _validateAppConfig()) return _tapSDKResult; /// prepare sdk configurations - sdkConfigurations = {"appCredentials": appCredentials, "sessionParameters": sessionParameters}; + sdkConfigurations = { + "appCredentials": appCredentials, + "sessionParameters": sessionParameters + }; // /forward call to channel - dynamic result = await _channel.invokeMethod('start_sdk', sdkConfigurations); + dynamic result = + await _channel.invokeMethod('start_sdk', sdkConfigurations); print('result in dart : $result'); return result; } @@ -27,12 +32,17 @@ class GoSellSdkFlutter { _channel.invokeMethod('terminate_session'); } - static Map sdkConfigurations; - static Map appCredentials; - static Map sessionParameters; + static late Map sdkConfigurations; + static late Map appCredentials; + static late Map sessionParameters; /// App configurations - static void configureApp({String productionSecreteKey, String sandBoxsecretKey, String bundleId, String lang}) { + static void configureApp({ + required String productionSecreteKey, + required String sandBoxsecretKey, + required String bundleId, + required String lang, + }) { appCredentials = { "production_secrete_key": productionSecreteKey, "sandbox_secrete_key": sandBoxsecretKey, @@ -43,31 +53,31 @@ class GoSellSdkFlutter { /// session configurations static void sessionConfigurations({ - TransactionMode trxMode, - String transactionCurrency, - String amount, - Customer customer, - List paymentItems, - List taxes, - List shippings, - String postURL, - String paymentDescription, - Map paymentMetaData, - Reference paymentReference, - String paymentStatementDescriptor, - bool isUserAllowedToSaveCard, - bool isRequires3DSecure, - Receipt receipt, - AuthorizeAction authorizeAction, - Destinations destinations, - String merchantID, - CardType allowedCadTypes, - String applePayMerchantID, - SDKMode sdkMode, - PaymentType paymentType, - bool allowsToSaveSameCardMoreThanOnce, - String cardHolderName, - bool allowsToEditCardHolderName, + required TransactionMode trxMode, + required String transactionCurrency, + required String amount, + required Customer customer, + required List paymentItems, + List? taxes, + List? shippings, + required String postURL, + required String paymentDescription, + required Map paymentMetaData, + required Reference paymentReference, + required String paymentStatementDescriptor, + required bool isUserAllowedToSaveCard, + required bool isRequires3DSecure, + required Receipt receipt, + required AuthorizeAction authorizeAction, + Destinations? destinations, + required String merchantID, + CardType? allowedCadTypes, + required String applePayMerchantID, + required SDKMode sdkMode, + required PaymentType paymentType, + required bool allowsToSaveSameCardMoreThanOnce, + String? cardHolderName, + bool? allowsToEditCardHolderName, }) { sessionParameters = { 'trxMode': trxMode.toString(), @@ -100,9 +110,13 @@ class GoSellSdkFlutter { /// validate app configurations static bool _validateAppConfig() { - if (appCredentials["bundleId"] == "" || appCredentials["bundleId"] == "null" || appCredentials["bundleId"] == null) { + if (appCredentials["bundleId"] == "" || + appCredentials["bundleId"] == "null" || + appCredentials["bundleId"] == null) { _prepareConfigurationsErrorMap( - errorCode: ERROR_CODE_INVALID_APP_CONFIGURATION, errorMsg: 'Invalid Bundle ID', errorDescription: 'Bundle ID can not be empty or null'); + errorCode: ERROR_CODE_INVALID_APP_CONFIGURATION, + errorMsg: 'Invalid Bundle ID', + errorDescription: 'Bundle ID can not be empty or null'); return false; } @@ -126,9 +140,13 @@ class GoSellSdkFlutter { return false; } - if (appCredentials["lang"] == "" || appCredentials["lang"] == "null" || appCredentials["lang"] == null) { + if (appCredentials["lang"] == "" || + appCredentials["lang"] == "null" || + appCredentials["lang"] == null) { _prepareConfigurationsErrorMap( - errorCode: ERROR_CODE_INVALID_SESSION_CONFIGURATION, errorMsg: 'Invalid language', errorDescription: 'Language can not empty or null'); + errorCode: ERROR_CODE_INVALID_SESSION_CONFIGURATION, + errorMsg: 'Invalid language', + errorDescription: 'Language can not empty or null'); return false; } return true; @@ -136,7 +154,9 @@ class GoSellSdkFlutter { static bool _validateSessionArge() { // validate trx mode - if (sessionParameters["trxMode"] == "" || sessionParameters["trxMode"] == "null" || sessionParameters["trxMode"] == null) { + if (sessionParameters["trxMode"] == "" || + sessionParameters["trxMode"] == "null" || + sessionParameters["trxMode"] == null) { _prepareConfigurationsErrorMap( errorCode: ERROR_CODE_INVALID_SESSION_CONFIGURATION, errorMsg: 'Invalid Transaction Mode', @@ -156,18 +176,24 @@ class GoSellSdkFlutter { } // validate customer - if (sessionParameters["customer"] == "null" || sessionParameters["customer"] == null) { + if (sessionParameters["customer"] == "null" || + sessionParameters["customer"] == null) { _prepareConfigurationsErrorMap( - errorCode: ERROR_CODE_INVALID_SESSION_CONFIGURATION, errorMsg: 'Invalid Customer', errorDescription: 'Customer can not be empty or null'); + errorCode: ERROR_CODE_INVALID_SESSION_CONFIGURATION, + errorMsg: 'Invalid Customer', + errorDescription: 'Customer can not be empty or null'); return false; } // validate amount - if (sessionParameters["amount"] == "null" || !Util.isNumeric(sessionParameters["amount"]) || sessionParameters["amount"] == "") { + if (sessionParameters["amount"] == "null" || + !Util.isNumeric(sessionParameters["amount"]) || + sessionParameters["amount"] == "") { _prepareConfigurationsErrorMap( errorCode: ERROR_CODE_INVALID_SESSION_CONFIGURATION, errorMsg: 'Invalid Amount', - errorDescription: 'Amount can not be empty or null or zero and must be numeric value'); + errorDescription: + 'Amount can not be empty or null or zero and must be numeric value'); return false; } @@ -182,12 +208,17 @@ class GoSellSdkFlutter { } static void _validateBooleanValues(String param) { - if (sessionParameters[param] == "null" || sessionParameters[param] == null || sessionParameters[param] == "") { + if (sessionParameters[param] == "null" || + sessionParameters[param] == null || + sessionParameters[param] == "") { sessionParameters[param] = false; } } - static void _prepareConfigurationsErrorMap({String errorCode, String errorMsg, String errorDescription}) { + static void _prepareConfigurationsErrorMap( + {required String errorCode, + required String errorMsg, + String? errorDescription}) { _tapSDKResult.putIfAbsent('sdk_result', () => 'SDK_ERROR'); _tapSDKResult.putIfAbsent('sdk_error_code', () => errorCode); _tapSDKResult.putIfAbsent('sdk_error_message', () => errorMsg); diff --git a/lib/model/models.dart b/lib/model/models.dart index 6b355ee..f5ec33b 100644 --- a/lib/model/models.dart +++ b/lib/model/models.dart @@ -1,11 +1,11 @@ class Reference { - String acquirer; - String gateway; - String payment; - String track; - String transaction; - String order; - String gosellID; + String? acquirer; + String? gateway; + String? payment; + String? track; + String? transaction; + String? order; + String? gosellID; Reference( {this.acquirer, @@ -32,7 +32,7 @@ class Reference { class Receipt { bool sms; bool email; - String id; + String? id; Receipt(this.sms, this.email, {this.id}); Map toJson() { @@ -45,21 +45,21 @@ class Receipt { } class Customer { - String firstName; - String middleName; - String lastName; - String email; + String? firstName; + String? middleName; + String? lastName; + String? email; // Phone phone; - String isdNumber; - String number; + String? isdNumber; + String? number; String customerId; - String metaData; + String? metaData; Customer( {this.isdNumber, this.number, - this.customerId, + required this.customerId, this.email, this.firstName, this.middleName, @@ -83,10 +83,10 @@ class Customer { } class Destinations { - double amount; - String currency; - int count; - List destinationlist; + double? amount; + String? currency; + int? count; + List? destinationlist; Destinations({this.amount, this.currency, this.count, this.destinationlist}); @@ -98,7 +98,7 @@ class Destinations { if (this.destinationlist != null) { data['destination'] = - this.destinationlist.map((v) => v.toJson()).toList(); + this.destinationlist!.map((v) => v.toJson()).toList(); } return data; @@ -106,11 +106,11 @@ class Destinations { } class Destination { - String id; - double amount; - String currency; - String description; - String reference; + String? id; + double? amount; + String? currency; + String? description; + String? reference; Destination( {this.id, this.amount, this.currency, this.description, this.reference}); @@ -129,15 +129,15 @@ class Destination { class PaymentItem { int amountPerUnit; String description; - Map discount; - String name; - Quantity quantity; - List taxes; - int totalAmount; + Map? discount; + String? name; + Quantity? quantity; + List? taxes; + int? totalAmount; PaymentItem( - {this.amountPerUnit, - this.description, + {this.amountPerUnit = 0, + this.description = '', this.discount, this.name, this.quantity, @@ -153,11 +153,11 @@ class PaymentItem { data['name'] = this.name; if (this.quantity != null) { - data['quantity'] = this.quantity.toJson(); + data['quantity'] = this.quantity!.toJson(); } if (this.taxes != null) { - data['taxes'] = this.taxes.map((v) => v.toJson()).toList(); + data['taxes'] = this.taxes!.map((v) => v.toJson()).toList(); } data['total_amount'] = this.totalAmount; @@ -167,11 +167,15 @@ class PaymentItem { } class Amount { - String type; - double value; - double maximumFee; - double minimumFee; - Amount({this.type, this.value, this.maximumFee, this.minimumFee}); + final String type; + final double value; + final double maximumFee; + final double minimumFee; + const Amount( + {this.type = '', + this.value = 0.0, + this.maximumFee = 0.0, + this.minimumFee = 0.0}); Map toJson() { final Map data = new Map(); @@ -186,7 +190,7 @@ class Amount { class Quantity { int value; - Quantity({this.value}); + Quantity({this.value = 0}); Map toJson() { final Map data = new Map(); @@ -200,7 +204,7 @@ class Tax { String description; Amount amount; - Tax({this.amount, this.name, this.description}); + Tax({this.amount = const Amount(), this.name = '', this.description = ''}); Map toJson() { final Map data = new Map(); @@ -218,7 +222,7 @@ class Shipping { String description; double amount; - Shipping({this.name, this.description, this.amount}); + Shipping({this.name = '', this.description = '', this.amount = 0.0}); Map toJson() { final Map data = new Map(); @@ -233,7 +237,7 @@ class AuthorizeAction { AuthorizeActionType type; int timeInHours; - AuthorizeAction({this.type, this.timeInHours}); + AuthorizeAction({required this.type, required this.timeInHours}); Map toJson() { final Map data = new Map(); From 99a35e67b63f728ce58520f1f52c62234fb91097 Mon Sep 17 00:00:00 2001 From: Abdullahi Addow Date: Sun, 11 Jul 2021 18:01:59 +0300 Subject: [PATCH 5/7] migrate util file to null safety --- lib/utils/util.dart | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/utils/util.dart b/lib/utils/util.dart index 682c4e9..6b30498 100644 --- a/lib/utils/util.dart +++ b/lib/utils/util.dart @@ -1,15 +1,13 @@ -mixin Util{ -static bool isNumeric(String s) { - +mixin Util { + static bool isNumeric(String? s) { if (s == null || s.contains('-')) { return false; } - String finalString = s.replaceAll('.','').replaceAll('0',''); - if(finalString.isEmpty){ + String finalString = s.replaceAll('.', '').replaceAll('0', ''); + if (finalString.isEmpty) { return false; } // return double.parse(s, (e) => null) != null; - return (double.tryParse(s) ?? null) !=null; + return (double.tryParse(s) ?? null) != null; } } - \ No newline at end of file From ca97a0194c1dd39b05a170a41992b81a985b8d07 Mon Sep 17 00:00:00 2001 From: Abdullahi Addow Date: Sun, 17 Oct 2021 11:31:19 +0300 Subject: [PATCH 6/7] rename paymentMetaData to paymentMetadata --- .../tap/company/go_sell_sdk_flutter/GoSellSdKDelegate.java | 2 +- example/lib/main.dart | 2 +- lib/go_sell_sdk_flutter.dart | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/android/src/main/java/tap/company/go_sell_sdk_flutter/GoSellSdKDelegate.java b/android/src/main/java/tap/company/go_sell_sdk_flutter/GoSellSdKDelegate.java index 2b93465..fe06bd2 100644 --- a/android/src/main/java/tap/company/go_sell_sdk_flutter/GoSellSdKDelegate.java +++ b/android/src/main/java/tap/company/go_sell_sdk_flutter/GoSellSdKDelegate.java @@ -195,7 +195,7 @@ private void configureSDKSession(HashMap sessionParameters, Meth sdkSession.setPaymentDescription(sessionParameters.get("paymentDescription").toString()); // ** Optional ** // Payment Extra Info - sdkSession.setPaymentMetadata(DeserializationUtil.getMetaData(sessionParameters.get("paymenMetaData")));// ** + sdkSession.setPaymentMetadata(DeserializationUtil.getMetaData(sessionParameters.get("paymentMetadata")));// ** // Optional // ** // you diff --git a/example/lib/main.dart b/example/lib/main.dart index 58c9e66..3775f89 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -89,7 +89,7 @@ class _MyAppState extends State { // Payment description paymentDescription: "paymentDescription", // Payment Metadata - paymentMetaData: { + paymentMetadata: { "a": "a meta", "b": "b meta", }, diff --git a/lib/go_sell_sdk_flutter.dart b/lib/go_sell_sdk_flutter.dart index 05a2f36..87bbed2 100644 --- a/lib/go_sell_sdk_flutter.dart +++ b/lib/go_sell_sdk_flutter.dart @@ -62,7 +62,7 @@ class GoSellSdkFlutter { List? shippings, required String postURL, required String paymentDescription, - required Map paymentMetaData, + required Map paymentMetadata, required Reference paymentReference, required String paymentStatementDescriptor, required bool isUserAllowedToSaveCard, @@ -89,7 +89,7 @@ class GoSellSdkFlutter { "shipping": jsonEncode(shippings), "postURL": postURL, "paymentDescription": paymentDescription, - "paymenMetaData": jsonEncode(paymentMetaData), + "paymentMetadata": jsonEncode(paymentMetadata), "paymentReference": jsonEncode(paymentReference), "paymentStatementDescriptor": paymentStatementDescriptor, "isUserAllowedToSaveCard": isUserAllowedToSaveCard, From a9817adf218e221f00ad219f6a57b8da45c44101 Mon Sep 17 00:00:00 2001 From: Abdullahi Addow Date: Sun, 17 Oct 2021 11:32:13 +0300 Subject: [PATCH 7/7] fix paymentMetadata is not read in ios issue --- ios/Classes/SwiftGoSellSdkFlutterPlugin.swift | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/ios/Classes/SwiftGoSellSdkFlutterPlugin.swift b/ios/Classes/SwiftGoSellSdkFlutterPlugin.swift index a05d781..2ffb8d6 100644 --- a/ios/Classes/SwiftGoSellSdkFlutterPlugin.swift +++ b/ios/Classes/SwiftGoSellSdkFlutterPlugin.swift @@ -261,6 +261,25 @@ extension SwiftGoSellSdkFlutterPlugin: SessionDataSource { } return nil } + + + public var paymentMetadata: Metadata? { + if let paymentMetadataString:String = argsSessionParameters?["paymentMetadata"] as? String { + if let data = paymentMetadataString.data(using: .utf8) { + do { + let decoder = JSONDecoder() + let paymentMetadataObject:Metadata = try decoder.decode(Metadata.self, from: data) + return paymentMetadataObject + } catch { + print(error.localizedDescription) + } + } + } + return nil + } + + + public var receiptSettings: Receipt? { if let receiptSettingsString:String = argsSessionParameters?["receiptSettings"] as? String { if let data = receiptSettingsString.data(using: .utf8) {