コード例 #1
0
ファイル: SecurityBll.cs プロジェクト: vasialek/GiftService
        public PaymentRequestValidationResponse ValidatePosPaymentRequest(PosBdo pos, string posUserUid)
        {
            if (pos.ValidateUrl == null)
            {
                throw new ArgumentNullException("POS does not have ValidateUrl to validate request from it");
            }

            PaymentRequestValidationResponse response = null;

            try
            {
                //var validationUri = new Uri(pos.ValidateUrl.ToString() + posUserUid);
                string url = pos.ValidateUrl.ToString();
                url = url.EndsWith("/") || url.EndsWith("=") ? String.Concat(url, posUserUid) : String.Concat(url, "/", posUserUid);
                var validationUri = new Uri(url);
                Logger.InfoFormat("Validating request payment from POS: `{0}`", validationUri.ToString());
                response = _communicationBll.GetJsonResponse <PaymentRequestValidationResponse>(validationUri);
                if (response == null)
                {
                    throw new BadResponseException("Got NULL response from POS on request validation");
                }

                if (response.RequestedAmountMinor < 1)
                {
                    throw new IncorrectPaymentParamersException("Payment request amount (minor) should be greater than 0");
                }

                if (String.IsNullOrEmpty(response.ProductName))
                {
                    throw new IncorrectPaymentParamersException("Payment request must specify product name");
                }

                ValidateCurrencyCode(response.CurrencyCode, pos);

                // model.Locations = posResponse.Locations ?? new List<ProductServiceLocation>();
                foreach (var l in response.Locations)
                {
                    if (String.IsNullOrEmpty(l.LatLng) == false)
                    {
                        l.LatLngCoordinates = BllFactory.Current.HelperBll.ParseLatLng(l.LatLng, MapTypes.GoogleMap);
                    }
                }

                return(response);
            }
            catch (InvalidCastException icex)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw;
            }
        }
コード例 #2
0
 public void Test_Exception_On_Null_Url()
 {
     _communicationBll.GetJsonResponse <BaseResponse>(null);
 }