public MultiPaymentApiResult(APIResponse apiResponse) { PaymentActions = new List <PaymentAction>(); if (apiResponse.Header.ErrorCode == 0) { ResultMessage = apiResponse.Body.CardHolderErrorMessage; if (!String.IsNullOrEmpty(apiResponse.Body.Result)) { Result = (Result)Enum.Parse(typeof(Result), apiResponse.Body.Result, true); } if (apiResponse.Body.Actions != null) { foreach (AltaPay.Service.Dto.Action action in apiResponse.Body.Actions) { PaymentActions.Add(PaymentAction.FromAction(action)); } } } else { Result = Result.SystemError; ResultMessage = "An error occurred"; } }
public static PaymentAction FromAction(AltaPay.Service.Dto.Action action) { var paymentAction = new PaymentAction(); paymentAction.Result = (Result)Enum.Parse(typeof(Result), action.Result, true); if (!String.IsNullOrEmpty(action.CardHolderErrorMessage)) { paymentAction.CardHolderErrorMessage = action.CardHolderErrorMessage; } if (!String.IsNullOrEmpty(action.MerchantErrorMessage)) { paymentAction.MerchantErrorMessage = action.MerchantErrorMessage; } if (action.Transactions != null && action.Transactions.Length > 0) { paymentAction.Payment = action.Transactions[0]; } return(paymentAction); }