Skip to content

Commit

Permalink
Version 1.0.7
Browse files Browse the repository at this point in the history
Get bitcoin/altcoin payment box values from gourl.io in JSON format.
JSON data will allow you to easily customise your bitcoin payment boxes.
For example, you can display payment amount and bitcoin payment address
with your
own text, you can also accept payments in android/windows and other
applications.
  • Loading branch information
cryptoapi committed Jul 23, 2017
1 parent b819b6d commit ea77aaa
Show file tree
Hide file tree
Showing 100 changed files with 1,081 additions and 60,798 deletions.
Binary file modified .vs/GoUrl/v14/.suo
Binary file not shown.
2 changes: 1 addition & 1 deletion .vs/config/applicationhost.config
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@
</site>
<site name="Gourl" id="2">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="c:\users\ihor\documents\visual studio 2015\Projects\Gourl\Gourl" />
<virtualDirectory path="/" physicalPath="C:\Users\Ihor\Documents\Visual Studio 2015\Projects\GourlForGitHub\Gourl" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:10076:localhost" />
Expand Down
Binary file modified GoUrl/App_Data/GourlDb.mdf
Binary file not shown.
Binary file modified GoUrl/App_Data/GourlDb_log.ldf
Binary file not shown.
51 changes: 49 additions & 2 deletions GoUrl/Controllers/GoUrl/ExamplesController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public ActionResult Basic()
private_key = "-your private key for Bitcoin box-",
webdev_key = "",
orderID = "your_product1_or_signuppage1_etc",
userID = "",
userID = "",
userFormat = "COOKIE",
amount = 0,
amountUSD = 2,
Expand Down Expand Up @@ -987,9 +987,56 @@ public ActionResult PayPerRegistrationMulti()
public ActionResult Payments()
{
GoUrlEntities Context = new GoUrlEntities();
IEnumerable<crypto_payments> payments = Context.crypto_payments.OrderByDescending(x=>x.recordCreated).Take(100);
IEnumerable<crypto_payments> payments = Context.crypto_payments.OrderByDescending(x => x.recordCreated).Take(100);
return View(payments);
}

public ActionResult PayPerJson()
{
OptionsModel options = new OptionsModel()
{
public_key = "-your gourl.io public key for Bitcoin/Dogecoin/etc box-",
private_key = "-your gourl.io private key for Bitcoin/Dogecoin/etc box-",
webdev_key = "",
orderID = "invoice22",
userID = "",
userFormat = "COOKIE",
amount = 0,
amountUSD = (decimal)0.01,
period = "NOEXPIRY",
language = "en"
};
using (Cryptobox cryptobox = new Cryptobox(options))
{
ViewBag.JsonUrl = cryptobox.cryptobox_json_url();
ViewBag.Message = "";
DisplayCryptoboxModel model = cryptobox.GetDisplayCryptoboxModel();
if (HttpContext.Request.Form["cryptobox_refresh_"] != null)
{
ViewBag.Message = "<div class='gourl_msg'>";
if (cryptobox.is_paid())
{
ViewBag.Message += "<div style=\"margin:50px\" class=\"well\"><i class=\"fa fa-info-circle fa-3x fa-pull-left fa-border\" aria-hidden=\"true\"></i> " + Controls.localisation[model.language].MsgNotReceived.Replace("%coinName%", model.coinName)
.Replace("%coinNames%", model.coinLabel == "DASH" ? model.coinName : model.coinName + "s")
.Replace("%coinLabel%", model.coinLabel) + "</div>";
}else if (cryptobox.is_processed())
{
ViewBag.Message += "<div style=\"margin:70px\" class=\"alert alert-success\" role=\"alert\"> " + (model.boxType == "paymentbox"
? Controls.localisation[model.language].MsgReceived
: Controls.localisation[model.language].MsgReceived2)
.Replace("%coinName%", model.coinName)
.Replace("%coinLabel%", model.coinLabel)
.Replace("%amountPaid%", model.amoutnPaid.ToString()) + "</div>";
cryptobox.set_status_processed();
}
ViewBag.Message = "</div>";
}



return View(model);
}
}
}
}

