diff --git a/example/.metadata b/example/.metadata index 3c0cd78..a25ef82 100644 --- a/example/.metadata +++ b/example/.metadata @@ -1,11 +1,11 @@ # This file tracks properties of this Flutter project. # Used by Flutter tool to assess capabilities and perform upgrades etc. # -# This file should be version controlled. +# This file should be version controlled and should not be manually edited. version: - revision: eb6d86ee27deecba4a83536aa20f366a6044895c - channel: stable + revision: "9e1c857886f07d342cf106f2cd588bcd5e031bb2" + channel: "stable" project_type: app @@ -13,26 +13,11 @@ project_type: app migration: platforms: - platform: root - create_revision: eb6d86ee27deecba4a83536aa20f366a6044895c - base_revision: eb6d86ee27deecba4a83536aa20f366a6044895c - - platform: android - create_revision: eb6d86ee27deecba4a83536aa20f366a6044895c - base_revision: eb6d86ee27deecba4a83536aa20f366a6044895c - - platform: ios - create_revision: eb6d86ee27deecba4a83536aa20f366a6044895c - base_revision: eb6d86ee27deecba4a83536aa20f366a6044895c - - platform: linux - create_revision: eb6d86ee27deecba4a83536aa20f366a6044895c - base_revision: eb6d86ee27deecba4a83536aa20f366a6044895c - - platform: macos - create_revision: eb6d86ee27deecba4a83536aa20f366a6044895c - base_revision: eb6d86ee27deecba4a83536aa20f366a6044895c + create_revision: 9e1c857886f07d342cf106f2cd588bcd5e031bb2 + base_revision: 9e1c857886f07d342cf106f2cd588bcd5e031bb2 - platform: web - create_revision: eb6d86ee27deecba4a83536aa20f366a6044895c - base_revision: eb6d86ee27deecba4a83536aa20f366a6044895c - - platform: windows - create_revision: eb6d86ee27deecba4a83536aa20f366a6044895c - base_revision: eb6d86ee27deecba4a83536aa20f366a6044895c + create_revision: 9e1c857886f07d342cf106f2cd588bcd5e031bb2 + base_revision: 9e1c857886f07d342cf106f2cd588bcd5e031bb2 # User provided section diff --git a/example/lib/main.dart b/example/lib/main.dart index 18f41df..54d21c3 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -1,5 +1,7 @@ import 'package:coffee_flutter/widgets/payment.dart'; +import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; import 'package:moyasar/moyasar.dart'; import 'widgets/coffee.dart'; @@ -29,11 +31,14 @@ class CoffeeShop extends StatefulWidget { class _CoffeeShopState extends State { final paymentConfig = PaymentConfig( - publishableApiKey: 'pk_test_r6eZg85QyduWZ7PNTHT56BFvZpxJgNJ2PqPMDoXA', + publishableApiKey: 'pk_test_KjYR9npiw3UJJpwXpvaADS3ut5bKtyC6ip18FeDC', amount: 100, // SAR 1 description: 'order #1324', + callbackUrl: 'http://localhost:13404/auth.html', metadata: {'size': '250g'}, creditCard: CreditCardConfig(saveCard: false, manual: false), + + applePay: ApplePayConfig( merchantId: 'merchant.mysr.fghurayri', label: 'Blue Coffee Beans', @@ -70,21 +75,64 @@ class _CoffeeShopState extends State { backgroundColor: Colors.white, resizeToAvoidBottomInset: true, body: Center( - child: SizedBox( - width: MediaQuery.of(context).size.width * 0.9, - child: ListView( - children: [ - const CoffeeImage(), - PaymentMethods( - paymentConfig: paymentConfig, - onPaymentResult: onPaymentResult, - ), - ], - ), + child: + TextButton( + onPressed: onSubmitCcForm, + child: const Text('Pay'), ), )); } -} + + + void onSubmitCcForm() async { + final source = CardPaymentRequestSource( + + creditCardData: CardFormModel( + name: 'John Doe', + number: '4201320111111010', + month: '05', + year: '2025',cvc: + '100'), + tokenizeCard: (paymentConfig.creditCard as CreditCardConfig).saveCard, + manualPayment: (paymentConfig.creditCard as CreditCardConfig).manual); + + final paymentRequest = PaymentRequest(paymentConfig, source); + + final result = await Moyasar.pay( + apiKey: paymentConfig.publishableApiKey, + paymentRequest: paymentRequest); + + + + final String transactionUrl = + (result.source as CardPaymentResponseSource).transactionUrl; + + if (kIsWeb) { + + + try { + final result = await FlutterWebAuth2.authenticate( + url: transactionUrl, + callbackUrlScheme: 'auth', + + ); +final uri = Uri.parse(result); + +final status = PaymentStatus.values.byName(uri.queryParameters['status']!); + + showToast(context, status); + + } on PlatformException catch (e) { + print('PlatformException ${e}'); + // setState(() { + // _status = 'Got error: $e'; + // }); + } + } + + + + } void showToast(context, status) { ScaffoldMessenger.of(context).showSnackBar(SnackBar( @@ -94,3 +142,4 @@ void showToast(context, status) { ), )); } +} \ No newline at end of file diff --git a/example/pubspec.lock b/example/pubspec.lock index 1ee4d96..53c8e7b 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -45,10 +45,10 @@ packages: dependency: transitive description: name: collection - sha256: f092b211a4319e98e5ff58223576de6c2803db36221657b46c82574721240687 + sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a url: "https://pub.dev" source: hosted - version: "1.17.2" + version: "1.18.0" cupertino_icons: dependency: "direct main" description: @@ -96,6 +96,27 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_web_auth_2: + dependency: transitive + description: + name: flutter_web_auth_2 + sha256: ea57000909d0002824179f1e4907c074f39538e86a9e4d93a74b7c37dbaee242 + url: "https://pub.dev" + source: hosted + version: "3.0.4" + flutter_web_auth_2_platform_interface: + dependency: transitive + description: + name: flutter_web_auth_2_platform_interface + sha256: "9124824cbd21e12680bf58190e27b77f251c897e80ec81cd557ec1fde9aecabf" + url: "https://pub.dev" + source: hosted + version: "3.0.0" + flutter_web_plugins: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" http: dependency: transitive description: @@ -148,10 +169,10 @@ packages: dependency: transitive description: name: meta - sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3" + sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e url: "https://pub.dev" source: hosted - version: "1.9.1" + version: "1.10.0" moyasar: dependency: "direct main" description: @@ -240,18 +261,18 @@ packages: dependency: transitive description: name: stack_trace - sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5 + sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" url: "https://pub.dev" source: hosted - version: "1.11.0" + version: "1.11.1" stream_channel: dependency: transitive description: name: stream_channel - sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8" + sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 url: "https://pub.dev" source: hosted - version: "2.1.1" + version: "2.1.2" string_scanner: dependency: transitive description: @@ -272,10 +293,10 @@ packages: dependency: transitive description: name: test_api - sha256: "75760ffd7786fffdfb9597c35c5b27eaeec82be8edfb6d71d32651128ed7aab8" + sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b" url: "https://pub.dev" source: hosted - version: "0.6.0" + version: "0.6.1" typed_data: dependency: transitive description: @@ -284,6 +305,70 @@ packages: url: "https://pub.dev" source: hosted version: "1.3.2" + url_launcher: + dependency: transitive + description: + name: url_launcher + sha256: b1c9e98774adf8820c96fbc7ae3601231d324a7d5ebd8babe27b6dfac91357ba + url: "https://pub.dev" + source: hosted + version: "6.2.1" + url_launcher_android: + dependency: transitive + description: + name: url_launcher_android + sha256: "31222ffb0063171b526d3e569079cf1f8b294075ba323443fdc690842bfd4def" + url: "https://pub.dev" + source: hosted + version: "6.2.0" + url_launcher_ios: + dependency: transitive + description: + name: url_launcher_ios + sha256: bba3373219b7abb6b5e0d071b0fe66dfbe005d07517a68e38d4fc3638f35c6d3 + url: "https://pub.dev" + source: hosted + version: "6.2.1" + url_launcher_linux: + dependency: transitive + description: + name: url_launcher_linux + sha256: "9f2d390e096fdbe1e6e6256f97851e51afc2d9c423d3432f1d6a02a8a9a8b9fd" + url: "https://pub.dev" + source: hosted + version: "3.1.0" + url_launcher_macos: + dependency: transitive + description: + name: url_launcher_macos + sha256: b7244901ea3cf489c5335bdacda07264a6e960b1c1b1a9f91e4bc371d9e68234 + url: "https://pub.dev" + source: hosted + version: "3.1.0" + url_launcher_platform_interface: + dependency: transitive + description: + name: url_launcher_platform_interface + sha256: "980e8d9af422f477be6948bdfb68df8433be71f5743a188968b0c1b887807e50" + url: "https://pub.dev" + source: hosted + version: "2.2.0" + url_launcher_web: + dependency: transitive + description: + name: url_launcher_web + sha256: "138bd45b3a456dcfafc46d1a146787424f8d2edfbf2809c9324361e58f851cf7" + url: "https://pub.dev" + source: hosted + version: "2.2.1" + url_launcher_windows: + dependency: transitive + description: + name: url_launcher_windows + sha256: "7754a1ad30ee896b265f8d14078b0513a4dba28d358eabb9d5f339886f4a1adc" + url: "https://pub.dev" + source: hosted + version: "3.1.0" vector_graphics: dependency: transitive description: @@ -320,10 +405,10 @@ packages: dependency: transitive description: name: web - sha256: dc8ccd225a2005c1be616fe02951e2e342092edf968cf0844220383757ef8f10 + sha256: afe077240a270dcfd2aafe77602b4113645af95d0ad31128cc02bce5ac5d5152 url: "https://pub.dev" source: hosted - version: "0.1.4-beta" + version: "0.3.0" webview_flutter: dependency: transitive description: @@ -356,6 +441,14 @@ packages: url: "https://pub.dev" source: hosted version: "3.9.4" + window_to_front: + dependency: transitive + description: + name: window_to_front + sha256: "7aef379752b7190c10479e12b5fd7c0b9d92adc96817d9e96c59937929512aee" + url: "https://pub.dev" + source: hosted + version: "0.0.3" xml: dependency: transitive description: @@ -373,5 +466,5 @@ packages: source: hosted version: "3.1.2" sdks: - dart: ">=3.1.0-185.0.dev <4.0.0" - flutter: ">=3.7.0" + dart: ">=3.2.0 <4.0.0" + flutter: ">=3.16.0" diff --git a/example/web/auth.html b/example/web/auth.html new file mode 100644 index 0000000..a39703f --- /dev/null +++ b/example/web/auth.html @@ -0,0 +1,17 @@ + +Authentication complete +

