public ActionResult GiftCardList(GridCommand command, GiftCardListModel model) { var gridModel = new GridModel <GiftCardModel>(); bool?isGiftCardActivated = null; if (model.ActivatedId == 1) { isGiftCardActivated = true; } else if (model.ActivatedId == 2) { isGiftCardActivated = false; } var giftCards = _giftCardService.GetAllGiftCards(null, null, null, isGiftCardActivated, model.CouponCode); gridModel.Data = giftCards.PagedForCommand(command).Select(x => { var m = x.ToModel(); m.RemainingAmountStr = _priceFormatter.FormatPrice(x.GetGiftCardRemainingAmount(), true, false); m.AmountStr = _priceFormatter.FormatPrice(x.Amount, true, false); m.CreatedOn = _dateTimeHelper.ConvertToUserTime(x.CreatedOnUtc, DateTimeKind.Utc); return(m); }); gridModel.Total = giftCards.Count(); return(new JsonResult { Data = gridModel }); }
public virtual async Task <(IEnumerable <GiftCardModel> giftCardModels, int totalCount)> PrepareGiftCardModel(GiftCardListModel model, int pageIndex, int pageSize) { bool?isGiftCardActivated = null; if (model.ActivatedId == 1) { isGiftCardActivated = true; } else if (model.ActivatedId == 2) { isGiftCardActivated = false; } var giftCards = await _giftCardService.GetAllGiftCards(isGiftCardActivated : isGiftCardActivated, giftCardCouponCode : model.CouponCode, recipientName : model.RecipientName, pageIndex : pageIndex - 1, pageSize : pageSize); return(giftCards.Select(x => { var m = x.ToModel(); m.RemainingAmountStr = _priceFormatter.FormatPrice(x.GetGiftCardRemainingAmount(), true, false); m.AmountStr = _priceFormatter.FormatPrice(x.Amount, true, false); m.CreatedOn = _dateTimeHelper.ConvertToUserTime(x.CreatedOnUtc, DateTimeKind.Utc); return m; }), giftCards.TotalCount); }
public ActionResult GiftCardList(GridCommand command, GiftCardListModel model) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageGiftCards)) return AccessDeniedView(); bool? isGiftCardActivated = null; if (model.ActivatedId == 1) isGiftCardActivated = true; else if (model.ActivatedId == 2) isGiftCardActivated = false; var giftCards = _giftCardService.GetAllGiftCards(null, null, null, isGiftCardActivated, model.CouponCode); var gridModel = new GridModel<GiftCardModel> { Data = giftCards.PagedForCommand(command).Select(x => { var m = x.ToModel(); m.RemainingAmountStr = _priceFormatter.FormatPrice(x.GetGiftCardRemainingAmount(), true, false); m.AmountStr = _priceFormatter.FormatPrice(x.Amount, true, false); m.CreatedOn = _dateTimeHelper.ConvertToUserTime(x.CreatedOnUtc, DateTimeKind.Utc); return m; }), Total = giftCards.Count() }; return new JsonResult { Data = gridModel }; }
public ActionResult GiftCardList(DataSourceRequest command, GiftCardListModel model) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageGiftCards)) { return(AccessDeniedView()); } bool?isGiftCardActivated = null; if (model.ActivatedId == 1) { isGiftCardActivated = true; } else if (model.ActivatedId == 2) { isGiftCardActivated = false; } var giftCards = _giftCardService.GetAllGiftCards(null, null, null, isGiftCardActivated, model.CouponCode, command.Page - 1, command.PageSize); var gridModel = new DataSourceResult { Data = giftCards.Select(x => { var m = x.ToModel(); m.RemainingAmountStr = _priceFormatter.FormatPrice(x.GetGiftCardRemainingAmount(), true, false); m.AmountStr = _priceFormatter.FormatPrice(x.Amount, true, false); m.CreatedOn = _dateTimeHelper.ConvertToUserTime(x.CreatedOnUtc, DateTimeKind.Utc); return(m); }), Total = giftCards.TotalCount }; return(Json(gridModel)); }
/// <summary> /// Get active gift cards that are applied by a customer /// </summary> /// <param name="customer">Customer</param> /// <returns>Active gift cards</returns> private async Task <IList <GiftCard> > GetActiveGiftCards(Customer customer) { var result = new List <GiftCard>(); if (customer == null) { return(result); } string[] couponCodes = customer.ParseAppliedCouponCodes(SystemCustomerAttributeNames.GiftCardCoupons); foreach (var couponCode in couponCodes) { var giftCards = await _giftCardService.GetAllGiftCards(isGiftCardActivated : true, giftCardCouponCode : couponCode); foreach (var gc in giftCards) { if (gc.IsGiftCardValid()) { result.Add(gc); } } } return(result); }
/// <summary> /// Get active gift cards that are applied by a customer /// </summary> /// <param name="customer">Customer</param> /// <returns>Active gift cards</returns> public static async Task <IList <GiftCard> > GetActiveGiftCardsAppliedByCustomer(this Customer customer, IGiftCardService giftCardService, IGenericAttributeService genericAttributeService) { var result = new List <GiftCard>(); if (customer == null) { return(result); } string[] couponCodes = await customer.ParseAppliedGiftCardCouponCodes(genericAttributeService); foreach (var couponCode in couponCodes) { var giftCards = await giftCardService.GetAllGiftCards(isGiftCardActivated : true, giftCardCouponCode : couponCode); foreach (var gc in giftCards) { if (gc.IsGiftCardValid()) { result.Add(gc); } } } return(result); }
public async Task <bool> Handle(ActivatedValueForPurchasedGiftCardsCommand request, CancellationToken cancellationToken) { if (request.Order == null) { throw new ArgumentNullException("order"); } foreach (var orderItem in request.Order.OrderItems) { var giftCards = await _giftCardService.GetAllGiftCards(purchasedWithOrderItemId : orderItem.Id, isGiftCardActivated : !request.Activate); foreach (var gc in giftCards) { if (request.Activate) { //activate bool isRecipientNotified = gc.IsRecipientNotified; if (gc.GiftCardType == GiftCardType.Virtual) { //send email for virtual gift card if (!String.IsNullOrEmpty(gc.RecipientEmail) && !String.IsNullOrEmpty(gc.SenderEmail)) { var customerLang = await _languageService.GetLanguageById(request.Order.CustomerLanguageId); if (customerLang == null) { customerLang = (await _languageService.GetAllLanguages()).FirstOrDefault(); } if (customerLang == null) { throw new Exception("No languages could be loaded"); } int queuedEmailId = await _workflowMessageService.SendGiftCardNotification(gc, customerLang.Id); if (queuedEmailId > 0) { isRecipientNotified = true; } } } gc.IsGiftCardActivated = true; gc.IsRecipientNotified = isRecipientNotified; await _giftCardService.UpdateGiftCard(gc); } else { //deactivate gc.IsGiftCardActivated = false; await _giftCardService.UpdateGiftCard(gc); } } } return(true); }
public ContentResult GetAllGiftCards() { var data = _giftCardService.GetAllGiftCards(); return(new ContentResult { Content = JsonConvert.SerializeObject(data), ContentType = "application/json" }); }
public virtual IActionResult ApplyGiftCard(string giftcardcouponcode) { //trim if (giftcardcouponcode != null) { giftcardcouponcode = giftcardcouponcode.Trim(); } var cart = _workContext.CurrentCustomer.ShoppingCartItems .Where(sci => sci.ShoppingCartType == ShoppingCartType.ShoppingCart || sci.ShoppingCartType == ShoppingCartType.Auctions) .LimitPerStore(_storeContext.CurrentStore.Id) .ToList(); var model = new ShoppingCartModel(); if (!cart.IsRecurring()) { if (!String.IsNullOrWhiteSpace(giftcardcouponcode)) { var giftCard = _giftCardService.GetAllGiftCards(giftCardCouponCode: giftcardcouponcode).FirstOrDefault(); bool isGiftCardValid = giftCard != null && giftCard.IsGiftCardValid(); if (isGiftCardValid) { _workContext.CurrentCustomer.ApplyGiftCardCouponCode(giftcardcouponcode); model.GiftCardBox.Message = _localizationService.GetResource("ShoppingCart.GiftCardCouponCode.Applied"); model.GiftCardBox.IsApplied = true; } else { model.GiftCardBox.Message = _localizationService.GetResource("ShoppingCart.GiftCardCouponCode.WrongGiftCard"); model.GiftCardBox.IsApplied = false; } } else { model.GiftCardBox.Message = _localizationService.GetResource("ShoppingCart.GiftCardCouponCode.WrongGiftCard"); model.GiftCardBox.IsApplied = false; } } else { model.GiftCardBox.Message = _localizationService.GetResource("ShoppingCart.GiftCardCouponCode.DontWorkWithAutoshipProducts"); model.GiftCardBox.IsApplied = false; } _shoppingCartViewModelService.PrepareShoppingCart(model, cart); return(Json(new { cart = this.RenderViewComponentToString("OrderSummary", new { overriddenModel = model }) })); }
public virtual async Task <IActionResult> ApplyGiftCard(string giftcardcouponcode) { //trim if (giftcardcouponcode != null) { giftcardcouponcode = giftcardcouponcode.Trim(); } var cart = _shoppingCartService.GetShoppingCart(_storeContext.CurrentStore.Id, ShoppingCartType.ShoppingCart, ShoppingCartType.Auctions); var model = new ShoppingCartModel(); if (!cart.IsRecurring()) { if (!String.IsNullOrWhiteSpace(giftcardcouponcode)) { var giftCard = (await _giftCardService.GetAllGiftCards(giftCardCouponCode: giftcardcouponcode)).FirstOrDefault(); bool isGiftCardValid = giftCard != null && giftCard.IsGiftCardValid(); if (isGiftCardValid) { await _workContext.CurrentCustomer.ApplyGiftCardCouponCode(_genericAttributeService, giftcardcouponcode); model.GiftCardBox.Message = _localizationService.GetResource("ShoppingCart.GiftCardCouponCode.Applied"); model.GiftCardBox.IsApplied = true; } else { model.GiftCardBox.Message = _localizationService.GetResource("ShoppingCart.GiftCardCouponCode.WrongGiftCard"); model.GiftCardBox.IsApplied = false; } } else { model.GiftCardBox.Message = _localizationService.GetResource("ShoppingCart.GiftCardCouponCode.Required"); model.GiftCardBox.IsApplied = false; } } else { model.GiftCardBox.Message = _localizationService.GetResource("ShoppingCart.GiftCardCouponCode.DontWorkWithAutoshipProducts"); model.GiftCardBox.IsApplied = false; } await _shoppingCartViewModelService.PrepareShoppingCart(model, cart); return(Json(new { cart = this.RenderViewComponentToString("OrderSummary", new { overriddenModel = model }) })); }
public ActionResult GiftCardList(GridCommand command, GiftCardListModel model) { var gridModel = new GridModel <GiftCardModel>(); if (_services.Permissions.Authorize(StandardPermissionProvider.ManageGiftCards)) { bool?isGiftCardActivated = null; if (model.ActivatedId == 1) { isGiftCardActivated = true; } else if (model.ActivatedId == 2) { isGiftCardActivated = false; } var giftCards = _giftCardService.GetAllGiftCards(null, null, null, isGiftCardActivated, model.CouponCode); gridModel.Data = giftCards.PagedForCommand(command).Select(x => { var m = x.ToModel(); m.RemainingAmountStr = _priceFormatter.FormatPrice(x.GetGiftCardRemainingAmount(), true, false); m.AmountStr = _priceFormatter.FormatPrice(x.Amount, true, false); m.CreatedOn = _dateTimeHelper.ConvertToUserTime(x.CreatedOnUtc, DateTimeKind.Utc); return(m); }); gridModel.Total = giftCards.Count(); } else { gridModel.Data = Enumerable.Empty <GiftCardModel>(); NotifyAccessDenied(); } return(new JsonResult { Data = gridModel }); }
/// <summary> /// Prepare paged gift card list model /// </summary> /// <param name="searchModel">Gift card search model</param> /// <returns>Gift card list model</returns> public virtual GiftCardListModel PrepareGiftCardListModel(GiftCardSearchModel searchModel) { if (searchModel == null) { throw new ArgumentNullException(nameof(searchModel)); } //get parameters to filter gift cards var isActivatedOnly = searchModel.ActivatedId == 0 ? null : searchModel.ActivatedId == 1 ? true : (bool?)false; //get gift cards var giftCards = _giftCardService.GetAllGiftCards(isGiftCardActivated: isActivatedOnly, giftCardCouponCode: searchModel.CouponCode, recipientName: searchModel.RecipientName, pageIndex: searchModel.Page - 1, pageSize: searchModel.PageSize); //prepare list model var model = new GiftCardListModel { Data = giftCards.Select(giftCard => { //fill in model values from the entity var giftCardModel = giftCard.ToModel(); //convert dates to the user time giftCardModel.CreatedOn = _dateTimeHelper.ConvertToUserTime(giftCard.CreatedOnUtc, DateTimeKind.Utc); //fill in additional values (not existing in the entity) giftCardModel.RemainingAmountStr = _priceFormatter.FormatPrice(giftCard.GetGiftCardRemainingAmount(), true, false); giftCardModel.AmountStr = _priceFormatter.FormatPrice(giftCard.Amount, true, false); return(giftCardModel); }), Total = giftCards.TotalCount }; return(model); }
public virtual async Task <(IEnumerable <GiftCardModel> giftCardModels, int totalCount)> PrepareGiftCardModel(GiftCardListModel model, int pageIndex, int pageSize) { bool?isGiftCardActivated = null; if (model.ActivatedId == 1) { isGiftCardActivated = true; } else if (model.ActivatedId == 2) { isGiftCardActivated = false; } var giftCards = await _giftCardService.GetAllGiftCards(isGiftCardActivated : isGiftCardActivated, giftCardCouponCode : model.CouponCode, recipientName : model.RecipientName, pageIndex : pageIndex - 1, pageSize : pageSize); var giftcards = new List <GiftCardModel>(); foreach (var item in giftCards) { var gift = item.ToModel(); var currency = await _currencyService.GetCurrencyByCode(item.CurrencyCode); if (currency == null) { currency = await _currencyService.GetPrimaryStoreCurrency(); } gift.RemainingAmountStr = _priceFormatter.FormatPrice(item.GetGiftCardRemainingAmount(), true, currency, _workContext.WorkingLanguage, true, false); gift.AmountStr = _priceFormatter.FormatPrice(item.Amount, true, currency, _workContext.WorkingLanguage, true, false); gift.CreatedOn = _dateTimeHelper.ConvertToUserTime(item.CreatedOnUtc, DateTimeKind.Utc); giftcards.Add(gift); } return(giftcards, giftCards.TotalCount); }
public void PostProcessPayment(PostProcessPaymentRequest postProcessPaymentRequest) { /* * Dati transazione inviati verso GestPay * Alcuni dei parametri "importanti/principali" per creazione della stringa * "ShopLogin" :VarChar (30) - Obbligatorio - Codice Esercente (Shop Login) * "Currency" :Num (3) - Obbligatorio - Codice Identificativo della divisa per l'importo della transazione * "Amount" :Num (9) - Obbligatorio - [ll separatore delle migliaia non deve essere inserito. I decimali (max 2 cifre) sono opzionali ed il separatore è il punto.] * "ShopTransactionID" :VarChar (50) - Obbligatorio - Identificativo attribuito alla transazione dall'esercente. * "BuyerName" :VarChar (50) - Facoltativo - Nome e cognome dell'acquirente * "BuyerEmail" :VarChar (50) - Facoltativo - Indirizzo e-mail dell'acquirente * "Language" :Num (2) - Facoltativo - Codice che identifica la lingua utilizzata nella comunicazione con l'acquirente (vedi tabella Codici lingua). */ var encryptedString = ""; var errorDescription = ""; var nopBillingAddress = _addressService.GetAddressById(postProcessPaymentRequest.Order.BillingAddressId); var amount = Math.Round(postProcessPaymentRequest.Order.OrderTotal, 2); var shopTransactionId = postProcessPaymentRequest.Order.OrderGuid.ToString(); var buyerName = String.Format( "{0} {1}", nopBillingAddress?.FirstName, nopBillingAddress?.LastName ); var endpoint = _gestPayPaymentSettings.UseSandbox ? EndpointConfiguration.WSCryptDecryptSoap12Test : EndpointConfiguration.WSCryptDecryptSoap12; var objCryptDecrypt = new WSCryptDecryptSoapClient(endpoint); var billingCountry = _countryService.GetCountryById(Convert.ToInt32(nopBillingAddress.CountryId)); var billingStateProvince = _stateProvinceService.GetStateProvinceByAddress(nopBillingAddress); Address nopShippingAddress = null; Country shippingCountry = null; StateProvince shippingStateProvince = null; if (postProcessPaymentRequest.Order.ShippingAddressId != null) { nopShippingAddress = _addressService.GetAddressById((int)postProcessPaymentRequest.Order.ShippingAddressId); shippingCountry = _countryService.GetCountryById((int)nopShippingAddress.CountryId); shippingStateProvince = _stateProvinceService.GetStateProvinceByAddress(nopShippingAddress); } XmlNode xmlResponse; EcommGestpayPaymentDetails paymentDetails = new EcommGestpayPaymentDetails(); if (_gestPayPaymentSettings.EnableGuaranteedPayment) { FraudPrevention fraudPrevention = new FraudPrevention(); fraudPrevention.BeaconSessionID = _httpContextAccessor.HttpContext.Session.Id; fraudPrevention.SubmitForReview = "1"; fraudPrevention.OrderDateTime = postProcessPaymentRequest.Order.CreatedOnUtc.ToString(); fraudPrevention.Source = "desktop_web"; fraudPrevention.SubmissionReason = "rule_decision"; fraudPrevention.VendorName = _storeContext.CurrentStore.Name; paymentDetails.FraudPrevention = fraudPrevention; //var logger = Nop.Core.Infrastructure.EngineContext.Current.Resolve<Nop.Services.Logging.ILogger>(); //logger.Information("Gestpay BeaconId = " + _httpContextAccessor.HttpContext.Session.Id); var customer = _customerService.GetCustomerById(postProcessPaymentRequest.Order.CustomerId); CustomerDetail customerDetail = new CustomerDetail(); customerDetail.PrimaryEmail = nopBillingAddress?.Email; customerDetail.MerchantCustomerID = postProcessPaymentRequest.Order.CustomerId.ToString(); customerDetail.FirstName = nopBillingAddress?.FirstName; customerDetail.Lastname = nopBillingAddress?.LastName; customerDetail.PrimaryPhone = nopBillingAddress?.PhoneNumber; customerDetail.Company = nopBillingAddress?.Company; customerDetail.CreatedAtDate = customer?.CreatedOnUtc.ToString(); customerDetail.VerifiedEmail = "true"; customerDetail.AccountType = "normal"; paymentDetails.CustomerDetail = customerDetail; if (nopShippingAddress != null) { ShippingAddress shippingAddress = new ShippingAddress(); shippingAddress.ProfileID = postProcessPaymentRequest.Order.ShippingAddressId.ToString(); shippingAddress.FirstName = nopShippingAddress.FirstName; shippingAddress.Lastname = nopShippingAddress.LastName; shippingAddress.StreetName = nopShippingAddress.Address1; shippingAddress.Streetname2 = nopShippingAddress.Address2; shippingAddress.City = nopShippingAddress.City; shippingAddress.ZipCode = nopShippingAddress.ZipPostalCode; shippingAddress.State = shippingStateProvince?.Name; shippingAddress.CountryCode = shippingCountry?.TwoLetterIsoCode; shippingAddress.Email = nopShippingAddress.Email; shippingAddress.PrimaryPhone = nopShippingAddress.PhoneNumber; shippingAddress.Company = nopShippingAddress.Company; shippingAddress.StateCode = shippingStateProvince?.Abbreviation; paymentDetails.ShippingAddress = shippingAddress; } BillingAddress billingAddress = new BillingAddress(); billingAddress.ProfileID = postProcessPaymentRequest.Order.BillingAddressId.ToString(); billingAddress.FirstName = nopBillingAddress?.FirstName; billingAddress.Lastname = nopBillingAddress?.LastName; billingAddress.StreetName = nopBillingAddress?.Address1; billingAddress.Streetname2 = nopBillingAddress?.Address2; billingAddress.City = nopBillingAddress?.City; billingAddress.ZipCode = nopBillingAddress?.ZipPostalCode; billingAddress.State = billingStateProvince?.Name; billingAddress.CountryCode = billingCountry?.TwoLetterIsoCode; billingAddress.Email = nopBillingAddress?.Email; billingAddress.PrimaryPhone = nopBillingAddress?.PhoneNumber; billingAddress.Company = nopBillingAddress?.Company; billingAddress.StateCode = billingStateProvince?.Abbreviation; paymentDetails.BillingAddress = billingAddress; var orderItems = _orderService.GetOrderItems(postProcessPaymentRequest.Order.Id); var productDetails = new List <ProductDetail>(); decimal itemsTotalInclTax = 0; foreach (var item in orderItems) { var product = _productService.GetProductById(item.ProductId); if (product != null) { var productDetail = new ProductDetail(); productDetail.ProductCode = product.ManufacturerPartNumber; productDetail.SKU = product.Sku; productDetail.Name = product.Name; productDetail.Description = product.ShortDescription; productDetail.Quantity = item.Quantity.ToString(); productDetail.Price = item.PriceInclTax.ToString("0.00", CultureInfo.InvariantCulture); productDetail.UnitPrice = item.UnitPriceInclTax.ToString("0.00", CultureInfo.InvariantCulture); if ((!product.IsGiftCard && product.IsShipEnabled) || (product.IsGiftCard && product.GiftCardType == Core.Domain.Catalog.GiftCardType.Physical)) { productDetail.Type = "physical"; productDetail.RequiresShipping = "true"; } else { productDetail.Type = "digital"; productDetail.RequiresShipping = "false"; if (product.IsGiftCard) { DigitalGiftCardDetails giftcardDetails = new DigitalGiftCardDetails(); var associatedGiftCards = _giftCardService.GetAllGiftCards(postProcessPaymentRequest.Order.Id); foreach (var giftcard in associatedGiftCards) { giftcardDetails.SenderName = giftcard.SenderName; giftcardDetails.DisplayName = giftcard.SenderName; giftcardDetails.GreetingMessage = giftcard.Message; Recipient recipient = new Recipient(); recipient.Email = giftcard.RecipientEmail; giftcardDetails.Recipient = recipient; break; } productDetail.DigitalGiftCardDetails = giftcardDetails; } } productDetail.Vat = item.PriceInclTax > 0 ? "22" : "0"; productDetail.Condition = "new"; var productManufacturers = _manufacturerService.GetProductManufacturersByProductId(product.Id); productDetail.Brand = _manufacturerService.GetManufacturerById((int)productManufacturers.FirstOrDefault()?.ManufacturerId)?.Name; //productDetail.DeliveryAt = "home"; productDetails.Add(productDetail); itemsTotalInclTax += item.UnitPriceInclTax * item.Quantity; } } paymentDetails.ProductDetails = productDetails.ToArray(); IList <DiscountCode> discountCodes = new List <DiscountCode>(); IList <ShippingLine> shippingLines = new List <ShippingLine>(); // Discount on Sub Total var subTotalDiscountCode = new DiscountCode(); subTotalDiscountCode.Code = "Order subtotal discount"; subTotalDiscountCode.Amount = postProcessPaymentRequest.Order.OrderSubTotalDiscountInclTax.ToString("0.00", CultureInfo.InvariantCulture); discountCodes.Add(subTotalDiscountCode); // Discount on Total var discountCode = new DiscountCode(); discountCode.Code = "Order total discount"; discountCode.Amount = postProcessPaymentRequest.Order.OrderDiscount.ToString("0.00", CultureInfo.InvariantCulture); discountCodes.Add(discountCode); // Shipping var shipping = new ShippingLine(); shipping.Code = postProcessPaymentRequest.Order.ShippingRateComputationMethodSystemName; shipping.Title = postProcessPaymentRequest.Order.ShippingRateComputationMethodSystemName; shipping.Price = postProcessPaymentRequest.Order.OrderShippingInclTax.ToString("0.00", CultureInfo.InvariantCulture); shippingLines.Add(shipping); // Additional Charges / GiftWrap / GiftCard var extraAdjustment = postProcessPaymentRequest.Order.OrderTotal - (itemsTotalInclTax + postProcessPaymentRequest.Order.OrderShippingInclTax - postProcessPaymentRequest.Order.OrderDiscount - postProcessPaymentRequest.Order.OrderSubTotalDiscountInclTax); if (extraAdjustment > 0) { var additionalShipping = new ShippingLine(); additionalShipping.Code = "Additional Charge/Giftwrap"; additionalShipping.Title = "Additional Charge/Giftwrap"; additionalShipping.Price = extraAdjustment.ToString("0.00", CultureInfo.InvariantCulture); shippingLines.Add(additionalShipping); } else { var additionalDiscount = new DiscountCode(); additionalDiscount.Code = "Giftcard/Additional Discount"; additionalDiscount.Amount = (extraAdjustment * -1).ToString("0.00", CultureInfo.InvariantCulture); // * -1 converts into positive number discountCodes.Add(additionalDiscount); } paymentDetails.DiscountCodes = discountCodes.ToArray(); paymentDetails.ShippingLines = shippingLines.ToArray(); } // 3DS var threeDSTransDetails = new ThreeDSEncryptTransDetails(); threeDSTransDetails.type = "EC"; threeDSTransDetails.authenticationAmount = amount.ToString("0.00", CultureInfo.InvariantCulture); var threeDSContainer = new EncryptThreeDsContainer(); threeDSContainer.transTypeReq = "P"; //threeDSContainer.exemption = "SKIP"; As asked by Gestpay Support BuyerDetails buyerDetails = new BuyerDetails(); ThreeDSBillingAddress threeDSBillingAddress = new ThreeDSBillingAddress(); threeDSBillingAddress.line1 = nopBillingAddress?.Address1; threeDSBillingAddress.line2 = nopBillingAddress?.Address2; threeDSBillingAddress.city = nopBillingAddress?.City; threeDSBillingAddress.postCode = nopBillingAddress?.ZipPostalCode; threeDSBillingAddress.state = billingStateProvince?.Name; threeDSBillingAddress.country = billingCountry?.TwoLetterIsoCode; buyerDetails.billingAddress = threeDSBillingAddress; if (nopShippingAddress != null) { ThreeDSShippingAddress threeDSShippingAddress = new ThreeDSShippingAddress(); threeDSShippingAddress.line1 = nopShippingAddress?.Address1; threeDSShippingAddress.line2 = nopShippingAddress?.Address2; threeDSShippingAddress.city = nopShippingAddress?.City; threeDSShippingAddress.postCode = nopShippingAddress?.ZipPostalCode; threeDSShippingAddress.state = shippingStateProvince?.Name; threeDSShippingAddress.country = shippingCountry?.TwoLetterIsoCode; buyerDetails.shippingAddress = threeDSShippingAddress; } buyerDetails.addrMatch = "N"; threeDSContainer.buyerDetails = buyerDetails; threeDSTransDetails.threeDsContainer = threeDSContainer; xmlResponse = objCryptDecrypt.EncryptAsync( _gestPayPaymentSettings.ShopOperatorCode, _gestPayPaymentSettings.CurrencyUiCcode.ToString(), amount.ToString("0.00", CultureInfo.InvariantCulture), shopTransactionId, "", "", "", buyerName, nopBillingAddress.Email, _gestPayPaymentSettings.LanguageCode.ToString(), "", "Order Number = " + postProcessPaymentRequest.Order.CustomOrderNumber, "", "", "", null, null, null, "", null, null, null, null, null, null, "", null, "", "", paymentDetails, _gestPayPaymentSettings.ApiKey, threeDSTransDetails).Result.EncryptResult; XmlDocument xmlReturn = new XmlDocument(); xmlReturn.LoadXml(xmlResponse.OuterXml); string errorCode = xmlReturn.SelectSingleNode("/GestPayCryptDecrypt/ErrorCode")?.InnerText; if (errorCode == "0") { encryptedString = xmlReturn.SelectSingleNode("/GestPayCryptDecrypt/CryptDecryptString")?.InnerText; } else { //Put error handle code HERE errorDescription = xmlReturn.SelectSingleNode("/GestPayCryptDecrypt/ErrorDescription")?.InnerText; } var builder = new StringBuilder(); if (!String.IsNullOrEmpty(encryptedString)) { builder.Append(GetGestPayUrl()); builder.AppendFormat("?a={0}&b={1}", _gestPayPaymentSettings.ShopOperatorCode, encryptedString); } else { //Errore builder.Append(_webHelper.GetStoreLocation(false) + "Plugins/PaymentGestPay/Error"); builder.AppendFormat("?type=0&errc={0}&errd={1}", HttpUtility.UrlEncode(errorCode), HttpUtility.UrlEncode(errorDescription)); } _httpContextAccessor.HttpContext.Response.Redirect(builder.ToString()); }