示例#1
0
 /// <summary>
 /// Inserts the g2s response.
 /// </summary>
 /// <param name="g2SResponseModel">The invoice model.</param>
 /// <returns>returns int of the inserted row</returns>
 public long InsertG2SResponse(G2SResponseModel g2SResponseModel)
 {
     try
     {
         G2SResponse g2SResponse = this.mapperFactory.GetMapper<G2SResponseModel, G2SResponse>().Map(g2SResponseModel);
         g2SResponse.CreatedOn = DateTime.UtcNow;
         this.g2SResponseRepository.Insert(g2SResponse);
         this.g2SResponseRepository.Commit();
         return g2SResponse.Id;
     }
     catch (Exception ex)
     {
         return 0;
     }
 }
示例#2
0
        public async Task<IHttpActionResult> G2SPending()
        {
            G2SResponseModel response = new G2SResponseModel();
            try
            {
                response = this.FillG2SResponse(Request.RequestUri.Query);
                try
                {
                    this.UpdateInvoice(Convert.ToInt64(response.InvoiceId), InvoiceStatus.Pending);
                }
                catch (Exception ex)
                {
                    this.LoggerService.LogException("PaymentController > G2SPending(while updating invoice): " + ex.StackTrace);
                }

                this.paymentService.InsertG2SResponse(response);
            }
            catch (Exception ex)
            {
                this.LoggerService.LogException("PaymentController > G2SPending(while filling or inserting response): " + ex.StackTrace);
            }

            return this.Redirect(AppSettings.Get<string>("site_payment_url").ToString() + "?status=pending");
        }
示例#3
0
 /// <summary>
 /// Fills the g2s response.
 /// </summary>
 /// <param name="query">The query.</param>
 /// <returns>G2S Response Model.</returns>
 private G2SResponseModel FillG2SResponse(string query)
 {
     G2SResponseModel response = new G2SResponseModel();
     response.PPPStatus = HttpUtility.ParseQueryString(query).Get("ppp_status");
     response.CardCompany = HttpUtility.ParseQueryString(query).Get("cardCompany");
     response.NameOnCard = HttpUtility.ParseQueryString(query).Get("nameOnCard");
     response.FirstName = HttpUtility.ParseQueryString(query).Get("first_name");
     response.LastName = HttpUtility.ParseQueryString(query).Get("last_name");
     response.Address = HttpUtility.ParseQueryString(query).Get("address1");
     response.City = HttpUtility.ParseQueryString(query).Get("city");
     response.Country = HttpUtility.ParseQueryString(query).Get("country");
     response.Email = HttpUtility.ParseQueryString(query).Get("email");
     response.State = HttpUtility.ParseQueryString(query).Get("state");
     response.Zip = HttpUtility.ParseQueryString(query).Get("zip");
     response.Phone = HttpUtility.ParseQueryString(query).Get("phone1");
     response.Currency = HttpUtility.ParseQueryString(query).Get("currency");
     response.UserId = HttpUtility.ParseQueryString(query).Get("customField1");
     response.Interest = HttpUtility.ParseQueryString(query).Get("customField2");
     response.CompanyId = HttpUtility.ParseQueryString(query).Get("customField3");
     response.MerchantSiteId = HttpUtility.ParseQueryString(query).Get("merchant_site_id");
     response.MerchantId = HttpUtility.ParseQueryString(query).Get("merchant_id");
     response.MerchantLocale = HttpUtility.ParseQueryString(query).Get("merchantLocale");
     response.RequestVersion = HttpUtility.ParseQueryString(query).Get("requestVersion");
     response.PPPTransactionID = HttpUtility.ParseQueryString(query).Get("PPP_TransactionID");
     response.ProductId = HttpUtility.ParseQueryString(query).Get("productId");
     response.CustomData = HttpUtility.ParseQueryString(query).Get("customData");
     response.PaymentMethod = HttpUtility.ParseQueryString(query).Get("payment_method");
     response.InvoiceId = HttpUtility.ParseQueryString(query).Get("invoice_id");
     response.ResponseTimeStamp = HttpUtility.ParseQueryString(query).Get("responseTimeStamp");
     response.Message = HttpUtility.ParseQueryString(query).Get("message");
     response.Error = HttpUtility.ParseQueryString(query).Get("Error");
     response.Status = HttpUtility.ParseQueryString(query).Get("Status");
     response.ExErrCode = HttpUtility.ParseQueryString(query).Get("ExErrCode");
     response.ErrCode = HttpUtility.ParseQueryString(query).Get("ErrCode");
     response.AuthCode = HttpUtility.ParseQueryString(query).Get("AuthCode");
     response.ReasonCode = HttpUtility.ParseQueryString(query).Get("ReasonCode");
     response.Token = HttpUtility.ParseQueryString(query).Get("Token");
     response.TokenId = HttpUtility.ParseQueryString(query).Get("tokenId");
     response.ResponseChecksum = HttpUtility.ParseQueryString(query).Get("responsechecksum");
     response.AdvanceResponseChecksum = HttpUtility.ParseQueryString(query).Get("advanceResponseChecksum");
     response.TotalAmount = HttpUtility.ParseQueryString(query).Get("totalAmount");
     response.TransactionID = HttpUtility.ParseQueryString(query).Get("TransactionID");
     response.DynamicDescriptor = HttpUtility.ParseQueryString(query).Get("dynamicDescriptor");
     response.UniqueCC = HttpUtility.ParseQueryString(query).Get("uniqueCC");
     response.ItemNumber = HttpUtility.ParseQueryString(query).Get("item_number_1");
     response.ItemAmount = HttpUtility.ParseQueryString(query).Get("item_amount_1");
     response.ItemQuantity = HttpUtility.ParseQueryString(query).Get("item_quantity_1");
     response.IsValid = this.IsChecksumValid(response.TotalAmount, response.Currency, response.ResponseTimeStamp, response.PPPTransactionID, response.Status, response.ProductId, response.ResponseChecksum, response.AdvanceResponseChecksum);
     return response;
 }