Authentication is complete. If this does not happen automatically, please close the window.

+ \ No newline at end of file diff --git a/example/web/favicon.png b/example/web/favicon.png new file mode 100644 index 0000000..8aaa46a Binary files /dev/null and b/example/web/favicon.png differ diff --git a/example/web/icons/Icon-192.png b/example/web/icons/Icon-192.png new file mode 100644 index 0000000..b749bfe Binary files /dev/null and b/example/web/icons/Icon-192.png differ diff --git a/example/web/icons/Icon-512.png b/example/web/icons/Icon-512.png new file mode 100644 index 0000000..88cfd48 Binary files /dev/null and b/example/web/icons/Icon-512.png differ diff --git a/example/web/icons/Icon-maskable-192.png b/example/web/icons/Icon-maskable-192.png new file mode 100644 index 0000000..eb9b4d7 Binary files /dev/null and b/example/web/icons/Icon-maskable-192.png differ diff --git a/example/web/icons/Icon-maskable-512.png b/example/web/icons/Icon-maskable-512.png new file mode 100644 index 0000000..d69c566 Binary files /dev/null and b/example/web/icons/Icon-maskable-512.png differ diff --git a/example/web/index.html b/example/web/index.html new file mode 100644 index 0000000..45cf2ca --- /dev/null +++ b/example/web/index.html @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + + example + + + + + + + + + + diff --git a/example/web/manifest.json b/example/web/manifest.json new file mode 100644 index 0000000..096edf8 --- /dev/null +++ b/example/web/manifest.json @@ -0,0 +1,35 @@ +{ + "name": "example", + "short_name": "example", + "start_url": ".", + "display": "standalone", + "background_color": "#0175C2", + "theme_color": "#0175C2", + "description": "A new Flutter project.", + "orientation": "portrait-primary", + "prefer_related_applications": false, + "icons": [ + { + "src": "icons/Icon-192.png", + "sizes": "192x192", + "type": "image/png" + }, + { + "src": "icons/Icon-512.png", + "sizes": "512x512", + "type": "image/png" + }, + { + "src": "icons/Icon-maskable-192.png", + "sizes": "192x192", + "type": "image/png", + "purpose": "maskable" + }, + { + "src": "icons/Icon-maskable-512.png", + "sizes": "512x512", + "type": "image/png", + "purpose": "maskable" + } + ] +} diff --git a/lib/moyasar.dart b/lib/moyasar.dart index c1ca731..8b90e96 100644 --- a/lib/moyasar.dart +++ b/lib/moyasar.dart @@ -29,3 +29,5 @@ export 'src/errors/api_error.dart' show ApiError; export 'src/errors/auth_error.dart' show AuthError; export 'src/errors/validation_error.dart' show ValidationError; export 'src/errors/payment_canceled_error.dart' show PaymentCanceledError; + +export 'package:flutter_web_auth_2/flutter_web_auth_2.dart'; \ No newline at end of file diff --git a/lib/src/models/payment_config.dart b/lib/src/models/payment_config.dart index 44f0ff0..c7d98a9 100644 --- a/lib/src/models/payment_config.dart +++ b/lib/src/models/payment_config.dart @@ -1,10 +1,10 @@ import 'package:moyasar/src/models/apple_pay_config.dart'; import 'package:moyasar/src/models/credit_card_config.dart'; - + const defaultCallbackUrl = "https://example.com/thanks"; /// Used by Moyasar API along with any of the supported sources. class PaymentConfig { /// Used internally to manage the 3DS step. - static String callbackUrl = "https://example.com/thanks"; + final String callbackUrl; /// You can find your [publishableApiKey] in your Moyasar Dashboard. /// Go to https://moyasar.com/docs/dashboard/api-keys for more details. @@ -40,6 +40,7 @@ class PaymentConfig { required this.description, this.metadata, this.applePay, + this.callbackUrl = defaultCallbackUrl, this.creditCard}) : assert(publishableApiKey.isNotEmpty, 'Please fill `publishableApiKey` argument with your key.'), diff --git a/lib/src/models/payment_request.dart b/lib/src/models/payment_request.dart index 3dc54f2..141d534 100644 --- a/lib/src/models/payment_request.dart +++ b/lib/src/models/payment_request.dart @@ -1,4 +1,5 @@ import 'package:moyasar/moyasar.dart'; +import 'package:moyasar/src/models/payment_config.dart'; import 'package:moyasar/src/models/sources/payment_request_source.dart'; /// Required data to setup a payment. @@ -11,7 +12,7 @@ class PaymentRequest { Map? metadata; late PaymentRequestSource source; - String callbackUrl = PaymentConfig.callbackUrl; + String callbackUrl = defaultCallbackUrl; PaymentRequest( PaymentConfig config, PaymentRequestSource paymentRequestSource) { @@ -20,6 +21,7 @@ class PaymentRequest { description = config.description; metadata = config.metadata; source = paymentRequestSource; + callbackUrl = config.callbackUrl; } Map toJson() => { @@ -29,5 +31,6 @@ class PaymentRequest { 'description': description, 'metadata': metadata, 'callback_url': callbackUrl, + }; } diff --git a/lib/src/moyasar.dart b/lib/src/moyasar.dart index e005e0d..30ee8c3 100644 --- a/lib/src/moyasar.dart +++ b/lib/src/moyasar.dart @@ -2,6 +2,7 @@ import 'dart:convert'; import 'package:http/http.dart' as http; import 'package:moyasar/moyasar.dart'; + const version = "2.0.4"; /// Payment service. diff --git a/lib/src/widgets/credit_card.dart b/lib/src/widgets/credit_card.dart index 088be8b..ee52ccd 100644 --- a/lib/src/widgets/credit_card.dart +++ b/lib/src/widgets/credit_card.dart @@ -1,5 +1,7 @@ +import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:flutter_web_auth_2/flutter_web_auth_2.dart'; import 'package:moyasar/moyasar.dart'; import 'package:moyasar/src/utils/card_utils.dart'; import 'package:moyasar/src/utils/input_formatters.dart'; @@ -80,28 +82,51 @@ class _CreditCardState extends State { final String transactionUrl = (result.source as CardPaymentResponseSource).transactionUrl; - if (mounted) { - Navigator.push( - context, - MaterialPageRoute( - fullscreenDialog: true, - maintainState: false, - builder: (context) => ThreeDSWebView( - transactionUrl: transactionUrl, - on3dsDone: (String status, String message) async { - if (status == PaymentStatus.paid.name) { - result.status = PaymentStatus.paid; - } else if (status == PaymentStatus.authorized.name) { - result.status = PaymentStatus.authorized; - } else { - result.status = PaymentStatus.failed; - (result.source as CardPaymentResponseSource).message = - message; - } - Navigator.pop(context); - widget.onPaymentResult(result); - })), - ); + if (kIsWeb) { + + + try { + final result = await FlutterWebAuth2.authenticate( + url: transactionUrl, + callbackUrlScheme: 'auth', + options: const FlutterWebAuth2Options( + timeout: 5, // example: 5 seconds timeout + ), + ); + print('result ${result}'); + // setState(() { + // _status = 'Got result: $result'; + // }); + } on PlatformException catch (e) { + print('result ${e}'); + // setState(() { + // _status = 'Got error: $e'; + // }); + } + } else { + if (mounted) { + Navigator.push( + context, + MaterialPageRoute( + fullscreenDialog: true, + maintainState: false, + builder: (context) => ThreeDSWebView( + transactionUrl: transactionUrl, + on3dsDone: (String status, String message) async { + if (status == PaymentStatus.paid.name) { + result.status = PaymentStatus.paid; + } else if (status == PaymentStatus.authorized.name) { + result.status = PaymentStatus.authorized; + } else { + result.status = PaymentStatus.failed; + (result.source as CardPaymentResponseSource).message = + message; + } + Navigator.pop(context); + widget.onPaymentResult(result); + })), + ); + } } } @@ -117,6 +142,7 @@ class _CreditCardState extends State { hintText: widget.locale.nameOnCard, ), keyboardType: TextInputType.text, + validator: (String? input) => CardUtils.validateName(input, widget.locale), onSaved: (value) => _cardData.name = value ?? '', diff --git a/lib/src/widgets/three_d_s_webview.dart b/lib/src/widgets/three_d_s_webview.dart index 1e932d3..b490f2a 100644 --- a/lib/src/widgets/three_d_s_webview.dart +++ b/lib/src/widgets/three_d_s_webview.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:moyasar/moyasar.dart'; +import 'package:moyasar/src/models/payment_config.dart'; import 'package:webview_flutter/webview_flutter.dart'; /// The widget that shows the 3DS step. @@ -31,7 +32,7 @@ class _ThreeDSWebViewState extends State { ..setJavaScriptMode(JavaScriptMode.unrestricted) ..setNavigationDelegate(NavigationDelegate(onPageFinished: (pageUrl) { final redirectedTo = Uri.parse(pageUrl); - final callbackUri = Uri.parse(PaymentConfig.callbackUrl); + final callbackUri = Uri.parse(defaultCallbackUrl); final bool hasReachedFinalRedirection = redirectedTo.host == callbackUri.host; diff --git a/pubspec.lock b/pubspec.lock index 0265467..7e0e8d2 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -88,6 +88,27 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_web_auth_2: + dependency: "direct main" + description: + name: flutter_web_auth_2 + sha256: ea57000909d0002824179f1e4907c074f39538e86a9e4d93a74b7c37dbaee242 + url: "https://pub.dev" + source: hosted + version: "3.0.4" + flutter_web_auth_2_platform_interface: + dependency: transitive + description: + name: flutter_web_auth_2_platform_interface + sha256: "9124824cbd21e12680bf58190e27b77f251c897e80ec81cd557ec1fde9aecabf" + url: "https://pub.dev" + source: hosted + version: "3.0.0" + flutter_web_plugins: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" http: dependency: "direct main" description: @@ -269,6 +290,70 @@ packages: url: "https://pub.dev" source: hosted version: "1.3.2" + url_launcher: + dependency: transitive + description: + name: url_launcher + sha256: b1c9e98774adf8820c96fbc7ae3601231d324a7d5ebd8babe27b6dfac91357ba + url: "https://pub.dev" + source: hosted + version: "6.2.1" + url_launcher_android: + dependency: transitive + description: + name: url_launcher_android + sha256: "31222ffb0063171b526d3e569079cf1f8b294075ba323443fdc690842bfd4def" + url: "https://pub.dev" + source: hosted + version: "6.2.0" + url_launcher_ios: + dependency: transitive + description: + name: url_launcher_ios + sha256: bba3373219b7abb6b5e0d071b0fe66dfbe005d07517a68e38d4fc3638f35c6d3 + url: "https://pub.dev" + source: hosted + version: "6.2.1" + url_launcher_linux: + dependency: transitive + description: + name: url_launcher_linux + sha256: "9f2d390e096fdbe1e6e6256f97851e51afc2d9c423d3432f1d6a02a8a9a8b9fd" + url: "https://pub.dev" + source: hosted + version: "3.1.0" + url_launcher_macos: + dependency: transitive + description: + name: url_launcher_macos + sha256: b7244901ea3cf489c5335bdacda07264a6e960b1c1b1a9f91e4bc371d9e68234 + url: "https://pub.dev" + source: hosted + version: "3.1.0" + url_launcher_platform_interface: + dependency: transitive + description: + name: url_launcher_platform_interface + sha256: "980e8d9af422f477be6948bdfb68df8433be71f5743a188968b0c1b887807e50" + url: "https://pub.dev" + source: hosted + version: "2.2.0" + url_launcher_web: + dependency: transitive + description: + name: url_launcher_web + sha256: "138bd45b3a456dcfafc46d1a146787424f8d2edfbf2809c9324361e58f851cf7" + url: "https://pub.dev" + source: hosted + version: "2.2.1" + url_launcher_windows: + dependency: transitive + description: + name: url_launcher_windows + sha256: "7754a1ad30ee896b265f8d14078b0513a4dba28d358eabb9d5f339886f4a1adc" + url: "https://pub.dev" + source: hosted + version: "3.1.0" vector_graphics: dependency: transitive description: @@ -341,6 +426,14 @@ packages: url: "https://pub.dev" source: hosted version: "3.9.4" + window_to_front: + dependency: transitive + description: + name: window_to_front + sha256: "7aef379752b7190c10479e12b5fd7c0b9d92adc96817d9e96c59937929512aee" + url: "https://pub.dev" + source: hosted + version: "0.0.3" xml: dependency: transitive description: @@ -358,5 +451,5 @@ packages: source: hosted version: "3.1.2" sdks: - dart: ">=3.2.0-194.0.dev <4.0.0" - flutter: ">=3.7.0" + dart: ">=3.2.0 <4.0.0" + flutter: ">=3.16.0" diff --git a/pubspec.yaml b/pubspec.yaml index c2c83a9..7fcfe7c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -12,6 +12,7 @@ environment: dependencies: flutter: sdk: flutter + flutter_web_auth_2: ^3.0.4 http: ^1.1.0 pay: ^1.1.2 webview_flutter: ^4.4.2 diff --git a/test/models/payment_config_test.dart b/test/models/payment_config_test.dart index 6112915..0f64ca3 100644 --- a/test/models/payment_config_test.dart +++ b/test/models/payment_config_test.dart @@ -1,5 +1,6 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:moyasar/moyasar.dart'; +import 'package:moyasar/src/models/payment_config.dart'; void main() { test('should create a valid payment config with only required fields.', () { @@ -11,7 +12,7 @@ void main() { expect(paymentConfig.currency, "SAR"); expect(paymentConfig.description, "Coffee"); expect(paymentConfig.metadata, null); - expect(PaymentConfig.callbackUrl, "https://example.com/thanks"); + expect(defaultCallbackUrl, "https://example.com/thanks"); }); test('should create a valid payment config with all fields.', () { @@ -34,7 +35,7 @@ void main() { expect(paymentConfig.currency, "USD"); expect(paymentConfig.description, "Coffee!"); expect(paymentConfig.metadata, meta); - expect(PaymentConfig.callbackUrl, "https://example.com/thanks"); + expect(defaultCallbackUrl, "https://example.com/thanks"); expect(paymentConfig.creditCard!.saveCard, false); expect(paymentConfig.creditCard!.manual, false); diff --git a/test/models/payment_request_test.dart b/test/models/payment_request_test.dart index 3bc1f73..37fe7f6 100644 --- a/test/models/payment_request_test.dart +++ b/test/models/payment_request_test.dart @@ -76,6 +76,7 @@ void main() { publishableApiKey: "api_key", amount: 123, description: "Coffee!", + metadata: metadata); ApplePayPaymentRequestSource apprs =