Beispiel #1
0
        public static void Main(string[] args)
        {
            try {
                // The sample XML document...
                string xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" +
                             "<paymentAuthRequest version=\"1.0\" id=\"YOUR_ID_HERE\">\n" +
                             "<control>\n" +
                             "  <adresse type=\"facturation\" format=\"1\">\n" +
                             "    <rue1>15 rue spencer &amp; spencer</rue1>\n" +
                             "    <cpostal>75008</cpostal>\n" +
                             "    <ville>paris</ville>\n" +
                             "    <pays>FRANCE</pays>\n" +
                             "  </adresse>\n" +
                             "  <utilisateur type=\"facturation\" qualite=\"1\">\n" +
                             "   <nom>dupont</nom>\n" +
                             "   <prenom>jean rene</prenom>\n" +
                             "   <email>[email protected]</email>\n" +
                             "  </utilisateur>\n" +
                             "  <infocommande>\n" +
                             "   <siteid>678</siteid>\n" +
                             "   <refid>000000001</refid>\n" +
                             "   <montant devise=\"eur\">100.00</montant>\n" +
                             "   <ip timestamp=\"2012-08-08 11:11:56\">127.0.0.1</ip>\n" +
                             "   <transport>\n" +
                             "    <type>4</type>\n" +
                             "    <nom>La Poste</nom>\n" +
                             "    <rapidite>2</rapidite>\n" +
                             "   </transport>\n" +
                             "   <list nbproduit=\"1\">\n" +
                             "    <produit>the first product</produit>\n" +
                             "   </list>\n" +
                             "  </infocommande>\n" +
                             "  <paiement>\n" +
                             "  	<type>carte</type>\n"+
                             "  </paiement>\n" +
                             "</control>\n" +
                             "</paymentAuthRequest>";

                Console.WriteLine("*******************************************");
                Console.WriteLine("** Calling copilot.cgi...                **");
                Console.WriteLine("*******************************************\n");


                // Our configuration object
                CopilotConfig cfg = new CopilotConfig(
                    COPILOT_URI,
                    MY_SITEID,
                    MY_AUTHKEY_HEX,
                    MY_TIMEOUT_MS,
                    MY_DEFAULT_AUTHLEVEL
                    );

                // Call the web-service and get the reponse :
                CopilotResponse resp = new CopilotRequest(cfg).Execute(xml, MY_ENCODING);

                Console.WriteLine("*******************************************");
                Console.WriteLine(" HTTP Status: " + resp.StatusText);

                if (resp.Success)
                {
                    Console.WriteLine(" Call successful.");
                }
                else
                {
                    Console.WriteLine(" An error occured. We will be using the default authentication level.");
                    Console.WriteLine(" Response body: " + resp.DocumentBody);
                }

                Console.WriteLine("*******************************************");
                Console.WriteLine(" Authentication level: " + resp.AuthLevel);

                Console.Write(" Technical ID: ");
                if (resp.TechnicalId.Length == 0)
                {
                    Console.WriteLine("<none>");
                }
                else
                {
                    Console.WriteLine(resp.TechnicalId);
                }

                Console.WriteLine("*******************************************");
            } catch (Exception e) {
                Console.Error.WriteLine("*******************************************");
                Console.Error.WriteLine("** Exception caught                      **");
                Console.Error.WriteLine("*******************************************");
                Console.Error.WriteLine(e.Message);
                Console.Error.Write(e.StackTrace);
            } finally {
                Console.ReadKey();
            }
        }
Beispiel #2
0
 public CopilotRequest(CopilotConfig cfg)
 {
     this.cfg = cfg;
 }