public void CancelDiscover() { _discoveryCancelable?.Cancel((NSError e) => { // Do Nothing }); _discoveryCancelable = null; _discoveredReaders.Clear(); }
public void DiscoverReaders(StripeDiscoveryConfiguration config, Action <IList <StripeTerminalReader> > readers, Action scanTimeoutCallback) { try { var deviceType = SCPDeviceType.Chipper2X; switch (config.DeviceType) { case "Chipper2X": deviceType = SCPDeviceType.Chipper2X; break; case "VerifoneP400": deviceType = SCPDeviceType.VerifoneP400; break; case "WisePad3": deviceType = SCPDeviceType.WisePad3; break; } var disocveryMethod = SCPDiscoveryMethod.BluetoothScan; switch (config.DiscoveyMethod) { case "BluetoothScan": disocveryMethod = SCPDiscoveryMethod.BluetoothScan; break; case "BluetoothProximity": disocveryMethod = SCPDiscoveryMethod.BluetoothProximity; break; case "Internet": disocveryMethod = SCPDiscoveryMethod.BluetoothProximity; break; } var configuration = new SCPDiscoveryConfiguration(deviceType, disocveryMethod, config.IsSimulated) { Timeout = (nuint)config.TimeOut, }; _onReadersDiscoveredAction = readers; _discoveryCancelable?.Cancel((NSError e) => { // Notify Something }); _discoveryCancelable = SCPTerminal.Shared?.DiscoverReaders(configuration, this, (NSError e) => { // Do Nothing... scanTimeoutCallback?.Invoke(); }); } catch (Exception e) { throw e; } }
public void RetreivePaymentIntent(string clientSecret, Action <string> onSuccess, Action <string> onFailure) { SCPTerminal.Shared.RetrievePaymentIntent(clientSecret, (SCPPaymentIntent intentToCapture, NSError retreiveError) => { if (retreiveError != null) { onFailure?.Invoke(retreiveError?.LocalizedDescription); } else { _cancelable = SCPTerminal.Shared?.CollectPaymentMethod(intentToCapture, new TerminalServiceReaderDisplay(ReaderNotifyHandler), (SCPPaymentIntent capturedIntent, NSError collectError) => { if (collectError != null) { _cancelable = null; onFailure?.Invoke(collectError?.LocalizedDescription); } else { ReaderNotifyHandler("Authorizing Payment"); SCPTerminal.Shared?.ProcessPayment(capturedIntent, (SCPPaymentIntent approvedIntent, SCPProcessPaymentError paymentError) => { if (paymentError != null) { _cancelable = null; onFailure?.Invoke(paymentError?.LocalizedDescription); } else { if (approvedIntent != null && string.IsNullOrEmpty(approvedIntent?.StripeId) == false && approvedIntent?.Status == SCPPaymentIntentStatus.RequiresCapture) { var paymentMethodId = approvedIntent?.OriginalJSON["payment_method"]?.ToString() ?? string.Empty; _cancelable = null; onSuccess?.Invoke(paymentMethodId); } else { var errorMessage = approvedIntent == null ? "No payment intent was found" : "You payment is in an invalid state try the checkout process again: " + approvedIntent?.Status.ToString(); _cancelable = null; onFailure?.Invoke(errorMessage); } } }); } }); } }); }
public override void DidUpdateDiscoveredReaders(SCPTerminal terminal, SCPReader[] readers) { if (readers.Any()) { var stripeReaders = new List <StripeTerminalReader>(); foreach (var reader in readers) { stripeReaders.Add(new StripeTerminalReader { IsSimulated = reader?.Simulated ?? false, SerialNumber = reader?.SerialNumber, SoftwareVersion = reader?.DeviceSoftwareVersion, BatteryLevel = reader?.BatteryLevel?.FloatValue ?? 0 }); } _discoveredReaders.AddRange(readers); _onReadersDiscoveredAction?.Invoke(stripeReaders); _discoveryCancelable = null; } }