Example #1
0
            /// <summary>
            /// Run the example code.
            /// </summary>
            public static void Main()
            {
                const string MerchantId   = "0";
                const string SharedSecret = "sharedSecret";
                string       orderId      = "12345";
                string       captureId    = "34567";

                IConnector connector = ConnectorFactory.Create(MerchantId, SharedSecret, Client.EuTestBaseUrl);

                Client   client  = new Client(connector);
                IOrder   order   = client.NewOrder(orderId);
                ICapture capture = client.NewCapture(order.Location, captureId);

                ShippingInfo shippingInfo = new ShippingInfo
                {
                    ShippingCompany       = "DHL",
                    ShippingMethod        = "Home",
                    TrackingUri           = new Uri("http://www.dhl.com/content/g0/en/express/tracking.shtml?brand=DHL&AWB=1234567890"),
                    TrackingNumber        = "1234567890",
                    ReturnTrackingNumber  = "E-55-KL",
                    ReturnShippingCompany = "DHL",
                    ReturnTrackingUri     = new Uri("http://www.dhl.com/content/g0/en/express/tracking.shtml?brand=DHL&AWB=98389222")
                };

                AddShippingInfo addShippingInfo = new AddShippingInfo();

                addShippingInfo.ShippingInfo = new List <ShippingInfo>()
                {
                    shippingInfo
                };

                try
                {
                    capture.AddShippingInfo(addShippingInfo);
                }
                catch (ApiException ex)
                {
                    Console.WriteLine(ex.ErrorMessage.ErrorCode);
                    Console.WriteLine(ex.ErrorMessage.ErrorMessages);
                    Console.WriteLine(ex.ErrorMessage.CorrelationId);
                }
                catch (WebException ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }