Example #1
0
        public virtual IGatewayResponse Send(IGatewayRequest request, string description)
        {
            var serviceUrl = TEST_URL;

            if (!string.IsNullOrEmpty(_customUrl))
            {
                serviceUrl = _customUrl;
            }
            else if (!TestMode)
            {
                serviceUrl = LIVE_URL;
            }

            LoadAuthorization(request);
            if (String.IsNullOrEmpty(request.Description))
            {
                request.Queue(ApiFields.Description, description);
            }
#if debug
            request.DuplicateWindow = "0";
#endif
            var response = SendRequest(serviceUrl, request);

            return(DecideResponse(response.Split('|')));
        }
Example #2
0
        public IGatewayResponse Send(IGatewayRequest request, string description)
        {
            var serviceUrl = TEST_URL;

            if (!TestMode)
            {
                serviceUrl = LIVE_URL;
            }

            request.Queue(ApiFields.ApiLogin, ApiLogin);
            request.Queue(ApiFields.TransactionKey, TransactionKey);
            request.Queue(ApiFields.Description, description);
            //validate the inputs
            Validate(request);
            var result   = "";
            var postData = request.ToPostString();

            //override the local cert policy
            ServicePointManager.CertificatePolicy = new PolicyOverride();

            var webRequest = (HttpWebRequest)WebRequest.Create(serviceUrl);

            webRequest.Method        = "POST";
            webRequest.ContentLength = postData.Length;
            webRequest.ContentType   = "application/x-www-form-urlencoded";

            // post data is sent as a stream
            StreamWriter myWriter = null;

            myWriter = new StreamWriter(webRequest.GetRequestStream());
            myWriter.Write(postData);
            myWriter.Close();

            // returned values are returned as a stream, then read into a string
            var response = (HttpWebResponse)webRequest.GetResponse();

            using (StreamReader responseStream = new StreamReader(response.GetResponseStream())) {
                result = responseStream.ReadToEnd();
                responseStream.Close();
            }

            // the response string is broken into an array
            // The split character specified here must match the delimiting character specified above
            var response_array = result.Split('|');

            return(DecideResponse(response_array));
        }
        /// <summary>
        /// Loops the form request and pushes the data into the request, if preset.
        /// </summary>
        static void SerializeForm(IGatewayRequest request, NameValueCollection collection)
        {
            var api = new ApiFields ();
            foreach (string item in collection.Keys) {

                //always send the keys to the API - this allows for Merchant Custom Keys
                request.Queue(item, collection[item]);
            }
        }
Example #4
0
        /// <summary>
        /// Sends the specified request.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <param name="description">The description.</param>
        /// <returns></returns>
        public override IGatewayResponse Send(IGatewayRequest request, string description)
        {
            var device = (int)_deviceType;

            //make sure to send in the API version
            request.Queue("x_cpversion", "1.0");
            request.Queue("x_market_type", _marketType);
            request.Queue("x_device_type", device.ToString());
            request.Queue("x_response_format", "1");

            LoadAuthorization(request);
            request.Queue(ApiFields.Description, description);

            var response = SendRequest(_serviceUrl, request);


            return(new CardPresentResponse(response.Split('|')));
        }
        /// <summary>
        /// Loops the form request and pushes the data into the request, if preset.
        /// </summary>
        static void SerializeForm(IGatewayRequest request, NameValueCollection collection)
        {
            var api = new ApiFields();

            foreach (string item in collection.Keys)
            {
                //always send the keys to the API - this allows for Merchant Custom Keys
                request.Queue(item, collection[item]);
            }
        }
Example #6
0
        public virtual IGatewayResponse Send(IGatewayRequest request, string description)
        {
            var serviceUrl = TEST_URL;

            if (!TestMode)
            {
                serviceUrl = LIVE_URL;
            }

            LoadAuthorization(request);
            request.Queue(ApiFields.Description, description);

            var response = SendRequest(serviceUrl, request);

            return(DecideResponse(response.Split('|')));
        }
Example #7
0
        public virtual IGatewayResponse Send(IGatewayRequest request, string description)
        {
            string serviceUrl = "https://test.authorize.net/gateway/transact.dll";

            if (!this.TestMode)
            {
                serviceUrl = "https://secure.authorize.net/gateway/transact.dll";
            }
            this.LoadAuthorization(request);
            if (string.IsNullOrEmpty(request.Description))
            {
                request.Queue("x_description", description);
            }
            return(this.DecideResponse(this.SendRequest(serviceUrl, request).Split(new char[1]
            {
                '|'
            })));
        }
Example #8
0
 protected void LoadAuthorization(IGatewayRequest request)
 {
     request.Queue(ApiFields.ApiLogin, ApiLogin);
     request.Queue(ApiFields.TransactionKey, TransactionKey);
 }
Example #9
0
		public virtual IGatewayResponse Send (IGatewayRequest request, string description)
		{

            var serviceUrl = TEST_URL;
            if (!TestMode)
                serviceUrl = LIVE_URL;

            LoadAuthorization(request);
            if(String.IsNullOrEmpty(request.Description))
                request.Queue(ApiFields.Description, description);
#if debug          
            request.DuplicateWindow = "0";
#endif            
            var response = SendRequest(serviceUrl, request);

            return DecideResponse(response.Split('|'));
		}
Example #10
0
 protected void LoadAuthorization(IGatewayRequest request) {
     request.Queue(ApiFields.ApiLogin, ApiLogin);
     request.Queue(ApiFields.TransactionKey, TransactionKey);
 }
Example #11
0
        /// <summary>
        /// Sends the specified request.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <param name="description">The description.</param>
        /// <returns></returns>
        public override IGatewayResponse Send(IGatewayRequest request, string description) {

            var device = (int)_deviceType;
            //make sure to send in the API version
            request.Queue("x_cpversion", "1.0");
            request.Queue("x_market_type", _marketType);
            request.Queue("x_device_type", device.ToString());
            request.Queue("x_response_format", "1");

            LoadAuthorization(request);
            request.Queue(ApiFields.Description, description);

            //make sure this is empty
            request.RelayResponse = "";

            var response = SendRequest(_serviceUrl, request);


            return new CardPresentResponse(response.Split('|'));
        }
Example #12
0
 protected void LoadAuthorization(IGatewayRequest request)
 {
     request.Queue("x_login", this.ApiLogin);
     request.Queue("x_tran_key", this.TransactionKey);
 }