Beispiel #1
0
        private MobicomMessage LogRegisterResponse(MobicomRegisterResponse response)
        {
            var logEntry = _storage.MobicomMessages.CreateObject();

            logEntry.Id                = Guid.NewGuid();
            logEntry.CreateTime        = DateTime.Now;
            logEntry.Method            = "MobicomRegisterRequestOperation";
            logEntry.Action            = "Request";
            logEntry.AgreagatorId      = Truncate(response.Agregator.id.ToString(), 10);
            logEntry.MerchantId        = Truncate(response.Merchant.id.ToString(), 10);
            logEntry.OwnerId           = Truncate(response.Owner.id, 50);
            logEntry.ClientPhoneNumber = Truncate(response.Client.Phone.number, 10);
            logEntry.PaymentAmount     = Truncate(response.Payment.amount.ToString(), 10);
            logEntry.PaymentCurrency   = Truncate(response.Payment.currency.ToString(), 3);
            logEntry.TransactionId     = Truncate(response.Transaction.id, 50);
            logEntry.MessageComment    = Truncate(response.Message.comment, 50);
            logEntry.ResultCode        = Truncate(response.Result.code.ToString(), 10);
            logEntry.ResultComment     = Truncate(response.Result.comment, 255);
            logEntry.Version           = Truncate(response.version, 10);
            //logEntry.Hash = Truncate(response.hash, 50);

            _storage.MobicomMessages.AddObject(logEntry);

            return(logEntry);
        }
Beispiel #2
0
        private MobicomRegisterResponse MobicomRegisterRequestOperation(MobicomRegisterRequest request)
        {
            Trace.WriteLine("Phone:" + request.Client.Phone + " Number:" + request.Payment.result);

            var response = new MobicomRegisterResponse();

            response.Result.code    = 1;
            response.Result.comment = "";

            try
            {
                var initialRequest = LogRegisterRequest(request);

                if (request.Owner.id == null)
                {
                    return(response);
                }

                var payment = _storage.Payments.SingleOrDefault(p => p.OwnerId == request.Owner.id);

                if (payment == null)
                {
                    return(response);
                }

                if (!request.CheckHashCode(payment.Partner.Password))
                {
                    return(response);
                }

                payment.Status = GetOrCreateStatus(request.Payment.result, payment.ProviderCode);

                response.Agregator.id        = payment.Merchant.Bank.AgregarorId;
                response.Merchant.id         = payment.Merchant.Code;
                response.Owner.id            = payment.OwnerId;
                response.Client.Phone.number = payment.PaymentNumber;
                response.Payment.amount      = payment.Amount;
                response.Payment.currency    = payment.Currency;
                response.Transaction.id      = request.Transaction.id;
                response.Message.comment     = payment.SMSComment;

                NotifyPartner(payment);
                LogRegisterResponse(response);
            }
            catch (Exception e)
            {
                Trace.WriteLine("Ошибка при получении статуса платежа: " + e);
                response.Result.code    = 1;
                response.Result.comment = "";
                throw;
            }
            finally
            {
                TrySaveChanges();
            }
            return(response);
        }