private void OnMsrDataEvent(int status) { if (this.MsrSwipeEvent != null) { var swipeInfo = new MagneticCardSwipeInfo(); swipeInfo.ParseTracks(this.oposMsr.Track1Data, this.oposMsr.Track2Data); // Store the account number in the temporary storage and mask the accout number only if it's the payment card. if (swipeInfo.IsPaymentCard) { // Store the swipe info into the temporary memory storage. var temporaryMemoryManager = new TemporaryMemoryManager <string, string>(); temporaryMemoryManager.AddCardInfoToMemory(MagneticCardSwipeInfo.MsrCardKey, swipeInfo.AccountNumber, DateTime.UtcNow, swipeInfo.AccountNumber); // Mask the account number using mask chars. string maskedAccountNumber = Utilities.GetMaskedCardNumber(swipeInfo.AccountNumber); swipeInfo.AccountNumber = maskedAccountNumber; } this.MsrSwipeEvent(this, swipeInfo); } // This should not be required since the auto disable is set to false // but apparently some Msrs require this explictly enabled // every time. this.oposMsr.DataEventEnabled = true; }
public async Task <MagneticCardSwipeInfo> GetMsrSwipeInfo(MsrRequest request) { var device = LockManager.GetPeripheral <IRamblerStripeReader>(request.Token); try { ThrowIf.Null(request, "request"); device.Open(string.Empty, null); var eventCompletionSource = new TaskCompletionSource <RamblerMagneticStripeCardData>(); EventHandler <RamblerMagneticStripeCardData> handler = null; handler = (sender, args) => { eventCompletionSource.SetResult(args); device.RamblerCardSwipeEvent -= handler; }; device.RamblerCardSwipeEvent += handler; MagneticCardSwipeInfo swipeInfo = null; if (Task.WaitAny(eventCompletionSource.Task, Task.Delay(request.TimeoutInSeconds * 1000)) == 0) { swipeInfo = await eventCompletionSource.Task; } return(swipeInfo); } finally { device.Close(); } }