public void InitMessageFields()
		{
			PaymentInitMessage pipe = new PaymentInitMessage(
			    id:"id",
 			   	password: "******",
 			    action: RequiredAction.Authorization,
 			    currency: 978,
 			   	language: RequiredLanguage.ITA,
 			   	responseURL: new Uri("http://www.mioserver.it/responseurl"),
 			    errorURL: new Uri("http://www.mioserver.it/errorurl"),
 			   	amount: 33.33, 
 			    trackId: "trackId",
 			    udf1: "details");
			
			Assert.AreEqual("password", pipe.Password);
			Assert.AreEqual("id", pipe.Id);
			Assert.AreEqual(RequiredAction.Authorization, pipe.RequiredAction);
			Assert.AreEqual(978, pipe.Currency);
			Assert.AreEqual(RequiredLanguage.ITA, pipe.Language);
			Assert.AreEqual(new Uri("http://www.mioserver.it/responseurl"), pipe.ResponseURL);
			Assert.AreEqual(new Uri("http://www.mioserver.it/errorurl"), pipe.ErrorURL);
			Assert.AreEqual(33.33, pipe.Amount);
			Assert.AreEqual("trackId", pipe.TrackId);
			Assert.AreEqual("details", pipe.Udf1);					
		}
Exemplo n.º 2
0
		/// <summary>
		/// sends a payment initialization message to the payment gateway
		/// </summary>
		/// <param name="initMessage">instance of PaymentInitMessage that wraps the
		/// details for the requested operation</param>
		/// <param name="timeout">After this time (in milliseconds), the method will stop waiting for an
		/// answer from the payment gateway. It's an optional parameter.Default 5000 milliseconds.</param>
		/// <returns>PaymentDetails for the requested operation</returns>
		/// <exception cref="e24PaymentPipe.Exceptions.BadResponseFromWebServiceException"></exception>
		public PaymentDetails PerformPaymentInitialization(PaymentInitMessage initMessage, int timeout=5000)
		{
			if(initMessage==null) throw new ArgumentNullException("initMessage");

			Uri url=BuildUrl("PaymentInitHTTPServlet");
			
			string response = sendMessage(url,initMessage.ToUrlParameters(),timeout);
			
			if(String.IsNullOrEmpty(response) || response.StartsWith("!ERROR!") || !response.Contains(":"))
			{
				throw new BadResponseFromWebServiceException(response, url.ToString(),initMessage.ToUrlParameters());
			}
			
			int firstColon = response.IndexOf(":");
			
			string pId = response.Substring(0, firstColon);
			string pPage = response.Substring(firstColon + 1);			
			
			return new PaymentDetails(pId, string.Format("{0}?PaymentID={1}",pPage, pId));
		}
		public void InitGetParameters()
		{
			PaymentInitMessage pipe = new PaymentInitMessage(
			    id:"89025555",
 			   	password: "******",
 			    action: RequiredAction.Authorization,
 			    currency: 978,
 			   	language: RequiredLanguage.ITA,
 			   	responseURL: new Uri("http://www.mioserver.com/Receipt.jsp"),
 			   	errorURL: new Uri("http://www.mioserver.com/Error.jsp"),
 			   	amount: 33.33, 
 			    trackId: "trackId",
 			    udf1: "udf1",
 			    udf2: "udf2",
 			    udf3: "udf3",
 			    udf4: "udf4",
 			    udf5: "udf5");
			
			var urlPars = pipe.ToUrlParameters();
			Console.Error.WriteLine(urlPars);
			Assert.AreEqual(@"id=89025555&password=test&amt=33.33&currencycode=978&action=4&langid=ITA&responseURL=http%3A%2F%2Fwww.mioserver.com%2FReceipt.jsp&errorURL=http%3A%2F%2Fwww.mioserver.com%2FError.jsp&trackid=trackId&udf1=udf1&udf2=udf2&udf3=udf3&udf4=udf4&udf5=udf5",
			                urlPars);
		}		
Exemplo n.º 4
0
        /// <summary>
        /// sends a payment initialization message to the payment gateway
        /// </summary>
        /// <param name="initMessage">instance of PaymentInitMessage that wraps the
        /// details for the requested operation</param>
        /// <param name="timeout">After this time (in milliseconds), the method will stop waiting for an
        /// answer from the payment gateway. It's an optional parameter.Default 5000 milliseconds.</param>
        /// <returns>PaymentDetails for the requested operation</returns>
        /// <exception cref="e24PaymentPipe.Exceptions.BadResponseFromWebServiceException"></exception>
        public PaymentDetails PerformPaymentInitialization(PaymentInitMessage initMessage, int timeout = 5000)
        {
            if (initMessage == null)
            {
                throw new ArgumentNullException("initMessage");
            }

            Uri url = BuildUrl("PaymentInitHTTPServlet");

            string response = sendMessage(url, initMessage.ToUrlParameters(), timeout);

            if (String.IsNullOrEmpty(response) || response.StartsWith("!ERROR!") || !response.Contains(":"))
            {
                throw new BadResponseFromWebServiceException(response, url.ToString(), initMessage.ToUrlParameters());
            }

            int firstColon = response.IndexOf(":");

            string pId   = response.Substring(0, firstColon);
            string pPage = response.Substring(firstColon + 1);

            return(new PaymentDetails(pId, string.Format("{0}?PaymentID={1}", pPage, pId)));
        }
		public void PaymentInitializationTest() 
		{
			var sku = "SKU";
			var size="medium";
			var desc = "a product";
			string details = sku + "#" + desc + "#" + size;

//			// build Payment Init message
			var init=new PaymentInitMessage(
			 	id: "11111111",
			 	password: "******",
			 	action: RequiredAction.Authorization,
			 	amount: 5.30,
			 	language: RequiredLanguage.ITA,
			 	responseURL: new Uri("http://www.example.com/TransactionOK.htm"),
			 	errorURL: new Uri("http://www.example.com/TransactionKO.htm"),
			 	trackId: new Guid().ToString(),
			 	currency: 978,
			 	udf1:details
			 );
			
			var pipe = new PaymentPipe(paymentServerUrl);
			PaymentDetails paymentdetails=null;
			try 
			{
				paymentdetails = pipe.PerformPaymentInitialization(init);
			}
			catch(BadResponseFromWebServiceException ex)
			{
				Console.Error.WriteLine("attemptedUrl:", ex.AttemptedUrl);
				Console.Error.WriteLine("attemptedParameters:", ex.AttemptedParams);				
			}
			
			Assert.IsNotNull(paymentdetails);
			Console.Error.WriteLine("paymentID: {0}", paymentdetails.PaymentId);
			Console.Error.WriteLine("paymentpage: {0}", paymentdetails.PaymentPage);
		}