Expand Down
8 changes: 7 additions & 1 deletion GoUrl/GoUrl.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,9 @@
<DependentUpon>GourlDb.edmx</DependentUpon>
</Content>
<Content Include="scripts\cryptobox.js" />
<Content Include="Web.config" />
<Content Include="Web.config">
<SubType>Designer</SubType>
</Content>
</ItemGroup>
<ItemGroup>
<Compile Include="App_Start\RouteConfig.cs" />
Expand Down Expand Up @@ -217,11 +219,15 @@
<Content Include="Views\Examples\PayPerProductMulti.cshtml" />
<Content Include="Views\Examples\PayPerRegistration.cshtml" />
<Content Include="Views\Examples\PayPerRegistrationMulti.cshtml" />
<Content Include="Views\Examples\PayPerJson.cshtml" />
<None Include="Properties\PublishProfiles\Gourl.pubxml" />
<None Include="Web.Debug.config">
<DependentUpon>Web.config</DependentUpon>
<SubType>Designer</SubType>
</None>
<None Include="Web.Release.config">
<DependentUpon>Web.config</DependentUpon>
<SubType>Designer</SubType>
</None>
</ItemGroup>
<ItemGroup />
Expand Down
1 change: 1 addition & 0 deletions GoUrl/GoUrl.csproj.user
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<UseIISExpress>true</UseIISExpress>
<NameOfLastUsedPublishProfile>Gourl</NameOfLastUsedPublishProfile>
</PropertyGroup>
<ProjectExtensions>
<VisualStudio>
Expand Down
65 changes: 63 additions & 2 deletions GoUrl/GoUrlCore/Calculator.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
using System;
using System.Globalization;
using System.Security.Cryptography;
using System.Text;
using System.Web;
using Gourl.Models.GoUrl;

namespace Gourl.GoUrlCore
{
Expand Down Expand Up @@ -132,13 +135,71 @@ public static TimeSpan ConvertPeriod(string period)
}
if (period.Contains("WEEK"))
{
return TimeSpan.FromDays(double.Parse(period.Split(' ')[0])*7);
return TimeSpan.FromDays(double.Parse(period.Split(' ')[0]) * 7);
}
if (period.Contains("MONTH"))
{
return TimeSpan.FromDays(double.Parse(period.Split(' ')[0])*30);
return TimeSpan.FromDays(double.Parse(period.Split(' ')[0]) * 30);
}
return TimeSpan.MaxValue;
}

public static string cryptobox_hash(DisplayCryptoboxModel model, bool json = false, int width = 0, int height = 0)
{
string hash_str = "";
if (json)
{
hash_str = string.Join("|",
model.boxID,
model.coinName,
model.public_key,
model.private_key,
model.webdev_key,
model.amount.ToString("0.####", CultureInfo.InvariantCulture),
model.amountUSD.ToString("0.####", CultureInfo.InvariantCulture),
model.period,
model.language,
model.orderID,
model.userID,
model.userFormat,
HttpContext.Current.Request.UserHostAddress);
}
else
{
hash_str = string.Join("|",
model.boxID,
model.coinName,
model.public_key,
model.private_key,
model.webdev_key,
model.amount.ToString("0.####", CultureInfo.InvariantCulture),
model.amountUSD.ToString("0.####", CultureInfo.InvariantCulture),
model.period,
model.language,
model.orderID,
model.userID,
model.userFormat,
model.iframeID,
width,
height);
}
return Calculator.md5(hash_str);
}

public static string hash512(string s)
{
string hash = string.Empty;
using (SHA512 sha512 = new SHA512Managed())
{
byte[] bytes = Encoding.UTF8.GetBytes(s);
byte[] res = sha512.ComputeHash(bytes);
for (int i = 0; i < res.Length; i++)
{
hash += res[i].ToString("X2");
}
}

return hash;
}
}
}
96 changes: 48 additions & 48 deletions GoUrl/GoUrlCore/Controls.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ public static MvcHtmlString Cryptobox(this HtmlHelper helper, DisplayCryptoboxMo
message_style = new { style = "display:inline-block;max-width:580px;padding:15px 20px;box-shadow:0 0 10px #aaa;-moz-box-shadow: 0 0 10px #aaa;margin:7px;font-size:13px;font-weight:normal;line-height:21px;font-family: Verdana, Arial, Helvetica, sans-serif;" };
}