示例#4
0
        public async Task<IHttpActionResult> G2SSuccess()
        {
            G2SResponseModel response = new G2SResponseModel();
            try
            {
                response = this.FillG2SResponse(Request.RequestUri.Query);
                try
                {
                    this.UpdateInvoice(Convert.ToInt64(response.InvoiceId), InvoiceStatus.Success);
                }
                catch (Exception ex)
                {
                    this.LoggerService.LogException("PaymentController > G2SSuccess(while updating invoice): " + ex.StackTrace);
                }

                this.paymentService.InsertG2SResponse(response);
            }
            catch (Exception ex)
            {
                this.LoggerService.LogException("PaymentController > G2SSuccess(while filling or inserting response): " + ex.StackTrace);
                response.UserId = HttpUtility.ParseQueryString(Request.RequestUri.Query).Get("customField1");
                response.Interest = HttpUtility.ParseQueryString(Request.RequestUri.Query).Get("customField2");
                response.CompanyId = HttpUtility.ParseQueryString(Request.RequestUri.Query).Get("customField3");
            }

            try
            {
                bool isSuccess = true;
                decimal price = AppSettings.Get<decimal>(ConfigConstants.UserPrice);

                BuyUserModelDto buyUserModelDto = new BuyUserModelDto { CompanyId = response.CompanyId, UserId = response.UserId, Interest = response.Interest, Amount = price, PurchasedFromCash = false, PurchasedFromCredit = false };
                isSuccess = this.crmManagerService.AddOpportunity(buyUserModelDto);
            }
            catch (Exception ex)
            {
                this.LoggerService.LogException("PaymentController > G2SSuccess(while updating system for who purchased what): " + ex.StackTrace);
            }

            return this.Redirect(AppSettings.Get<string>("site_payment_url").ToString() + "?status=success");
        }