示例#1
0
 public void _004_TestSaleStop()
 {
     try
     {
         var ServiceObject = new SaleService();
         var ArgsObject = new SaleStopServiceOptions();
         ArgsObject.sale_id = sale_id;
         var result = ServiceObject.Stop(ArgsObject);
         Assert.IsInstanceOf<TwoCheckoutResponse>(result);
     }
     catch (TwoCheckoutException e)
     {
         Assert.IsInstanceOf<TwoCheckoutException>(e);
     }
 }
        public static string StopActiveLineitems(Dictionary <string, string> active)
        {
            string stoppedLineitems        = null;
            SaleStopServiceOptions options = new SaleStopServiceOptions();

            foreach (var entry in active)
            {
                options.lineitem_id = Convert.ToInt64(entry.Value);
                try
                {
                    TwoCheckoutUtil.Request("api/sales/stop_lineitem_recurring", "POST", "admin", options);
                    stoppedLineitems += "," + entry.Value; //log the stopped lineitem in response mesage
                }
                catch (TwoCheckoutException)
                {
                    return("{ 'response_code': 'NOTICE', 'response_message': 'Linetiem " + entry.Value + " could not be stopped.' }");
                }
            }
            stoppedLineitems = stoppedLineitems.Remove(0, 1); //drop the leading comma
            return("{ 'response_code': 'OK', 'response_message': '" + stoppedLineitems + "' }");
        }
示例#3
0
 public TwoCheckoutResponse Stop(SaleStopServiceOptions options)
 {
     String Result = null;
     if (options.sale_id != null)
     {
         Result = TwoCheckoutUtil.Request("api/sales/detail_sale", "GET", "admin", options);
         Dictionary<string, string> Active = TwoCheckoutUtil.Active(Result);
         if (Active.ContainsKey("lineitem_id0"))
         {
             Result = TwoCheckoutUtil.StopActiveLineitems(Active);
         }
         else
         {
             Result = "{ 'response_code': 'NOTICE', 'response_message': " + "'No active recurring lineitems.'" + " }";
         }
     }
     else
     {
         Result = TwoCheckoutUtil.Request("api/sales/stop_lineitem_recurring", "POST", "admin", options);
     }
     return TwoCheckoutUtil.MapToObject<TwoCheckoutResponse>(Result);
 }
 public TwoCheckoutResponse Stop(SaleStopServiceOptions options)
 {
     String Result = null;
     if (options.sale_id != null)
     {
         Result = TwoCheckoutUtil.Request("api/sales/detail_sale", "GET", "admin", options);
         Dictionary<string, string> Active = TwoCheckoutUtil.Active(Result);
         if (Active.ContainsKey("lineitem_id0"))
         {
             Result = TwoCheckoutUtil.StopActiveLineitems(Active);
         }
         else
         {
             Result = "{ 'response_code': 'NOTICE', 'response_message': " + "'No active recurring lineitems.'" + " }";
         }
     }
     else
     {
         Result = TwoCheckoutUtil.Request("api/sales/stop_lineitem_recurring", "POST", "admin", options);
     }
     return TwoCheckoutUtil.MapToObject<TwoCheckoutResponse>(Result);
 }