public ActionResult PayPerProduct() { OptionsModel options = new OptionsModel() { public_key = "-your public key for Bitcoin box-", private_key = "-your private key for Bitcoin box-", webdev_key = "", orderID = "invoice000383", userID = "", userFormat = "COOKIE", amount = 0, amountUSD = (decimal)0.01, period = "NOEXPIRY", language = "en" }; using (Cryptobox cryptobox = new Cryptobox(options)) { if (cryptobox.is_paid()) { if (!cryptobox.is_confirmed()) { ViewBag.message = "Thank you for order (order #" + options.orderID + ", payment #" + cryptobox.payment_id() + "). Awaiting transaction/payment confirmation"; } else { if (!cryptobox.is_processed()) { ViewBag.message = "Thank you for order (order #" + options.orderID + ", payment #" + cryptobox.payment_id() + "). Payment Confirmed<br/> (User will see this message one time after payment has been made)"; cryptobox.set_status_processed(); } else { ViewBag.message = "Thank you for order (order #" + options.orderID + ", payment #" + cryptobox.payment_id() + "). Payment Confirmed<br/> (User will see this message during " + options.period + " period after payment has been made)"; } } } else { ViewBag.message = "This invoice has not been paid yet"; } DisplayCryptoboxModel model = cryptobox.GetDisplayCryptoboxModel(); return(View(model)); } }
public ActionResult MakePayment(double cryptoamount) { var transaction = new CryptoTransaction(); var account = new CryptoAccount(); var accountId = AccountId(); transaction.Create(new TransactionVm() { Status = TransactionStatus.PENDING, Amount = Convert.ToDecimal(cryptoamount), accountId = accountId, CurrencyDomination = "BTC", TransactionType = TransactionTypeStatus.Credit }); OptionsModel options = new OptionsModel() { public_key = GoUrlKeys.PublicKey, private_key = GoUrlKeys.PrivateKey, webdev_key = "", orderID = transaction.savedId.ToString(), userID = UserId(), userFormat = "COOKIE", //amount = 0, amountUSD = Convert.ToDecimal(cryptoamount), period = "2 HOUR", language = "en" }; using (Cryptobox cryptobox = new Cryptobox(options)) { if (cryptobox.is_paid()) { //initiate a pendint transaction if (!cryptobox.is_confirmed()) { ViewBag.message = "Thank you for order (order #" + options.orderID + ", payment #" + cryptobox.payment_id() + "). Awaiting transaction/payment confirmation"; } else { if (!cryptobox.is_processed()) { ViewBag.message = "Thank you for order (order #" + options.orderID + ", payment #" + cryptobox.payment_id() + "). Payment Confirmed<br/> (User will see this message one time after payment has been made)"; cryptobox.set_status_processed(); transaction.SetStatus(transaction.savedId, TransactionStatus.SUCCESSFUL); } else { ViewBag.message = "Thank you for order (order #" + options.orderID + ", payment #" + cryptobox.payment_id() + "). Payment Confirmed<br/> (User will see this message during " + options.period + " period after payment has been made)"; transaction.SetStatus(transaction.savedId, TransactionStatus.INPROGESS); } } } else { ViewBag.message = "This invoice has not been paid yet"; transaction.SetStatus(transaction.savedId, TransactionStatus.PENDING); } DisplayCryptoboxModel model = cryptobox.GetDisplayCryptoboxModel(); return(View(model)); } }
public ActionResult PayPerProductMulti() { string defPaiment = "bitcoin"; string[] available_payments = new[] { "bitcoin", "dogecoin" }; IDictionary <string, IDictionary <string, string> > all_keys = new Dictionary <string, IDictionary <string, string> >() { { "bitcoin", new Dictionary <string, string>() { { "public_key", "-your public key for Bitcoin box-" }, { "private_key", "-your private key for Bitcoin box-" } } }, { "dogecoin", new Dictionary <string, string>() { { "public_key", "-your public key for Dogecoin box-" }, { "private_key", "-your private key for Dogecoin box-" } } } }; foreach (KeyValuePair <string, IDictionary <string, string> > valuePair in all_keys) { if (valuePair.Value["public_key"] == null || valuePair.Value["private_key"] == null || valuePair.Value["public_key"] == "" || valuePair.Value["private_key"] == "") { return (new ContentResult() { Content = "Please add your public/private keys for " + valuePair.Key + " in all_keys variable" }); } else if (!valuePair.Value["public_key"].Contains("PUB")) { return (new ContentResult() { Content = "Invalid public key for " + valuePair.Key + " in all_keys variable" }); } else if (!valuePair.Value["private_key"].Contains("PRV")) { return (new ContentResult() { Content = "Invalid private key for " + valuePair.Key + " in all_keys variable" }); } else if (!ConfigurationManager.AppSettings["PrivateKeys"].Contains(valuePair.Value["private_key"])) { return (new ContentResult() { Content = "Please add your private key for " + valuePair.Key + " in Web.config." }); } } string coinName = CryptoHelper.cryptobox_selcoin(available_payments, defPaiment); OptionsModel options = new OptionsModel() { public_key = all_keys[coinName]["public_key"], private_key = all_keys[coinName]["private_key"], webdev_key = "", orderID = "invoice000383", userID = "", userFormat = "COOKIE", amount = 0, amountUSD = (decimal)0.01, period = "NOEXPIRY", language = "en" }; using (Cryptobox cryptobox = new Cryptobox(options)) { ViewBag.Coins = available_payments; ViewBag.DefCoin = defPaiment; ViewBag.DefLang = options.language; if (cryptobox.is_paid()) { if (!cryptobox.is_confirmed()) { ViewBag.message = "Thank you for order (order #" + options.orderID + ", payment #" + cryptobox.payment_id() + "). Awaiting transaction/payment confirmation"; } else { if (!cryptobox.is_processed()) { ViewBag.message = "Thank you for order (order #" + options.orderID + ", payment #" + cryptobox.payment_id() + "). Payment Confirmed<br/> (User will see this message one time after payment has been made)"; cryptobox.set_status_processed(); } else { ViewBag.message = "Thank you for order (order #" + options.orderID + ", payment #" + cryptobox.payment_id() + "). Payment Confirmed<br/> (User will see this message during " + options.period + " period after payment has been made)"; } } } else { ViewBag.message = "This invoice has not been paid yet"; } DisplayCryptoboxModel model = cryptobox.GetDisplayCryptoboxModel(); return(View(model)); } }