-
Notifications
You must be signed in to change notification settings - Fork 14
[WIP] Feature/add netlify #430
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
29cfc0c
64acf41
6355044
06600b1
c11e2bb
18c2874
e01a9e3
bcd1ebf
e642ad5
73255c7
90b9991
d46da7c
2a93a22
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<component name="ProjectRunConfigurationManager"> | ||
<configuration default="false" name="main_netlify.dart" type="FlutterRunConfigurationType" factoryName="Flutter" nameIsGenerated="true"> | ||
<option name="additionalArgs" value="--dart-define="CLIENT_KEY=test_O3LEH54C3JDPREE3QOEPOCRG4QGEICBQ" --dart-define="APPLE_PAY_MERCHANT_ID_KEY=demo"" /> | ||
Robert-SD marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Committing secrets to the repository, even if they are test keys, is a security risk. The hardcoded There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is intended. It is our public client key from mystoredemo.io. |
||
<option name="filePath" value="$PROJECT_DIR$/example/lib/main_netlify.dart" /> | ||
<method v="2" /> | ||
</configuration> | ||
</component> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import 'package:adyen_checkout/adyen_checkout.dart'; | ||
|
||
extension CardConfigurationExtension on CardConfiguration { | ||
static CardConfiguration fromJson(Map<String, dynamic> json) { | ||
return CardConfiguration( | ||
holderNameRequired: json['holderNameRequired'] ?? false, | ||
addressMode: _parseAddressMode(json['addressMode']), | ||
showStorePaymentField: json['showStorePaymentField'] ?? false, | ||
showCvcForStoredCard: json['showCvcForStoredCard'] ?? true, | ||
showCvc: json['showCvc'] ?? true, | ||
kcpFieldVisibility: _parseFieldVisibility(json['kcpFieldVisibility']), | ||
socialSecurityNumberFieldVisibility: | ||
_parseFieldVisibility(json['socialSecurityNumberFieldVisibility']), | ||
supportedCardTypes: (json['supportedCardTypes'] as List<dynamic>?) | ||
?.map((element) => element as String) | ||
.toList() ?? | ||
[], | ||
); | ||
} | ||
|
||
CardConfiguration copyWith({ | ||
bool? holderNameRequired, | ||
AddressMode? addressMode, | ||
bool? showStorePaymentField, | ||
bool? showCvcForStoredCard, | ||
bool? showCvc, | ||
FieldVisibility? kcpFieldVisibility, | ||
FieldVisibility? socialSecurityNumberFieldVisibility, | ||
List<String>? supportedCardTypes, | ||
Function(List<BinLookupData>)? onBinLookup, | ||
Function(String)? onBinValue, | ||
}) { | ||
return CardConfiguration( | ||
holderNameRequired: holderNameRequired ?? this.holderNameRequired, | ||
addressMode: addressMode ?? this.addressMode, | ||
showStorePaymentField: | ||
showStorePaymentField ?? this.showStorePaymentField, | ||
showCvcForStoredCard: showCvcForStoredCard ?? this.showCvcForStoredCard, | ||
showCvc: showCvc ?? this.showCvc, | ||
kcpFieldVisibility: kcpFieldVisibility ?? this.kcpFieldVisibility, | ||
socialSecurityNumberFieldVisibility: | ||
socialSecurityNumberFieldVisibility ?? | ||
this.socialSecurityNumberFieldVisibility, | ||
supportedCardTypes: supportedCardTypes ?? this.supportedCardTypes, | ||
onBinLookup: onBinLookup ?? this.onBinLookup, | ||
onBinValue: onBinValue ?? this.onBinValue, | ||
); | ||
} | ||
|
||
static AddressMode _parseAddressMode(String? value) { | ||
switch (value) { | ||
case 'full': | ||
return AddressMode.full; | ||
case 'postalCode': | ||
return AddressMode.postalCode; | ||
case 'none': | ||
default: | ||
return AddressMode.none; | ||
} | ||
} | ||
|
||
static FieldVisibility _parseFieldVisibility(String? value) { | ||
switch (value) { | ||
case 'show': | ||
return FieldVisibility.show; | ||
case 'hide': | ||
default: | ||
return FieldVisibility.hide; | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,185 +1,6 @@ | ||
// ignore_for_file: unused_local_variable | ||
|
||
import 'package:adyen_checkout/adyen_checkout.dart'; | ||
import 'package:adyen_checkout_example/network/service.dart'; | ||
import 'package:adyen_checkout_example/repositories/adyen_apple_pay_component_repository.dart'; | ||
import 'package:adyen_checkout_example/repositories/adyen_card_component_repository.dart'; | ||
import 'package:adyen_checkout_example/repositories/adyen_cse_repository.dart'; | ||
import 'package:adyen_checkout_example/repositories/adyen_drop_in_repository.dart'; | ||
import 'package:adyen_checkout_example/repositories/adyen_google_pay_component_repository.dart'; | ||
import 'package:adyen_checkout_example/repositories/adyen_instant_component_repository.dart'; | ||
import 'package:adyen_checkout_example/screens/api_only/card_state_notifier.dart'; | ||
import 'package:adyen_checkout_example/screens/api_only/custom_card_screen.dart'; | ||
import 'package:adyen_checkout_example/screens/component/apple_pay/apple_pay_advanced_component_screen.dart'; | ||
import 'package:adyen_checkout_example/screens/component/apple_pay/apple_pay_navigation_screen.dart'; | ||
import 'package:adyen_checkout_example/screens/component/apple_pay/apple_pay_session_component_screen.dart'; | ||
import 'package:adyen_checkout_example/screens/component/card/card_advanced_component_screen.dart'; | ||
import 'package:adyen_checkout_example/screens/component/card/card_bottom_sheet_screen.dart'; | ||
import 'package:adyen_checkout_example/screens/component/card/card_navigation_screen.dart'; | ||
import 'package:adyen_checkout_example/screens/component/card/card_session_component_screen.dart'; | ||
import 'package:adyen_checkout_example/screens/component/google_pay/google_pay_advanced_component_screen.dart'; | ||
import 'package:adyen_checkout_example/screens/component/google_pay/google_pay_navigation_screen.dart'; | ||
import 'package:adyen_checkout_example/screens/component/google_pay/google_pay_session_component_screen.dart'; | ||
import 'package:adyen_checkout_example/screens/component/instant/instant_advanced_component_screen.dart'; | ||
import 'package:adyen_checkout_example/screens/component/instant/instant_navigation_screen.dart'; | ||
import 'package:adyen_checkout_example/screens/component/instant/instant_session_component_screen.dart'; | ||
import 'package:adyen_checkout_example/screens/component/multi_component/multi_component_advanced_screen.dart'; | ||
import 'package:adyen_checkout_example/screens/component/multi_component/multi_component_navigation_screen.dart'; | ||
import 'package:adyen_checkout_example/screens/component/multi_component/multi_component_session_screen.dart'; | ||
import 'package:adyen_checkout_example/screens/drop_in/drop_in_screen.dart'; | ||
import 'package:adyen_checkout_example/utils/provider.dart'; | ||
import 'package:flutter/foundation.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_localizations/flutter_localizations.dart'; | ||
import 'package:adyen_checkout_example/main_common.dart'; | ||
import 'package:adyen_checkout_example/network/checkout_service.dart'; | ||
|
||
void main() { | ||
final service = Service(); | ||
final adyenGooglePayComponentRepository = | ||
AdyenGooglePayComponentRepository(service: service); | ||
final adyenApplePayComponentRepository = | ||
AdyenApplePayComponentRepository(service: service); | ||
final adyenCardComponentRepository = | ||
AdyenCardComponentRepository(service: service); | ||
final adyenInstantComponentRepository = | ||
AdyenInstantComponentRepository(service: service); | ||
final adyenCseRepository = AdyenCseRepository(service: service); | ||
|
||
runApp(MaterialApp( | ||
localizationsDelegates: const [ | ||
GlobalMaterialLocalizations.delegate, | ||
GlobalWidgetsLocalizations.delegate, | ||
GlobalCupertinoLocalizations.delegate, | ||
], | ||
supportedLocales: const [ | ||
Locale('en'), // English | ||
Locale('ar'), // Arabic | ||
], | ||
themeMode: ThemeMode.system, | ||
theme: ThemeData( | ||
colorScheme: ColorScheme.fromSeed( | ||
seedColor: const Color(0xFF00112C), | ||
brightness: Brightness.light, | ||
)), | ||
darkTheme: ThemeData( | ||
colorScheme: ColorScheme.fromSeed( | ||
seedColor: const Color(0xFFEFEFEF), | ||
brightness: Brightness.dark, | ||
), | ||
), | ||
routes: { | ||
'/': (context) => const MyApp(), | ||
'/dropInScreen': (context) => DropInScreen( | ||
repository: AdyenDropInRepository(service: service), | ||
), | ||
'/cardComponentScreen': (context) => const CardNavigationScreen(), | ||
'/cardSessionComponentScreen': (context) => CardSessionComponentScreen( | ||
repository: adyenCardComponentRepository, | ||
), | ||
'/cardAdvancedComponentScreen': (context) => CardAdvancedComponentScreen( | ||
repository: adyenCardComponentRepository, | ||
), | ||
'/cardBottomSheetScreen': (context) => CardBottomSheetScreen( | ||
repository: adyenCardComponentRepository, | ||
), | ||
'/googlePayNavigation': (context) => const GooglePayNavigationScreen(), | ||
'/googlePaySessionComponent': (context) => | ||
GooglePaySessionsComponentScreen( | ||
repository: adyenGooglePayComponentRepository, | ||
), | ||
'/googlePayAdvancedComponent': (context) => | ||
GooglePayAdvancedComponentScreen( | ||
repository: adyenGooglePayComponentRepository, | ||
), | ||
'/applePayNavigation': (context) => const ApplePayNavigationScreen(), | ||
'/applePaySessionComponent': (context) => ApplePaySessionComponentScreen( | ||
repository: adyenApplePayComponentRepository, | ||
), | ||
'/applePayAdvancedComponent': (context) => | ||
ApplePayAdvancedComponentScreen( | ||
repository: adyenApplePayComponentRepository, | ||
), | ||
'/instantComponentNavigation': (context) => | ||
const InstantNavigationScreen(), | ||
'/instantSessionComponent': (context) => InstantSessionComponentScreen( | ||
repository: adyenInstantComponentRepository), | ||
'/instantAdvancedComponent': (context) => InstantAdvancedComponentScreen( | ||
repository: adyenInstantComponentRepository), | ||
'/multiComponentNavigationScreen': (context) => | ||
const MultiComponentNavigationScreen(), | ||
'/multiComponentSessionScreen': (context) => MultiComponentSessionScreen( | ||
cardRepository: adyenCardComponentRepository, | ||
googlePayRepository: adyenGooglePayComponentRepository, | ||
applePayRepository: adyenApplePayComponentRepository, | ||
), | ||
'/multiComponentAdvancedScreen': (context) => | ||
MultiComponentAdvancedScreen( | ||
cardRepository: adyenCardComponentRepository, | ||
googlePayRepository: adyenGooglePayComponentRepository, | ||
applePayRepository: adyenApplePayComponentRepository, | ||
), | ||
'/customCard': (context) => Provider( | ||
notifier: CardStateNotifier(adyenCseRepository), | ||
child: const CustomCardScreen(), | ||
), | ||
}, | ||
initialRoute: "/", | ||
)); | ||
} | ||
|
||
class MyApp extends StatelessWidget { | ||
const MyApp({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
AdyenCheckout.instance.enableConsoleLogging(enabled: false); | ||
|
||
return Scaffold( | ||
appBar: AppBar( | ||
title: const Center(child: Text('Checkout example app')), | ||
), | ||
body: Center( | ||
child: Column( | ||
mainAxisAlignment: MainAxisAlignment.center, | ||
children: [ | ||
TextButton( | ||
onPressed: () => Navigator.pushNamed(context, "/dropInScreen"), | ||
child: const Text("Drop-in")), | ||
TextButton( | ||
onPressed: () => | ||
Navigator.pushNamed(context, "/cardComponentScreen"), | ||
child: const Text("Card component")), | ||
_buildGoogleOrApplePayComponent(context), | ||
TextButton( | ||
onPressed: () => | ||
Navigator.pushNamed(context, "/instantComponentNavigation"), | ||
child: const Text("Instant component")), | ||
TextButton( | ||
onPressed: () => Navigator.pushNamed( | ||
context, "/multiComponentNavigationScreen"), | ||
child: const Text("Multi component")), | ||
TextButton( | ||
onPressed: () => Navigator.pushNamed(context, "/customCard"), | ||
child: const Text("Custom card (CSE)")), | ||
], | ||
), | ||
), | ||
); | ||
} | ||
|
||
Widget _buildGoogleOrApplePayComponent(BuildContext context) { | ||
switch (defaultTargetPlatform) { | ||
case TargetPlatform.android: | ||
return TextButton( | ||
onPressed: () => | ||
Navigator.pushNamed(context, "/googlePayNavigation"), | ||
child: const Text("Google pay component")); | ||
case TargetPlatform.iOS: | ||
return TextButton( | ||
onPressed: () => | ||
Navigator.pushNamed(context, "/applePayNavigation"), | ||
child: const Text("Apple pay component")); | ||
default: | ||
return const SizedBox.shrink(); | ||
} | ||
} | ||
mainCommon(CheckoutService()); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The client key is already public on the MyStoreDemo.