/// <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¤cycode=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); }
/// <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))); }