string hashResult = Calculator.md5(model.boxID + model.coinName + model.public_key + model.private_key + model.webdev_key + model.amount.ToString(CultureInfo.InvariantCulture) + model.period + model.amountUSD.ToString(CultureInfo.InvariantCulture) + model.language + model.amount.ToString(CultureInfo.InvariantCulture) + model.iframeID + model.amountUSD.ToString(CultureInfo.InvariantCulture) + model.userID + model.userFormat + model.orderID + width + height);
//string hashResult = Calculator.md5(model.boxID + model.coinName + model.public_key + model.private_key + model.webdev_key + model.amount.ToString(CultureInfo.InvariantCulture) + model.period + model.amountUSD.ToString(CultureInfo.InvariantCulture) + model.language + model.amount.ToString(CultureInfo.InvariantCulture) + model.iframeID + model.amountUSD.ToString(CultureInfo.InvariantCulture) + model.userID + model.userFormat + model.orderID + width + height);
string hashResult = Calculator.cryptobox_hash(model, false, width, height);
string val = Calculator.md5(model.iframeID + model.private_key + model.userID);
string result = "";

Expand Down Expand Up @@ -81,7 +82,7 @@ public static MvcHtmlString Cryptobox(this HtmlHelper helper, DisplayCryptoboxMo
? localisation[model.language].MsgReceived
: localisation[model.language].MsgReceived2)
.Replace("%coinName%", model.coinName)
.Replace("%coinLabel%", model.coinLabel == "DASH" ? model.coinName : model.coinName + "s")
.Replace("%coinLabel%", model.coinLabel)
.Replace("%amountPaid%", model.amoutnPaid.ToString());

