//This sample shows how to push the CVV data requested for a given credit card using Magnetic stripe. //In a real application, it should ask the user in the payment application to type the CVV and then call PushData() method to send it. private static void TransactionOrchestratorOnDataRequested(CollectInputParameters obj) { Console.WriteLine("-------- Transaction OnDataRequested --------"); Console.WriteLine("-------- Reference: " + obj.Reference + " --------"); Console.WriteLine("-------- Message: " + obj.Message + " --------"); switch (obj.Reference) { case "CVV": var cvvResponse = new CollectOutputParameters(); cvvResponse.Reference = obj.Reference; cvvResponse.Value = "123"; _transactionOrchestrator.PushData(cvvResponse); break; case "CVVState": var cvvStateResponse = new CollectOutputParameters(); cvvStateResponse.Reference = obj.Reference; cvvStateResponse.Value = "9"; _transactionOrchestrator.PushData(cvvStateResponse); break; default: break; } }
//Push data when the platform requests, works the same way as in console. //For the sake of this sample, we added here an Android fragment(a popup) that ask the user to enter the CVV when using a Magnetic stripe card. private void TransactionOrchestratorOnDataRequested(CollectInputParameters obj) { try { if (_progressDialog.IsShowing) { _progressDialog.Dismiss(); } switch (obj.Reference) { case "CVV": var cvvDialog = InputDialogFragment.NewInstance(this, "PI", obj.Message, (cvvValue) => { string result = cvvValue == 0 ? "" : cvvValue.ToString(); var cvvParameter = new CollectOutputParameters() { Reference = obj.Reference, Value = result }; _transactionOrchestrator.PushData(cvvParameter); }); cvvDialog.Show(FragmentManager, "fragment_cvv"); break; case "CVVState": var items = new List <string>(); foreach (var item in obj.Options) { items.Add(item.Value); } AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.SetTitle(obj.Message) .SetItems(items.ToArray(), (sender, e) => { var selectedValue = items[e.Which]; foreach (var item in obj.Options) { if (item.Value == selectedValue) { var cvvStateParameter = new CollectOutputParameters() { Reference = obj.Reference, Value = item.Key.ToString() }; _transactionOrchestrator.PushData(cvvStateParameter); break; } } }); dialog = builder.Create(); dialog.Show(); break; default: break; } } catch (Exception ex) { Helpers.Alert(this, "PI - TransactionOrchestratorOnDataRequested - Error", ex.Message, false); } }