예제 #1
0
        public Response ValidateMerchantAccount(Request request)
        {
            string methodName = "ValidateMerchantAccount";

            // Convert request
            ValidateMerchantAccountRequest validateRequest = null;

            try
            {
                validateRequest = ValidateMerchantAccountRequest.ConvertFrom(request);
            }
            catch (SampleException ex)
            {
                return(PaymentUtilities.CreateAndLogResponseForReturn(methodName, this.Name, Platform, locale: request == null ? null : request.Locale, properties: null, errors: ex.Errors));
            }

            // Validate merchant account
            List <PaymentError> errors = new List <PaymentError>();

            ValidateMerchantProperties(validateRequest, errors);
            if (errors.Count > 0)
            {
                return(PaymentUtilities.CreateAndLogResponseForReturn(methodName, this.Name, Platform, validateRequest.Locale, errors));
            }

            // Create response
            var validateResponse = new ValidateMerchantAccountResponse(validateRequest.Locale, validateRequest.ServiceAccountId, this.Name);

            // Convert response and return
            Response response = ValidateMerchantAccountResponse.ConvertTo(validateResponse);

            PaymentUtilities.LogResponseBeforeReturn(methodName, this.Name, Platform, response);
            return(response);
        }
예제 #2
0
        public Response GetMerchantAccountPropertyMetadata(Request request)
        {
            string methodName = "GetMerchantAccountPropertyMetadata";

            // Check null request
            List <PaymentError> errors = new List <PaymentError>();

            if (request == null)
            {
                errors.Add(new PaymentError(ErrorCode.InvalidRequest, "Request is null."));
                return(PaymentUtilities.CreateAndLogResponseForReturn(methodName, this.Name, Platform, locale: null, properties: null, errors: errors));
            }

            // Prepare response
            List <PaymentProperty> properties = new List <PaymentProperty>();
            PaymentProperty        property;

            property = new PaymentProperty(
                GenericNamespace.MerchantAccount,
                MerchantAccountProperties.AssemblyName,
                this.GetAssemblyName());
            property.SetMetadata("Assembly Name:", "The assembly name of the test provider", false, true, 0);
            properties.Add(property);

            Response response = new Response();

            response.Locale     = request.Locale;
            response.Properties = properties.ToArray();
            if (errors.Count > 0)
            {
                response.Errors = errors.ToArray();
            }

            PaymentUtilities.LogResponseBeforeReturn(methodName, this.Name, Platform, response);
            return(response);
        }