Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions Sample/ios/Runner/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ import Flutter
import UIKit

@main
@objc class AppDelegate: FlutterAppDelegate {
@objc class AppDelegate: FlutterAppDelegate, FlutterImplicitEngineDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
GeneratedPluginRegistrant.register(with: self)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}

func didInitializeImplicitFlutterEngine(_ engineBridge: FlutterImplicitEngineBridge) {
GeneratedPluginRegistrant.register(with: engineBridge.pluginRegistry)
}
}
25 changes: 23 additions & 2 deletions Sample/ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
<dict>
<key>CADisableMinimumFrameDurationOnPhone</key>
<true/>
<key>CFBundleAllowMixedLocalizations</key>
<true/>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleDisplayName</key>
Expand All @@ -28,6 +30,27 @@
<false/>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIApplicationSceneManifest</key>
<dict>
<key>UIApplicationSupportsMultipleScenes</key>
<false/>
<key>UISceneConfigurations</key>
<dict>
<key>UIWindowSceneSessionRoleApplication</key>
<array>
<dict>
<key>UISceneClassName</key>
<string>UIWindowScene</string>
<key>UISceneConfigurationName</key>
<string>flutter</string>
<key>UISceneDelegateClassName</key>
<string>FlutterSceneDelegate</string>
<key>UISceneStoryboardFile</key>
<string>Main</string>
</dict>
</array>
</dict>
</dict>
<key>UIApplicationSupportsIndirectInputEvents</key>
<true/>
<key>UILaunchStoryboardName</key>
Expand All @@ -40,8 +63,6 @@
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>CFBundleAllowMixedLocalizations</key>
<true/>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
Expand Down
4 changes: 3 additions & 1 deletion Sample/lib/api/model/pg_codes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ enum PGCode {

apple_pay(code: "apple-pay", name: "Apple Pay"),
tap_pg(code: "tap_pg", name: "Tag PG"),
ottu_sdk(code: "ottu_sdk", name: "Ottu Sdk");
ottu_sdk(code: "ottu_sdk", name: "Ottu Sdk"),
cod(code: "cod", name: "cod"),
jamiawallet(code: "jamiawallet", name: "jamiawallet");

const PGCode({required this.code, required this.name, this.inverselyRelated});

Expand Down
12 changes: 0 additions & 12 deletions Sample/lib/feature/home/home_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -287,18 +287,6 @@ class _HomeScreenState extends State<HomeScreen> {
Text('Fail payment validation', style: TextStyle(color: Colors.red)),
],
),
Row(
children: [
Checkbox(
checkColor: Colors.red,
value: state.failPaymentValidation ?? false,
onChanged: (bool? value) {
context.read<HomeScreenCubit>().onFailPaymentValidation(value);
},
),
Text('Fail payment validation', style: TextStyle(color: Colors.red)),
],
),
const SizedBox(height: 24),
Divider(height: 2, thickness: 3),
const Text('Payment methods:'),
Expand Down
2 changes: 2 additions & 0 deletions Sample/lib/feature/home/home_screen_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ class HomeScreenCubit extends Cubit<HomeScreenState> {
//PGCode.urpay: true,
PGCode.tamara: true,
PGCode.tabby: true,
PGCode.cod: true,
PGCode.jamiawallet: true,
}),
),
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,19 +221,25 @@ public class CheckoutPlatformView: NSObject, FlutterPlatformView {
}

func tryAttachController() {
Logger.sdk.info("tryAttachController")
guard let pvc = self.paymentViewController else { return }

if let parentVC = UIApplication.shared.delegate?.window??
.rootViewController as? FlutterViewController
{
parentVC.addChild(pvc)
_view.addCheckoutView(pvc.view)
pvc.didMove(toParent: parentVC)
Logger.sdk.info("Added to parent!")
} else {
Logger.sdk.info("Waiting for parent...")
DispatchQueue.main.asyncAfter(deadline: .now() + 0.05) {
self.tryAttachController()
if let scene = UIApplication.shared.connectedScenes.first as? UIWindowScene {
if let window = scene.windows.first(where: { $0.isKeyWindow }) {
let rootViewController = window.rootViewController
Logger.sdk.info("tryAttachController, pvc: \(rootViewController)")
if let parentVC = rootViewController as? FlutterViewController {
Logger.sdk.debug("tryAttachController, addChild PVC")
parentVC.addChild(pvc)
_view.addCheckoutView(pvc.view)
pvc.didMove(toParent: parentVC)
Logger.sdk.info("Added to parent!")
} else {
Logger.sdk.info("tryAttachController, PVC hasn found, waiting for parent...")
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
self.tryAttachController()
}
}
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions lib/src/checkout_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ class _OttuCheckoutWidgetState extends State<OttuCheckoutWidget> {
@override
void initState() {
super.initState();
if (kDebugMode) {
print("OttuCheckoutWidget.initState()");
}
_methodChannel.setMethodCallHandler(_handleChannelMethod);
}

Expand Down
Loading