static void Main(string[] args)
        {
            // Setting comerce data
            Onepay.SharedSecret    = "?XW#WOLG##FBAGEAYSNQ5APD#JF@$AYZ";
            Onepay.ApiKey          = "dKVhq1WGt_XapIYirTXNyUKoWTDFfxaEV63-O5jcsdw";
            Onepay.IntegrationType = Transbank.Onepay.Enums.OnepayIntegrationType.Test;

            // Setting items to the shopping cart
            ShoppingCart cart = new ShoppingCart();

            cart.Add(new Item(
                         description: "Zapatos",
                         quantity: 1,
                         amount: 10000,
                         additionalData: null,
                         expire: 10));

            cart.Add(new Item("Pantalon", 1, 5000, null, -1));

            // Send transaction to Transbank
            TransactionCreateResponse response = Transaction.Create(cart);

            Console.WriteLine(response.ToString());

            var bytes = Convert.FromBase64String(response.QrCodeAsBase64);

            using (var imageFile = new FileStream(@"Qr.jpg", FileMode.Create))
            {
                imageFile.Write(bytes, 0, bytes.Length);
                imageFile.Flush();
            }

            Console.WriteLine("Pay with the app and then press any key to continue....");
            Console.ReadKey();

            TransactionCommitResponse commitResponse = Transaction.Commit(
                response.Occ, response.ExternalUniqueNumber);

            Console.WriteLine(commitResponse.ToString());

            Console.WriteLine("Press any key to Refund Transaction...");
            Console.ReadKey();

            RefundCreateResponse refundResponse = Refund.Create(commitResponse.Amount,
                                                                commitResponse.Occ, response.ExternalUniqueNumber,
                                                                commitResponse.AuthorizationCode);

            Console.WriteLine(refundResponse.ToString());

            Console.WriteLine("Press any key to continue...");
            Console.ReadKey();
        }
예제 #2
0
 public ActionResult Create(long amount, string occ, string externalUniqueNumber, string authorizationCode)
 {
     try
     {
         RefundCreateResponse refundResponse = Refund.Create(amount, occ, externalUniqueNumber, authorizationCode);
         ViewBag.Refund = refundResponse;
         return(View());
     }
     catch (TransbankException e)
     {
         Debug.WriteLine(e.StackTrace);
         return(RedirectToAction("Error", "Message", new { error = e.Message }));
     }
 }
        public void TestOnepayRefundTransaction()
        {
            var amount = 27500;
            var occ    = "1807983490979289";
            var externalUniqueNumber = "f506a955-800c-4185-8818-4ef9fca97aae";
            var authorizationCode    = "623245";

            RefundCreateResponse response = Refund.Create(amount, occ,
                                                          externalUniqueNumber, authorizationCode);

            Assert.IsNotNull(response);
            Assert.AreEqual("1807983490979289", response.Occ);
            Assert.AreEqual("f506a955-800c-4185-8818-4ef9fca97aae", response.ExternalUniqueNumber);
            Assert.AreEqual("623245", response.ReverseCode);
            Assert.AreEqual(1532104252, response.IssuedAt);
            Assert.AreEqual("52NpZBolTEs+ckNOXwGRexDetY9MOaX1QbFYkjPymf4=", response.Signature);
        }