public Result <VoidResult> SetPaymentMethods(SetPaymentArgs args) { var result = new Result <VoidResult>(); var model = new VoidResult(); try { result.SetResult(model); var currentCart = this.CartManager.GetCurrentCart( this.StorefrontContext.ShopName, this.VisitorContext.ContactId); if (!currentCart.ServiceProviderResult.Success) { result.SetErrors(currentCart.ServiceProviderResult); return(result); } var updateCartResponse = this.CartManager.UpdateCart( this.StorefrontContext.ShopName, currentCart.Result, new CartBase { Email = string.IsNullOrWhiteSpace(args.BillingAddress.Email) ? this.VisitorContext.CurrentUser.Email : args.BillingAddress.Email }); if (!updateCartResponse.ServiceProviderResult.Success && updateCartResponse.ServiceProviderResult.SystemMessages.Any()) { result.SetErrors(updateCartResponse.ServiceProviderResult); return(result); } var billingParty = this.EntityMapper.MapToPartyEntity(args.BillingAddress); var federatedPaymentArgs = this.EntityMapper.MapToFederatedPaymentArgs(args.FederatedPayment); var paymentInfoResponse = this.CartManager.AddPaymentInfo( this.StorefrontContext.ShopName, updateCartResponse.Result, billingParty, federatedPaymentArgs); if (!paymentInfoResponse.ServiceProviderResult.Success) { result.SetErrors(paymentInfoResponse.ServiceProviderResult); return(result); } } catch (Exception ex) { result.SetErrors(nameof(this.SetPaymentMethods), ex); } return(result); }
public ActionResult SetPaymentMethods(SetPaymentArgs paymentArgs) { var result = this.billingRepository.SetPaymentMethods(paymentArgs); if (result.Success) { return(this.JsonOk(result.Data)); } return(this.JsonError(result.Errors?.ToArray(), HttpStatusCode.InternalServerError, tempData: result.Data)); }