private static Error callback(Mpos mpos, int amount, IEnumerable <EmvApplication> applications, PaymentMethod magstripePaymentMethod, TaskCompletionSource <PaymentResult> source)
        {
            var callback = MposPaymentCallback.Callback(mpos, source);

            var acquirers    = new List <Acquirer>();
            var riskProfiles = new List <RiskManagement>();

            var rawApplications = new List <Application>();

            if (applications != null)
            {
                foreach (var application in applications)
                {
                    var entries = mpos.TMSStorage.SelectApplication(application.Brand, (int)application.PaymentMethod);

                    entries.ToList().ForEach(a =>
                    {
                        rawApplications.Add(new Application(a));
                    }
                                             );
                }
            }
            else
            {
                foreach (var entry in mpos.TMSStorage.GetApplicationRows())
                {
                    rawApplications.Add(new Application(entry));
                }
            }

            foreach (var entry in mpos.TMSStorage.GetAcquirerRows())
            {
                acquirers.Add(new Acquirer(entry));
            }

            foreach (var entry in mpos.TMSStorage.GetRiskManagementRows())
            {
                riskProfiles.Add(new RiskManagement(entry));
            }

            var error = ProcessPayment(mpos.nativeMpos, amount, rawApplications.ToArray(), rawApplications.Count,
                                       acquirers.ToArray(), acquirers.Count, riskProfiles.ToArray(), riskProfiles.Count,
                                       (int)magstripePaymentMethod, callback);

            if (error != Error.Ok)
            {
                throw new MposException(error);
            }

            return(Error.Ok);
        }
Exemple #2
0
        public static Native.MposPaymentCallbackDelegate Callback(Mpos mpos, TaskCompletionSource <PaymentResult> source)
        {
            return(GCHelper.ManualFree <Native.MposPaymentCallbackDelegate>(releaseGC =>
            {
                return (mposPtr, err, info) =>
                {
                    releaseGC();

                    var instance = new MposPaymentCallback();
                    instance.info = info;

                    return instance.handleResult(mpos, source, err);
                };
            }));
        }