Beispiel #1
0
        public ValidatePaymentResponse ValidatePaymentResponse(string amountToCharge,
            string provider, string sessionId, List<KeyValue> variables, Account userAccount, string authenticationId, string voucherCode)
        {
            var paymentProvider = PaymentProviderFactory.GetPaymentProvider(provider);
            if (paymentProvider != null)
            {
                var nameValueCollection = new NameValueCollection();

                foreach (var keyValue in variables)
                {
                    nameValueCollection.Add(keyValue.Key, keyValue.Value);
                }
                string error;
                Core.Model.Charge charge;
                var success = paymentProvider.IsValidResponse(decimal.Parse(amountToCharge), nameValueCollection,
                                                              userAccount.ToModel(), voucherCode, out error, out charge);
                if(success && string.IsNullOrEmpty(error))
                {
                    SendPaymentConfirmationMail(sessionId, authenticationId, userAccount);
                }

                return new ValidatePaymentResponse
                           {
                               ErrorMessage = error,
                               IsSuccess = success,
                               Charge = charge.ToDataContract()
                           };

            }
            return new ValidatePaymentResponse { ErrorMessage = "Provider not found.", IsSuccess = false };
        }
Beispiel #2
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;
        }
Beispiel #3
0
        private static void SendPaymentConfirmationMail(string sessionId, string authenticationId, Account userAccount)
        {
            var sessionProvider = SessionProviderFactory.GetSessionProvider();
            string errorMessage;
            var sessionDataResponse = sessionProvider.GetSession(authenticationId, sessionId, out errorMessage);
            if (sessionDataResponse != null)
            {
                var emailProvider = EmailProviderFactory.GetEmailProvider();
                var token = sessionDataResponse.Token;
                var requestId = string.Empty;
                var paxCount = 0;
                var paymentAmount = 0M;
                if (token != null)
                {
                    paxCount = token.PassengersCount;
                    requestId = token.RequestId;
                    paymentAmount = token.PayableAmount;

                }
                else
                {
                    paymentAmount = sessionDataResponse.ToPayAmount;
                    if (sessionDataResponse.Request != null)
                    {
                        requestId = sessionDataResponse.Request.RequestId;
                        if (sessionDataResponse.Request.Passengers != null)
                        {
                            paxCount = sessionDataResponse.Request.Passengers.Count;
                        }
                    }
                }
                emailProvider.SendPaymentConfirmationEmail(requestId, paymentAmount, userAccount.ToModel(), paxCount, sessionDataResponse.PaymentTransaction.InternalReferenceNumber);
            }
        }