Judopay / Xamarin-Sample-App

Xamarin SDK sample app
MIT License
9 stars 2 forks source link

System.NullReferenceException on creating PreAuthPage [iOS] #26

Closed xleon closed 5 years ago

xleon commented 5 years ago

image

  at JudoDotNetXamarin.PaymentService..ctor (JudoDotNetXamarin.Judo judo) [0x0002c] in <56707fd2425b4f29a750edb0a1b4d6b1>:0 
  at JudoDotNetXamarin.CardEntryPage..ctor (JudoDotNetXamarin.Judo judo) [0x0005f] in <56707fd2425b4f29a750edb0a1b4d6b1>:0 
  at JudoDotNetXamarin.CardEntryPage..ctor (JudoDotNetXamarin.Judo judo, JudoDotNetXamarin.PaymentDefaultsViewModel defaults) [0x00000] in <56707fd2425b4f29a750edb0a1b4d6b1>:0 
  at JudoDotNetXamarin.PreAuthPage..ctor (JudoDotNetXamarin.Judo judo, JudoDotNetXamarin.PaymentDefaultsViewModel defaults) [0x0000c] in <56707fd2425b4f29a750edb0a1b4d6b1>:0 
  at JudoDotNetXamarin.PreAuthPage..ctor (JudoDotNetXamarin.Judo judo) [0x00007] in <56707fd2425b4f29a750edb0a1b4d6b1>:0 
  at Pockit.Mobile.Core.Future.Features.More.JudoPayDemoView.PreAuth (System.Object sender, System.EventArgs e) [0x00001] in /Users/xleon/Projects/PockitNativeApp/Pockit.Mobile.Core/Future/Features/More/JudoPayDemoView.xaml.cs:72 
  at Xamarin.Forms.Button.Xamarin.Forms.Internals.IButtonElement.PropagateUpClicked () [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Button.cs:166 
  at Xamarin.Forms.ButtonElement.ElementClicked (Xamarin.Forms.VisualElement visualElement, Xamarin.Forms.Internals.IButtonElement ButtonElementManager) [0x0001f] in D:\a\1\s\Xamarin.Forms.Core\ButtonElement.cs:61 
  at Xamarin.Forms.Button.SendClicked () [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Button.cs:152 
  at Xamarin.Forms.Platform.iOS.ButtonElementManager.OnButtonTouchUpInside (Xamarin.Forms.IButtonController element) [0x0000c] in <254f4498a43a4c978801900ce3be4478>:0 
  at Xamarin.Forms.Platform.iOS.ButtonRenderer.OnButtonTouchUpInside (System.Object sender, System.EventArgs eventArgs) [0x00006] in <254f4498a43a4c978801900ce3be4478>:0 
  at UIKit.UIControlEventProxy.Activated () [0x00004] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.8.0.2/src/Xamarin.iOS/UIKit/UIControl.cs:38 
  at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
  at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.8.0.2/src/Xamarin.iOS/UIKit/UIApplication.cs:79 
  at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0002c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.8.0.2/src/Xamarin.iOS/UIKit/UIApplication.cs:63 
  at Pockit.Mobile.Touch.Application.Main (System.String[] args) [0x00022] in /Users/xleon/Projects/PockitNativeApp/Pockit.Mobile.iOS/Main.cs:31 
private readonly Judo _payload = new Judo
        {
            JudoId = JudoId,
            Token = ApiToken,
            Secret = ApiSecret,
            Environment = JudoEnvironment.Sandbox,
            Amount = 0.02m,
            Currency = "GBP",
            MaestroAccepted = true,
            AmexAccepted = true,
            AvsEnabled = true,
            ConsumerReference = "customer-id", 
            MetaData = new Dictionary<string, string> { { "[omitted]", "true" } },
            Theme = new Theme
            {
                PageTitle = "Card details",
                ButtonLabel = "Authorize payment",
                ShowSecurityMessage = true,
                SecurityMessageTextColor = TextColor,
                BackgroundColor = CustomBackgroundColor,
                ButtonBackgroundColor = PockitColor,
                ButtonTextColor = Color.Black,
                PlaceholderTextColor = LabelColor,
                LabelActiveTextColor = LabelColor,
                LabelInactiveTextColor = LabelColor,
                EntryTextColor = TextColor,
                ErrorTextColor = ErrorColor,
                OverlayBackgroundColor = CustomBackgroundColor
            }
        };
xleon commented 5 years ago

This screenshot shows exactly what´s null image

zfoltin commented 5 years ago

It looks as though the JudoDotNetXamariniOSSDK.ClientService hasn't been registered with Xamarin.Forms.DependencyService. Can you check if the required dependencies are registered in AppDelegate.FinishedLaunching? - see https://github.com/Judopay/Xamarin-Sample-App/blob/master/samples/iOS/AppDelegate.cs#L19 and https://github.com/Judopay/Xamarin-Sample-App/wiki/Initializing-the-SDK

xleon commented 5 years ago

Oh no, how could I miss that? It works!