/// <summary> /// Gets the string value of a payment property. /// </summary> /// <param name="propertyHashtable">The property hashtable.</param> /// <param name="propertyNamespace">The namespace.</param> /// <param name="propertyName">The name.</param> /// <param name="required">The flag indicating whether the property is required.</param> /// <param name="errors">The error list in case the property is required but not found.</param> /// <returns>The string value.</returns> private static string GetPropertyStringValue(Dictionary <string, object> propertyHashtable, string propertyNamespace, string propertyName, bool required, List <PaymentError> errors) { string propertyValue; bool found = PaymentProperty.GetPropertyValue( propertyHashtable, propertyNamespace, propertyName, out propertyValue); if (!found && required) { var error = new PaymentError(ErrorCode.InvalidRequest, string.Format(CultureInfo.InvariantCulture, "Property '{0}' is null or not set", propertyName)); errors.Add(error); } return(propertyValue); }
/// <summary> /// Validates the merchant account. /// </summary> /// <param name="request">The request.</param> /// <param name="errors">The error list to add any validation errors.</param> private static void ValidateMerchantAccount(Request request, List <PaymentError> errors) { var processor = new SampleConnector(); // Prepare a request for validating merchant account var validateMerchantAccountRequest = new Request(); validateMerchantAccountRequest.Locale = request.Locale; var validateMerchantAccountRequestPropertyList = new List <PaymentProperty>(); foreach (var paymentProperty in request.Properties) { if (paymentProperty.Namespace == GenericNamespace.MerchantAccount) { validateMerchantAccountRequestPropertyList.Add(paymentProperty); } } validateMerchantAccountRequest.Properties = validateMerchantAccountRequestPropertyList.ToArray(); // Validates the merchant account by calling the payment processor Response validateMerchantAccountResponse = processor.ValidateMerchantAccount(validateMerchantAccountRequest); if (validateMerchantAccountResponse != null) { if (validateMerchantAccountResponse.Errors != null) { errors.AddRange(validateMerchantAccountResponse.Errors); } } else { var error = new PaymentError(ErrorCode.InvalidMerchantConfiguration, "Merchant configuraiton is invalid."); errors.Add(error); } }