Exemplo n.º 1
0
        public string GetPostData(string transactionId, string toChargeAmount, string productInfo, string sessionId,
            Account userAccount, Address contactAddress, string voucherCode)
        {
            IPaymentProvider paymentProvider = PaymentProviderFactory.GetPaymentProvider();

            if (paymentProvider != null)
            {
                return paymentProvider.GetPostData(transactionId, decimal.Parse(toChargeAmount), productInfo,
                                                   userAccount.ToModel(), contactAddress.ToModel(), voucherCode);
            }
            return string.Empty;
        }
Exemplo n.º 2
0
        public string GetPostData(string authenticationId, string sessionId, Address contactAddress)
        {
            ISessionService sessionService = new SessionService();

            var sessionDataResponse = sessionService.GetSessionData(authenticationId, sessionId);
            if (sessionDataResponse == null || string.IsNullOrEmpty(sessionDataResponse.ErrorMessage) == false || sessionDataResponse.SessionData == null)
                return string.Empty;

            var loginService = new LoginService();
            GetAccountResponse getAccountResponse = loginService.GetAccount(sessionId, authenticationId);
            if (getAccountResponse == null || getAccountResponse.UserAccount == null)
                return string.Empty;

            var userAccount = getAccountResponse.UserAccount;

            using (new ApplicationContextScope(new ApplicationContext()))
            {
                ApplicationContext.Current.Items["SessionId"] = sessionId;
                try
                {
                    var channelFactory =
                        new WebChannelFactory<IPaymentServiceRest>(Configuration.PaymentServiceConfigurationName);
                    IPaymentServiceRest channel = channelFactory.CreateChannel();

                    if (channel is IContextChannel)
                        using (new OperationContextScope(channel as IContextChannel))
                        {
                            var referenceNumber = Guid.NewGuid().ToString().Substring(10);
                            var voucherCode = string.Empty;
                            if (sessionDataResponse.SessionData.PaymentTransaction != null)
                            {
                                referenceNumber =
                                    sessionDataResponse.SessionData.PaymentTransaction.InternalReferenceNumber;
                            }
                            voucherCode = sessionDataResponse.SessionData.VoucherCode;

                            WebOperationContext.Current.OutgoingRequest.Headers.Add("X-MethodName", "GetPostData");
                            return channel.GetPostData(referenceNumber,
                                                       sessionDataResponse.SessionData.ToPayAmount.ToString(),
                                                       "Air", sessionId, userAccount, contactAddress, voucherCode);
                        }
                }
                catch (Exception exception)
                {
                    Logger.LogException(exception, Source, "GetPostData", Severity.Critical);
                }
            }
            return null;
        }