Пример #1
0
        public ActionResult RefundConfirmed(int id)
        {
            //Find Order
            Order order = db.Orders.Find(id);

            //Set API Credentials
            TwocheckoutConfig.ApiUsername = "******";
            TwocheckoutConfig.ApiPassword = "******";

            //Attempt Refund
            var dictionary = new Dictionary <string, string>();

            dictionary.Add("sale_id", order.OrderNumber);
            dictionary.Add("comment", "Refunded");
            dictionary.Add("category", "5");
            TwocheckoutResponse result = TwocheckoutSale.Refund(dictionary);

            //If Successful, update order.
            if (result.response_code == "OK")
            {
                order.Refunded        = "Yes";
                db.Entry(order).State = EntityState.Modified;
                db.SaveChanges();
            }

            return(RedirectToAction("Index"));
        }
Пример #2
0
 public void _006_TestSaleRefund()
 {
     try
     {
         var dictionary = new Dictionary <string, string>();
         dictionary.Add("sale_id", sale_id);
         dictionary.Add("comment", "test refund");
         dictionary.Add("category", "5");
         var result = TwocheckoutSale.Refund(dictionary);
         Assert.IsInstanceOf <TwocheckoutResponse>(result);
     }
     catch (TwocheckoutException e)
     {
         Assert.IsInstanceOf <TwocheckoutException>(e);
     }
 }