div0.InnerHtml = spanBuilder.ToString();
Expand All @@ -93,7 +94,7 @@ public static MvcHtmlString Cryptobox(this HtmlHelper helper, DisplayCryptoboxMo
spanBuilder.InnerHtml = localisation[model.language].MsgNotReceived
.Replace("%coinName%", model.coinName)
.Replace("%coinNames%", model.coinLabel == "DASH" ? model.coinName : model.coinName + "s")
.Replace("%coinLabel%", model.coinLabel == "DASH" ? model.coinName : model.coinName + "s");
.Replace("%coinLabel%", model.coinLabel);

TagBuilder scrptBuilder = new TagBuilder("script");
scrptBuilder.MergeAttribute("type", "text/javascript");
Expand Down Expand Up @@ -156,7 +157,7 @@ public static MvcHtmlString Cryptobox(this HtmlHelper helper, DisplayCryptoboxMo
buttonBuilder.InnerHtml = localisation[model.language].Button
.Replace("%coinName%", model.coinName)
.Replace("%coinNames%", model.coinLabel == "DASH" ? model.coinName : model.coinName + "s")
.Replace("%coinLabel%", model.coinLabel == "DASH" ? model.coinName : model.coinName + "s") +
.Replace("%coinLabel%", model.coinLabel) +
(model.language != "ar" ? " &#187;" : "") + " &#160;";

div3.InnerHtml = buttonBuilder.ToString();
Expand All @@ -176,47 +177,59 @@ public static MvcHtmlString Cryptobox(this HtmlHelper helper, DisplayCryptoboxMo
/// <param name="anchor"></param>
/// <returns></returns>
public static MvcHtmlString LanguageBox(this HtmlHelper helper, string defaultLanguage = "en",
string anchor = "gourlcryptolang")
string anchor = "gourlcryptolang", bool select_list = true)
{
defaultLanguage = defaultLanguage.ToLower();
string id = "gourlcryptolang";
string lan = "en";
string lan = CryptoHelper.cryptobox_sellanguage(defaultLanguage);
var query = HttpUtility.ParseQueryString(HttpContext.Current.Request.Url.Query);
if (HttpContext.Current.Request.QueryString[id] != null &&
HttpContext.Current.Request.QueryString[id] != "" &&
localisation.ContainsKey(HttpContext.Current.Request.QueryString[id]))
{
lan = HttpContext.Current.Request.QueryString[id];
HttpContext.Current.Response.Cookies.Add(new HttpCookie(id, lan) { Expires = DateTime.Now + TimeSpan.FromDays(7) });
query.Remove(id);
}
else if (HttpContext.Current.Request.Cookies[id] != null &&
HttpContext.Current.Request.Cookies[id].Value != "" &&
localisation.ContainsKey(HttpContext.Current.Request.Cookies[id].Value))
{
lan = HttpContext.Current.Request.Cookies[id].Value;
}
else if (localisation.ContainsKey(defaultLanguage))

string url = HttpContext.Current.Request.Url.AbsoluteUri.Split(new[] { '?' })[0];
TagBuilder selectBuilder;
if (select_list)
{
lan = defaultLanguage;
selectBuilder = new TagBuilder("select");
selectBuilder.MergeAttribute("name", id);
selectBuilder.MergeAttribute("id", id);

selectBuilder.MergeAttribute("onchange", "window.open(\"" + url + "?" +
query.ToString() +
(query.Count > 0 ? "&" : "") + id +
"=\"+this.options[this.selectedIndex].value+\"#" + anchor +
"\",\"_self\")");
foreach (string key in localisation.Keys)
{
TagBuilder optionsBuilder = new TagBuilder("option");
if (key == lan)
optionsBuilder.MergeAttribute("selected", "selected");
optionsBuilder.MergeAttribute("value", key);
optionsBuilder.InnerHtml = localisation[key].Name;
selectBuilder.InnerHtml += optionsBuilder.ToString();
}
}
string url = HttpContext.Current.Request.Url.AbsoluteUri.Split(new[] { '?' })[0];
TagBuilder selectBuilder = new TagBuilder("select");
selectBuilder.MergeAttribute("name", id);
selectBuilder.MergeAttribute("id", id);

selectBuilder.MergeAttribute("onchange", "window.open(\"" + url + "?" +
query.ToString() +
(query.Count > 0 ? "&" : "") + id +
"=\"+this.options[this.selectedIndex].value+\"#" + anchor + "\",\"_self\")");
foreach (string key in localisation.Keys)
else
{
TagBuilder optionsBuilder = new TagBuilder("option");
if (key == lan)
optionsBuilder.MergeAttribute("selected", "selected");
optionsBuilder.MergeAttribute("value", key);
optionsBuilder.InnerHtml = localisation[key].Name;
selectBuilder.InnerHtml += optionsBuilder.ToString();
selectBuilder = new TagBuilder("ul");
selectBuilder.MergeAttribute("class", "dropdown-menu");
foreach (string key in localisation.Keys)
{
TagBuilder liBuilder = new TagBuilder("li");
if(key == lan)
liBuilder.MergeAttribute("class", "active");
TagBuilder aBuilder = new TagBuilder("a");
aBuilder.MergeAttribute("href", url + "?" +
query.ToString() +
(query.Count > 0 ? "&" : "") + id + "=" + key + "#" + anchor);
aBuilder.InnerHtml = localisation[key].Name;
liBuilder.InnerHtml = aBuilder.ToString();
selectBuilder.InnerHtml += liBuilder.ToString();
}
}

return MvcHtmlString.Create(selectBuilder.ToString());
Expand Down Expand Up @@ -260,24 +273,11 @@ public static MvcHtmlString CurrencyBox(this HtmlHelper helper, string[] coins,
query.Remove("gourlcryptocoin");
}

string url = HttpContext.Current.Request.Url.AbsoluteUri.Split(new[] {'?'})[0] +
string url = HttpContext.Current.Request.Url.AbsoluteUri.Split(new[] { '?' })[0] +
"?" + query.ToString() + (query.Count > 0 ? "&" : "") + "gourlcryptocoin=";

string id = "gourlcryptolang";
string lan = defLang;
if (HttpContext.Current.Request.QueryString[id] != null &&
HttpContext.Current.Request.QueryString[id] != "" &&
localisation.ContainsKey(HttpContext.Current.Request.QueryString[id]))
{
lan = HttpContext.Current.Request.QueryString[id];
}
else if (HttpContext.Current.Request.Cookies[id] != null &&
HttpContext.Current.Request.Cookies[id].Value != "" &&
localisation.ContainsKey(HttpContext.Current.Request.Cookies[id].Value))
{
lan = HttpContext.Current.Request.Cookies[id].Value;
}
id = "gourlcryptocoins";
string lan = CryptoHelper.cryptobox_sellanguage(defLang);
string id = "gourlcryptocoins";

TagBuilder divBuilder = new TagBuilder("div");
divBuilder.MergeAttribute("id", id);
Expand Down
2 changes: 1 addition & 1 deletion GoUrl/GoUrlCore/ControlsLanguages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public static partial class Controls
/// <summary>
/// en - English, es - Spanish, fr - French, de - German, nl - Dutch, it - Italian, ru - Russian, pl - Polish, pt - Portuguese, fa - Persian, ko - Korean, ja - Japanese, id - Indonesian, tr - Turkish, ar - Arabic, cn - Simplified Chinese, zh - Traditional Chinese, hi - Hindi
/// </summary>
private static Dictionary<string, LocalisationModel> localisation = new Dictionary<string, LocalisationModel>()
public static Dictionary<string, LocalisationModel> localisation = new Dictionary<string, LocalisationModel>()
{
{ "en", new LocalisationModel() {Name = "English",
Button = "Click Here if you have already sent %coinNames%",
Expand Down
Loading

0 comments on commit ea77aaa

Please sign in to comment.