public JsonResult Create(string channel) { var jsonResponse = new Hashtable(); var channelType = ChannelType.Parse(channel); var cart = GetCart(); ShoppingCart shoppingCart = new ShoppingCart(); foreach (Product p in cart) { shoppingCart.Add(new Item( description: p.Name, quantity: p.Quantity, amount: p.Price, additionalData: null, expire: 10 )); } TransactionCreateResponse response; try { response = Transaction.Create(shoppingCart, channelType); } catch (Transbank.Onepay.Exceptions.TransbankException e) { jsonResponse.Add("error", e.Message); return(Json(jsonResponse)); } var camelCaseFormatter = new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }; jsonResponse.Add("occ", response.Occ); jsonResponse.Add("ott", response.Ott); jsonResponse.Add("externalUniqueNumber", response.ExternalUniqueNumber); jsonResponse.Add("qrCodeAsBase64", response.QrCodeAsBase64); jsonResponse.Add("issuedAt", response.IssuedAt); jsonResponse.Add("amount", shoppingCart.Total); return(Json(jsonResponse)); }
public void TestOnepaySendtransaction() { var options = new Options( "mUc0GxYGor6X8u-_oB3e-HWJulRG01WoC96-_tUA3Bg", "P4DCPS55QB2QLT56SQH6#W#LV76IAPYX" ); var cart = CreateCart(); var response = Transaction.Create(cart, ChannelType.Parse("web"), options); Assert.IsNotNull(response); Assert.AreEqual("1807983490979289", response.Occ); Assert.AreEqual(64181789, response.Ott); Assert.AreEqual("USrtuoyAU3l5qeG3Gm2fnxKRs++jQaf1wc8lwA6EZ2o=", response.Signature); Assert.AreEqual("f506a955-800c-4185-8818-4ef9fca97aae", response.ExternalUniqueNumber); Assert.AreEqual(1532103896, response.IssuedAt); string qrBase64 = "iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAYAAACtWK6eAAADmElEQVR42u3dQW4CMRBE0bn/peEEbBCmq9rvS9lFxDP221jEfl6SPvZ4BRIgEiASIBIgEiASIBIgEiASIJIAkQCRAJEAkQCRAJEAkQCRAJEAkQSIBIgEiASIdAuQ53kqfn71XKffT9rntMwXIIAAAggggAACCCCAAAIIIIAAAsh/FlLLeKYWxunP2TpfgAACCCCAAAIIIIAAAggggAACCCDfPeDUQto6ntvmCxBAAAEEEEAAAQQQQAABBBBAAAHkTiBT4zw9HkAAAQQQQAABBBBAAAEEEEAAAQQQQG5+4S3breYLEEAAAQQQQAABBBBAAAEEEEAAASTlAZMW8FYgm9cPIIAAAggggAACCCCAAAIIIIAAAkjPcfp+3/UHgAACCCCAAAIIIIAAAggggAACyA1A2ku7tiBxIa2de68AEAECiAABBBBAAAEEEEAAuQhI+wJrv55gapynxw8IIIAAAggggAACCCCAAAIIIIAA8h8gUwvg9IJp34adGqdv8wICCCCAAAIIIIAAAggggAACCCA7gLRc4pm2UG/bZgcEEEAAAQQQQAABBBBAAAEEEEAAyQTSss3Ycl1C2vYyIIAAAggggAACCCCAAAIIIIAAAkjmwXFp1wGkPW/atvDWeQEEEEAAAQQQQAABBBBAAAEEEEAA+W4i2hd2y/O2/8szIIAAAggggAACCCCAAAIIIIAAAkjmtu3Ugkw7mK4dDiCAAAIIIIAAAggggAACCCCAAALI7m3etG3JlvfQAhYQQAABBBBAAAEEEEAAAQQQQAAB5M6D47aCmgLYcrAeIIAAAggggAACCCCAAAIIIIAAAsju2oG3XBvhy4qAAAIIIIAAAggggAgQQAQIIJnbvGk/p8ffAnPrNjIggAACCCCAAAIIIIAAAggggAACyG8numXbNm27Mu3vblg/gAACCCCAAAIIIIAAAggggAACCCBz26q3HYzWsp0OCCCAAAIIIIAAAggggAACCCCAAALIiRfe8qXKtHlJPCAOEEAAAQQQQAABBBBAAAEEEEAAAWTvNm/L52z9u4AAAggggAACCCCAAAIIIIAAAgggs0BawJ4eT/sCa4IACCCAAAIIIIAAAggggAACCCCAAOL6gy2XeG49cA8QQAABBBBAAAEEEEAAAQQQQAABROoOEAkQCRAJEAkQCRAJEAkQCRAJEEmASIBIgEiASIBIgEiASIBIgEiASAJEAkQCRAJESugNVyLVvcNSF1EAAAAASUVORK5CYII="; Assert.AreEqual(qrBase64, response.QrCodeAsBase64); }
public void OnepaySendTransactionRequestDataToSign() { var a = new SendTransactionRequest(externalUniqueNumber: "1", total: 100, itemsQuantity: 3, issuedAt: 5, items: null, callbackUrl: "TestURL", channel: ChannelType.Parse("web").Value); Assert.AreEqual("11310013157TestURL", a.GetDataToSign()); }