From 2fa5709ed48f68d371da49ccaf3af5174faa4ca6 Mon Sep 17 00:00:00 2001 From: DEVSOG12 Date: Tue, 4 Jul 2023 11:44:36 -0400 Subject: [PATCH 1/2] Updates to dependencies and fixes --- CHANGELOG.md | 8 +- example/lib/main.dart | 9 +- .../Flutter/GeneratedPluginRegistrant.swift | 4 +- example/pubspec.lock | 300 +++++++++--------- lib/src/common/paystack.dart | 16 +- .../transaction/bank_transaction_manager.dart | 2 +- .../transaction/base_transaction_manager.dart | 10 +- .../transaction/card_transaction_manager.dart | 7 +- lib/src/ui/card_widget.dart | 4 +- lib/src/ui/checkout/card_checkout.dart | 4 + lib/src/ui/checkout/checkout_widget.dart | 7 +- lib/src/ui/input/card_input.dart | 38 ++- lib/src/ui/webview.dart | 29 +- pubspec.yaml | 27 +- 14 files changed, 247 insertions(+), 218 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2b8397e..937c73c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,4 +28,10 @@ Fixed Header Issue from @odunboye PR ## 0.1.2+5 - Fixed iOS WebView Issue \ No newline at end of file + Fixed iOS WebView Issue + +## 0.1.2+6 + v0.1.2+6 + +## 0.1.3 + Topped version for dependencies \ No newline at end of file diff --git a/example/lib/main.dart b/example/lib/main.dart index 7febd52..6138587 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -309,17 +309,18 @@ class _HomePageState extends State { ..putCustomField('Charged From', 'Flutter SDK'); // _getReference(); log(charge.reference!); - _chargeCard(charge); + _chargeCard(charge, scanCard: true); } else { // Perform transaction/initialize on Paystack server to get an access code // documentation: https://developers.paystack.co/reference#initialize-a-transaction charge.accessCode = await _fetchAccessCodeFrmServer(_getReference()); - _chargeCard(charge); + _chargeCard(charge, scanCard: true); } } - _chargeCard(Charge charge) async { - final response = await plugin.chargeCard(context, charge: charge); + _chargeCard(Charge charge, {required bool scanCard}) async { + final response = + await plugin.chargeCard(context, charge: charge, scanCard: scanCard); log(response.reference!); final reference = response.reference; diff --git a/example/macos/Flutter/GeneratedPluginRegistrant.swift b/example/macos/Flutter/GeneratedPluginRegistrant.swift index 15f797d..5397b8a 100644 --- a/example/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/example/macos/Flutter/GeneratedPluginRegistrant.swift @@ -5,8 +5,8 @@ import FlutterMacOS import Foundation -import device_info_plus_macos -import package_info_plus_macos +import device_info_plus +import package_info_plus func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin")) diff --git a/example/pubspec.lock b/example/pubspec.lock index 06ee5e7..8c49422 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -5,147 +5,128 @@ packages: dependency: transitive description: name: async - url: "https://pub.dartlang.org" + sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" + url: "https://pub.dev" source: hosted - version: "2.9.0" + version: "2.11.0" basic_utils: dependency: transitive description: name: basic_utils - url: "https://pub.dartlang.org" + sha256: "5748b8a2e810bba86da623940ac5c39874760a8f7cf02e62b1787a26f42f33bf" + url: "https://pub.dev" source: hosted - version: "5.3.0" + version: "5.6.0" boolean_selector: dependency: transitive description: name: boolean_selector - url: "https://pub.dartlang.org" + sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.1" characters: dependency: transitive description: name: characters - url: "https://pub.dartlang.org" + sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" + url: "https://pub.dev" source: hosted - version: "1.2.1" + version: "1.3.0" charcode: dependency: transitive description: name: charcode - url: "https://pub.dartlang.org" + sha256: fb98c0f6d12c920a02ee2d998da788bca066ca5f148492b7085ee23372b12306 + url: "https://pub.dev" source: hosted version: "1.3.1" clock: dependency: transitive description: name: clock - url: "https://pub.dartlang.org" + sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf + url: "https://pub.dev" source: hosted version: "1.1.1" collection: dependency: transitive description: name: collection - url: "https://pub.dartlang.org" + sha256: "4a07be6cb69c84d677a6c3096fcf960cc3285a8330b4603e0d463d15d9bd934c" + url: "https://pub.dev" source: hosted - version: "1.16.0" + version: "1.17.1" convert: dependency: transitive description: name: convert - url: "https://pub.dartlang.org" + sha256: "0f08b14755d163f6e2134cb58222dd25ea2a2ee8a195e53983d57c075324d592" + url: "https://pub.dev" source: hosted - version: "3.0.2" + version: "3.1.1" credit_card_scanner: dependency: transitive description: name: credit_card_scanner - url: "https://pub.dartlang.org" + sha256: "9bbfcac698f01bb32cbb2abfc6a9efa7fdea006e5a982cb4b8dc69fa0e8c1d19" + url: "https://pub.dev" source: hosted version: "1.0.5" - crypto: - dependency: transitive - description: - name: crypto - url: "https://pub.dartlang.org" - source: hosted - version: "3.0.2" csslib: dependency: transitive description: name: csslib - url: "https://pub.dartlang.org" + sha256: "831883fb353c8bdc1d71979e5b342c7d88acfbc643113c14ae51e2442ea0f20f" + url: "https://pub.dev" source: hosted - version: "0.17.2" + version: "0.17.3" cupertino_icons: dependency: "direct main" description: name: cupertino_icons - url: "https://pub.dartlang.org" + sha256: e35129dc44c9118cee2a5603506d823bab99c68393879edb440e0090d07586be + url: "https://pub.dev" source: hosted version: "1.0.5" device_info_plus: dependency: transitive description: name: device_info_plus - url: "https://pub.dartlang.org" - source: hosted - version: "4.1.2" - device_info_plus_linux: - dependency: transitive - description: - name: device_info_plus_linux - url: "https://pub.dartlang.org" - source: hosted - version: "3.0.0" - device_info_plus_macos: - dependency: transitive - description: - name: device_info_plus_macos - url: "https://pub.dartlang.org" + sha256: "2c35b6d1682b028e42d07b3aee4b98fa62996c10bc12cb651ec856a80d6a761b" + url: "https://pub.dev" source: hosted - version: "3.0.0" + version: "9.0.2" device_info_plus_platform_interface: dependency: transitive description: name: device_info_plus_platform_interface - url: "https://pub.dartlang.org" + sha256: d3b01d5868b50ae571cd1dc6e502fc94d956b665756180f7b16ead09e836fd64 + url: "https://pub.dev" source: hosted - version: "3.0.0" - device_info_plus_web: - dependency: transitive - description: - name: device_info_plus_web - url: "https://pub.dartlang.org" - source: hosted - version: "3.0.0" - device_info_plus_windows: - dependency: transitive - description: - name: device_info_plus_windows - url: "https://pub.dartlang.org" - source: hosted - version: "4.0.0" + version: "7.0.0" fake_async: dependency: transitive description: name: fake_async - url: "https://pub.dartlang.org" + sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" + url: "https://pub.dev" source: hosted version: "1.3.1" ffi: dependency: transitive description: name: ffi - url: "https://pub.dartlang.org" + sha256: ed5337a5660c506388a9f012be0288fb38b49020ce2b45fe1f8b8323fe429f99 + url: "https://pub.dev" source: hosted - version: "2.0.1" + version: "2.0.2" file: dependency: transitive description: name: file - url: "https://pub.dartlang.org" + sha256: "1b92bec4fc2a72f59a8e15af5f52cd441e4a7860b49499d69dfa817af20e925d" + url: "https://pub.dev" source: hosted version: "6.1.4" flutter: @@ -157,16 +138,17 @@ packages: dependency: "direct dev" description: name: flutter_lints - url: "https://pub.dartlang.org" + sha256: "2118df84ef0c3ca93f96123a616ae8540879991b8b57af2f81b76a7ada49b2a4" + url: "https://pub.dev" source: hosted - version: "2.0.1" + version: "2.0.2" flutter_paystack_payment: dependency: "direct dev" description: path: ".." relative: true source: path - version: "0.1.2+5" + version: "0.1.2+6" flutter_test: dependency: "direct dev" description: flutter @@ -181,149 +163,138 @@ packages: dependency: transitive description: name: html - url: "https://pub.dartlang.org" + sha256: "3a7812d5bcd2894edf53dfaf8cd640876cf6cef50a8f238745c8b8120ea74d3a" + url: "https://pub.dev" source: hosted - version: "0.15.0" + version: "0.15.4" http: dependency: transitive description: name: http - url: "https://pub.dartlang.org" + sha256: "759d1a329847dd0f39226c688d3e06a6b8679668e350e2891a6474f8b4bb8525" + url: "https://pub.dev" source: hosted - version: "0.13.5" + version: "1.1.0" http_parser: dependency: transitive description: name: http_parser - url: "https://pub.dartlang.org" + sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b" + url: "https://pub.dev" source: hosted - version: "4.0.1" + version: "4.0.2" intl: dependency: transitive description: name: intl - url: "https://pub.dartlang.org" + sha256: "3bc132a9dbce73a7e4a21a17d06e1878839ffbf975568bc875c60537824b0c4d" + url: "https://pub.dev" source: hosted - version: "0.17.0" + version: "0.18.1" js: dependency: transitive description: name: js - url: "https://pub.dartlang.org" + sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3 + url: "https://pub.dev" source: hosted - version: "0.6.4" + version: "0.6.7" json_annotation: dependency: transitive description: name: json_annotation - url: "https://pub.dartlang.org" + sha256: b10a7b2ff83d83c777edba3c6a0f97045ddadd56c944e1a23a3fdf43a1bf4467 + url: "https://pub.dev" source: hosted - version: "4.6.0" + version: "4.8.1" lints: dependency: transitive description: name: lints - url: "https://pub.dartlang.org" + sha256: "0a217c6c989d21039f1498c3ed9f3ed71b354e69873f13a8dfc3c9fe76f1b452" + url: "https://pub.dev" source: hosted - version: "2.0.0" + version: "2.1.1" logging: dependency: transitive description: name: logging - url: "https://pub.dartlang.org" + sha256: "623a88c9594aa774443aa3eb2d41807a48486b5613e67599fb4c41c0ad47c340" + url: "https://pub.dev" source: hosted - version: "1.0.2" + version: "1.2.0" matcher: dependency: transitive description: name: matcher - url: "https://pub.dartlang.org" + sha256: "6501fbd55da300384b768785b83e5ce66991266cec21af89ab9ae7f5ce1c4cbb" + url: "https://pub.dev" source: hosted - version: "0.12.12" + version: "0.12.15" material_color_utilities: dependency: transitive description: name: material_color_utilities - url: "https://pub.dartlang.org" + sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724 + url: "https://pub.dev" source: hosted version: "0.2.0" meta: dependency: transitive description: name: meta - url: "https://pub.dartlang.org" + sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3" + url: "https://pub.dev" source: hosted - version: "1.8.0" + version: "1.9.1" package_info_plus: dependency: transitive description: name: package_info_plus - url: "https://pub.dartlang.org" + sha256: ceb027f6bc6a60674a233b4a90a7658af1aebdea833da0b5b53c1e9821a78c7b + url: "https://pub.dev" source: hosted - version: "1.4.3+1" - package_info_plus_linux: - dependency: transitive - description: - name: package_info_plus_linux - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.5" - package_info_plus_macos: - dependency: transitive - description: - name: package_info_plus_macos - url: "https://pub.dartlang.org" - source: hosted - version: "1.3.0" + version: "4.0.2" package_info_plus_platform_interface: dependency: transitive description: name: package_info_plus_platform_interface - url: "https://pub.dartlang.org" + sha256: "9bc8ba46813a4cc42c66ab781470711781940780fd8beddd0c3da62506d3a6c6" + url: "https://pub.dev" source: hosted - version: "1.0.2" - package_info_plus_web: - dependency: transitive - description: - name: package_info_plus_web - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.5" - package_info_plus_windows: - dependency: transitive - description: - name: package_info_plus_windows - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.0" + version: "2.0.1" path: dependency: transitive description: name: path - url: "https://pub.dartlang.org" + sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" + url: "https://pub.dev" source: hosted - version: "1.8.2" + version: "1.8.3" platform_info: dependency: transitive description: name: platform_info - url: "https://pub.dartlang.org" + sha256: "61f3bd25642d6624b3d3111892b517cdb17c37a1837189fee346fcc6dd09b052" + url: "https://pub.dev" source: hosted - version: "3.2.0" + version: "4.0.2" plugin_platform_interface: dependency: transitive description: name: plugin_platform_interface - url: "https://pub.dartlang.org" + sha256: "6a2128648c854906c53fa8e33986fc0247a1116122f9534dd20e3ab9e16a32bc" + url: "https://pub.dev" source: hosted - version: "2.1.2" + version: "2.1.4" pointycastle: dependency: transitive description: name: pointycastle - url: "https://pub.dartlang.org" + sha256: "7c1e5f0d23c9016c5bbd8b1473d0d3fb3fc851b876046039509e18e0c7485f2c" + url: "https://pub.dev" source: hosted - version: "3.6.1" + version: "3.7.3" sky_engine: dependency: transitive description: flutter @@ -333,107 +304,130 @@ packages: dependency: transitive description: name: source_span - url: "https://pub.dartlang.org" + sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250 + url: "https://pub.dev" source: hosted version: "1.9.1" stack_trace: dependency: transitive description: name: stack_trace - url: "https://pub.dartlang.org" + sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5 + url: "https://pub.dev" source: hosted - version: "1.10.0" + version: "1.11.0" stream_channel: dependency: transitive description: name: stream_channel - url: "https://pub.dartlang.org" + sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8" + url: "https://pub.dev" source: hosted version: "2.1.1" string_scanner: dependency: transitive description: name: string_scanner - url: "https://pub.dartlang.org" + sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" + url: "https://pub.dev" source: hosted - version: "1.1.1" + version: "1.2.0" term_glyph: dependency: transitive description: name: term_glyph - url: "https://pub.dartlang.org" + sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 + url: "https://pub.dev" source: hosted version: "1.2.1" test_api: dependency: transitive description: name: test_api - url: "https://pub.dartlang.org" + sha256: eb6ac1540b26de412b3403a163d919ba86f6a973fe6cc50ae3541b80092fdcfb + url: "https://pub.dev" source: hosted - version: "0.4.14" + version: "0.5.1" typed_data: dependency: transitive description: name: typed_data - url: "https://pub.dartlang.org" + sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c + url: "https://pub.dev" source: hosted - version: "1.3.1" + version: "1.3.2" universal_html: dependency: transitive description: name: universal_html - url: "https://pub.dartlang.org" + sha256: a5cc5a84188e5d3e58f3ed77fe3dd4575dc1f68aa7c89e51b5b4105b9aab3b9d + url: "https://pub.dev" source: hosted - version: "2.0.8" + version: "2.2.3" universal_io: dependency: transitive description: name: universal_io - url: "https://pub.dartlang.org" + sha256: "1722b2dcc462b4b2f3ee7d188dad008b6eb4c40bbd03a3de451d82c78bba9aad" + url: "https://pub.dev" source: hosted - version: "2.0.4" + version: "2.2.2" vector_math: dependency: transitive description: name: vector_math - url: "https://pub.dartlang.org" + sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" + url: "https://pub.dev" source: hosted version: "2.1.4" webview_flutter: dependency: transitive description: name: webview_flutter - url: "https://pub.dartlang.org" + sha256: "789d52bd789373cc1e100fb634af2127e86c99cf9abde09499743270c5de8d00" + url: "https://pub.dev" source: hosted - version: "3.0.4" + version: "4.2.2" webview_flutter_android: dependency: transitive description: name: webview_flutter_android - url: "https://pub.dartlang.org" + sha256: "69787707339e7588aad256386475c18223cc0da87d9812343bc27c33c01eeab4" + url: "https://pub.dev" source: hosted - version: "2.10.0" + version: "3.8.1" webview_flutter_platform_interface: dependency: transitive description: name: webview_flutter_platform_interface - url: "https://pub.dartlang.org" + sha256: "656e2aeaef318900fffd21468b6ddc7958c7092a642f0e7220bac328b70d4a81" + url: "https://pub.dev" source: hosted - version: "1.9.3" + version: "2.3.1" webview_flutter_wkwebview: dependency: transitive description: name: webview_flutter_wkwebview - url: "https://pub.dartlang.org" + sha256: "7ae75a1a76b9463ae9278de7759ead68aa0eeb70f8d0175e3f9a6c43e911fe76" + url: "https://pub.dev" source: hosted - version: "2.9.3" + version: "3.6.1" win32: dependency: transitive description: name: win32 - url: "https://pub.dartlang.org" + sha256: dfdf0136e0aa7a1b474ea133e67cb0154a0acd2599c4f3ada3b49d38d38793ee + url: "https://pub.dev" source: hosted - version: "2.7.0" + version: "5.0.5" + win32_registry: + dependency: transitive + description: + name: win32_registry + sha256: e4506d60b7244251bc59df15656a3093501c37fb5af02105a944d73eb95be4c9 + url: "https://pub.dev" + source: hosted + version: "1.1.1" sdks: - dart: ">=2.18.0 <3.0.0" - flutter: ">=3.0.0" + dart: ">=3.0.0 <4.0.0" + flutter: ">=3.3.0" diff --git a/lib/src/common/paystack.dart b/lib/src/common/paystack.dart index 29279b7..f8daecb 100644 --- a/lib/src/common/paystack.dart +++ b/lib/src/common/paystack.dart @@ -45,8 +45,9 @@ class PaystackPayment { // Using cascade notation to build the platform specific info try { - - platformInfo = (Platform.environment.containsKey('FLUTTER_TEST') ? (await PlatformInfo.test())! :(await PlatformInfo.getinfo()))!; + platformInfo = (Platform.environment.containsKey('FLUTTER_TEST') + ? (await PlatformInfo.test())! + : (await PlatformInfo.getinfo()))!; _publicKey = publicKey; _sdkInitialized = true; } on PlatformException { @@ -83,10 +84,10 @@ class PaystackPayment { /// [charge] - the charge object. Future chargeCard(BuildContext context, - {required Charge charge}) { + {required Charge charge, required bool scanCard}) { _performChecks(); - return _Paystack(publicKey).chargeCard(context: context, charge: charge); + return _Paystack(publicKey).chargeCard(context: context, charge: charge, scanCard: scanCard); } /// Make payment using Paystack's checkout form. The plugin will handle the whole @@ -127,6 +128,7 @@ class PaystackPayment { BuildContext context, { required Charge charge, CheckoutMethod method = CheckoutMethod.selectable, + bool scanCard = false, bool fullscreen = false, Widget? logo, bool hideEmail = false, @@ -137,6 +139,7 @@ class PaystackPayment { charge: charge, method: method, fullscreen: fullscreen, + scanCard: scanCard, logo: logo, hideAmount: hideAmount, hideEmail: hideEmail, @@ -158,11 +161,12 @@ class _Paystack { _Paystack(this.publicKey); Future chargeCard( - {required BuildContext context, required Charge charge}) { + {required BuildContext context, required Charge charge, required bool scanCard}) { return CardTransactionManager( service: CardService(), charge: charge, context: context, + scanCard: scanCard, publicKey: publicKey) .chargeCard(); } @@ -172,6 +176,7 @@ class _Paystack { required Charge charge, required CheckoutMethod method, required bool fullscreen, + bool scanCard = false, bool hideEmail = false, bool hideAmount = false, Widget? logo, @@ -202,6 +207,7 @@ class _Paystack { bankService: BankService(), cardsService: CardService(), method: method, + scanCard: scanCard, charge: charge, fullscreen: fullscreen, logo: logo, diff --git a/lib/src/transaction/bank_transaction_manager.dart b/lib/src/transaction/bank_transaction_manager.dart index 7dbd5c4..5b59137 100644 --- a/lib/src/transaction/bank_transaction_manager.dart +++ b/lib/src/transaction/bank_transaction_manager.dart @@ -20,7 +20,7 @@ class BankTransactionManager extends BaseTransactionManager { required Charge charge, required BuildContext context, required String publicKey}) - : super(charge: charge, context: context, publicKey: publicKey); + : super(charge: charge, context: context, publicKey: publicKey, scanCard: false); Future chargeBank() async { await initiate(); diff --git a/lib/src/transaction/base_transaction_manager.dart b/lib/src/transaction/base_transaction_manager.dart index 199f7b0..7681d55 100644 --- a/lib/src/transaction/base_transaction_manager.dart +++ b/lib/src/transaction/base_transaction_manager.dart @@ -26,9 +26,11 @@ abstract class BaseTransactionManager { final BuildContext context; final Transaction transaction = Transaction(); final String publicKey; + final bool scanCard; BaseTransactionManager({ required this.charge, + required this.scanCard, required this.context, required this.publicKey, }); @@ -90,11 +92,15 @@ abstract class BaseTransactionManager { setProcessingOn() => processing = true; - Future getCardInfoFrmUI(PaymentCard? currentCard) async { + Future getCardInfoFrmUI( + PaymentCard? currentCard, bool scanCard) async { PaymentCard? newCard = await showDialog( barrierDismissible: false, context: context, - builder: (BuildContext context) => CardInputWidget(currentCard)); + builder: (BuildContext context) => CardInputWidget( + currentCard, + scanCard: scanCard, + )); if (newCard == null || !newCard.isValid()) { return notifyProcessingError(CardException('Invalid card parameters')); diff --git a/lib/src/transaction/card_transaction_manager.dart b/lib/src/transaction/card_transaction_manager.dart index eb375b2..d4433e0 100644 --- a/lib/src/transaction/card_transaction_manager.dart +++ b/lib/src/transaction/card_transaction_manager.dart @@ -24,10 +24,11 @@ class CardTransactionManager extends BaseTransactionManager { {required Charge charge, required this.service, required BuildContext context, - required String publicKey}) + required String publicKey, + required bool scanCard}) : assert(charge.card != null, 'please add a card to the charge before ' 'calling chargeCard'), - super(charge: charge, context: context, publicKey: publicKey); + super(charge: charge, context: context, publicKey: publicKey, scanCard: scanCard); @override postInitiate() async { @@ -39,7 +40,7 @@ class CardTransactionManager extends BaseTransactionManager { Future chargeCard() async { try { if (charge.card == null || !charge.card!.isValid()) { - return getCardInfoFrmUI(charge.card); + return getCardInfoFrmUI(charge.card, scanCard); } else { await initiate(); return sendCharge(); diff --git a/lib/src/ui/card_widget.dart b/lib/src/ui/card_widget.dart index 483c7c2..d7db7ed 100644 --- a/lib/src/ui/card_widget.dart +++ b/lib/src/ui/card_widget.dart @@ -7,8 +7,9 @@ import 'package:flutter_paystack_payment/src/ui/input/card_input.dart'; class CardInputWidget extends StatefulWidget { final PaymentCard? card; + final bool scanCard; - const CardInputWidget(this.card, {Key? key}) : super(key: key); + const CardInputWidget(this.card, {Key? key, required this.scanCard}) : super(key: key); @override // ignore: library_private_types_in_public_api @@ -42,6 +43,7 @@ class _CardInputWidgetState extends BaseState { height: 35.0, ), CardInput( + showScanButton: widget.scanCard, buttonText: 'Continue', card: widget.card, onValidated: _onCardValidated, diff --git a/lib/src/ui/checkout/card_checkout.dart b/lib/src/ui/checkout/card_checkout.dart index 29b46f9..c5efea6 100644 --- a/lib/src/ui/checkout/card_checkout.dart +++ b/lib/src/ui/checkout/card_checkout.dart @@ -20,12 +20,14 @@ class CardCheckout extends StatefulWidget { final ValueChanged onProcessingChange; final ValueChanged onCardChange; final bool hideAmount; + final bool scanCard; final CardServiceContract service; final String publicKey; const CardCheckout({ Key? key, required this.charge, + required this.scanCard, required this.onResponse, required this.onProcessingChange, required this.onCardChange, @@ -62,6 +64,7 @@ class _CardCheckoutState extends BaseCheckoutMethodState { height: 20.0, ), CardInput( + showScanButton: widget.scanCard, key: const Key("CardInput"), buttonText: widget.hideAmount ? "Continue" : 'Pay $amountText', card: _charge.card, @@ -93,6 +96,7 @@ class _CardCheckoutState extends BaseCheckoutMethodState { context: context, service: widget.service, publicKey: widget.publicKey, + scanCard: widget.scanCard, ).chargeCard(); onResponse(response); } diff --git a/lib/src/ui/checkout/checkout_widget.dart b/lib/src/ui/checkout/checkout_widget.dart index 605667a..5a9036d 100644 --- a/lib/src/ui/checkout/checkout_widget.dart +++ b/lib/src/ui/checkout/checkout_widget.dart @@ -25,6 +25,7 @@ class CheckoutWidget extends StatefulWidget { final Widget? logo; final bool hideEmail; final bool hideAmount; + final bool scanCard; final BankServiceContract bankService; final CardServiceContract cardsService; final String publicKey; @@ -34,6 +35,7 @@ class CheckoutWidget extends StatefulWidget { required this.method, required this.charge, required this.bankService, + required this.scanCard, required this.cardsService, required this.publicKey, this.fullscreen = false, @@ -94,10 +96,10 @@ class _CheckoutWidgetState extends BaseState crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center, children: [ - Row( + const Row( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center, - children: const [ + children: [ Icon(Icons.lock, size: 10), Padding( padding: EdgeInsetsDirectional.only(start: 3), @@ -297,6 +299,7 @@ class _CheckoutWidgetState extends BaseState publicKey: widget.publicKey, service: widget.cardsService, charge: _charge, + scanCard: widget.scanCard, onProcessingChange: _onProcessingChange, onResponse: _onPaymentResponse, hideAmount: widget.hideAmount, diff --git a/lib/src/ui/input/card_input.dart b/lib/src/ui/input/card_input.dart index f52e6ef..b290e95 100644 --- a/lib/src/ui/input/card_input.dart +++ b/lib/src/ui/input/card_input.dart @@ -13,14 +13,18 @@ import 'package:flutter_paystack_payment/src/ui/input/number_field.dart'; class CardInput extends StatefulWidget { final String buttonText; + final bool showScanButton; + // final bool scanCard; final PaymentCard? card; final ValueChanged onValidated; const CardInput({ Key? key, required this.buttonText, + required this.showScanButton, required this.card, required this.onValidated, + // required this.scanCard, }) : super(key: key); @override @@ -68,22 +72,24 @@ class _CardInputState extends State { onSaved: (String? value) => _card!.number = CardUtils.getCleanedNumber(value), // suffix: - suffix: GestureDetector( - onTap: () async { - ScanCard scanCard = ScanCard(); - CardDetails cardDetails = await scanCard.scanCard(); - setState(() { - numberController.text = cardDetails.cardNumber; - _card!.number = - CardUtils.getCleanedNumber(cardDetails.cardNumber); - // _card!.expiryMonth = - // int.parse(cardDetails.expiryDate.split('/')[0]); - // _card!.expiryYear = - // int.parse(cardDetails.expiryDate.split('/')[1]); - // _card!.cvc = cardDetail; - }); - }, - child: getCardIcon()), + suffix: widget.showScanButton + ? GestureDetector( + onTap: () async { + ScanCard scanCard = ScanCard(); + CardDetails cardDetails = await scanCard.scanCard(); + setState(() { + numberController.text = cardDetails.cardNumber; + _card!.number = + CardUtils.getCleanedNumber(cardDetails.cardNumber); + // _card!.expiryMonth = + // int.parse(cardDetails.expiryDate.split('/')[0]); + // _card!.expiryYear = + // int.parse(cardDetails.expiryDate.split('/')[1]); + // _card!.cvc = cardDetail; + }); + }, + child: getCardIcon()) + : getCardIcon(), ), const SizedBox( height: 15.0, diff --git a/lib/src/ui/webview.dart b/lib/src/ui/webview.dart index 3177483..d744bcb 100644 --- a/lib/src/ui/webview.dart +++ b/lib/src/ui/webview.dart @@ -35,33 +35,32 @@ class _WebViewState extends State { void readResponse() async { try { controller! - .runJavascriptReturningResult( + .runJavaScriptReturningResult( "document.getElementById('return').innerText") .catchError((e) { return Future.value(""); }).then((value) async { log("Value: $value"); - response = response!.length > 7 ? response : value; + // response = response!.length > 7 ? response : value; + response = response!.length > 7 ? response : value.toString(); log("Response: $response"); }); } catch (e) { log("error: $e"); } } -// value contains the html data of page as string - // ); - // WebView( ) - return view.WebView( - initialUrl: widget.url, - onWebViewCreated: (view.WebViewController webViewController) { - controller = webViewController; - }, - javascriptMode: view.JavascriptMode.unrestricted, - gestureNavigationEnabled: true, - onPageFinished: (String url) { - readResponse(); - }, + controller = view.WebViewController() + ..setJavaScriptMode(view.JavaScriptMode.unrestricted) + ..setNavigationDelegate(view.NavigationDelegate( + onPageFinished: (String url) { + readResponse(); + }, + )) + ..loadRequest(Uri.parse(widget.url)); + + return view.WebViewWidget( + controller: controller, ); } } diff --git a/pubspec.yaml b/pubspec.yaml index 60af76c..174c1b9 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,30 +1,31 @@ name: flutter_paystack_payment description: A plugin for Payment through Paystack made By Oreofe Solarin. -version: 0.1.2+5 +version: 0.1.2+6 homepage: https://github.com/DEVSOG12/flutter_paystack_payment environment: - sdk: ">=2.15.1 <3.0.0" + sdk: ">=2.15.1" flutter: ">=1.20.0" dependencies: flutter: sdk: flutter - http: ^0.13.4 - intl: ^0.17.0 - meta: ^1.7.0 - async: ^2.8.2 + http: ^1.1.0 + intl: ^0.18.1 + meta: ^1.9.1 + async: ^2.11.0 # Required for Dart Encryption - basic_utils: ^5.3.0 - pointycastle: ^3.6.0 + basic_utils: ^5.6.0 + pointycastle: ^3.7.3 # webview_flutter: ^3.0.0 # For Requests for Device - platform_info: ^3.2.0 - device_info_plus: ^4.0.0 - package_info_plus: ^1.4.2 - webview_flutter: ^3.0.4 - universal_html: ^2.0.8 + platform_info: ^4.0.2 + device_info_plus: ^9.0.2 + package_info_plus: ^4.0.2 + webview_flutter: ^4.2.2 + universal_html: ^2.2.3 + credit_card_scanner: ^1.0.5 dev_dependencies: From 0b7aafa53b97d49ce3f6334f4ee1fd2aa6f7d43b Mon Sep 17 00:00:00 2001 From: DEVSOG12 Date: Tue, 4 Jul 2023 11:46:29 -0400 Subject: [PATCH 2/2] Pubfix Constriant v0.1.3 --- example/pubspec.lock | 4 ++-- pubspec.yaml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/example/pubspec.lock b/example/pubspec.lock index 8c49422..929507c 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -148,7 +148,7 @@ packages: path: ".." relative: true source: path - version: "0.1.2+6" + version: "0.1.3" flutter_test: dependency: "direct dev" description: flutter @@ -429,5 +429,5 @@ packages: source: hosted version: "1.1.1" sdks: - dart: ">=3.0.0 <4.0.0" + dart: ">=3.0.0 <=3.0.5" flutter: ">=3.3.0" diff --git a/pubspec.yaml b/pubspec.yaml index 174c1b9..19f2e09 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,10 +1,10 @@ name: flutter_paystack_payment description: A plugin for Payment through Paystack made By Oreofe Solarin. -version: 0.1.2+6 +version: 0.1.3 homepage: https://github.com/DEVSOG12/flutter_paystack_payment environment: - sdk: ">=2.15.1" + sdk: ">=2.15.1 <=3.0.5" flutter: ">=1.20.0" dependencies: