protected void ButtonCreateMacroPayment_Click(object sender, EventArgs e) { // This is used to make a request try { string siteUrl = Request.Url.GetLeftPart(UriPartial.Authority); int projectId = 0; string signPassword = "******"; Client client = new Client(projectId, signPassword); // Make a new request MacroRequest request = client.NewMacroRequest(); // Should be saved somewhere and unique for every request. request.OrderId = "ORDER0001"; request.Amount = 1000; request.Currency = "EUR"; request.Country = "LT"; request.AcceptUrl = siteUrl + "/Accept.aspx"; request.CancelUrl = siteUrl + "/Cancel.aspx"; request.CallbackUrl = siteUrl + "/MacroCallback.aspx"; // Change this to "true" if you want to test request.Test = false; string redirectUrl = client.BuildRequestUrl(request); Response.Redirect(redirectUrl); } catch (Exception ex) { this.LabelErrorMessage.Visible = true; } }
public static async Task <string> pay(Cart cart) { MacroRequest request = client.NewMacroRequest(); request.OrderId = "Užsakymas " + cart.id.ToString(); request.Amount = (int)(cart.items.Select(x => x.price).Sum() * 100); request.Currency = "EUR"; request.Country = "LT"; request.AcceptUrl = "http://localhost:8000/Cart/OrderSuccess/" + cart.id.ToString(); request.CancelUrl = "http://localhost:8000/Cart/OrderFailed/" + cart.id.ToString(); request.CallbackUrl = "http://localhost:8000/Cart/OrderSuccess/" + cart.id.ToString(); request.Test = true; return(client.BuildRequestUrl(request)); }
/// <summary> /// Read a macro file request from a memory span /// </summary> /// <param name="from">Origin</param> /// <param name="channel">Code channel that requested the execution</param> /// <param name="reportMissing">Output a message if the macro cannot be found</param> /// <param name="fromCode">Whether the macro request came from the G/M/T-code being executed</param> /// <param name="filename">Filename of the macro to execute</param> /// <returns>Number of bytes read</returns> public static int ReadMacroRequest(ReadOnlySpan <byte> from, out CodeChannel channel, out bool reportMissing, out bool fromCode, out string filename) { MacroRequest header = MemoryMarshal.Cast <byte, MacroRequest>(from)[0]; int bytesRead = Marshal.SizeOf(header); // Read header channel = header.Channel; reportMissing = Convert.ToBoolean(header.ReportMissing); fromCode = Convert.ToBoolean(header.FromCode); // Read filename ReadOnlySpan <byte> unicodeFilename = from.Slice(bytesRead, header.Length); filename = Encoding.UTF8.GetString(unicodeFilename); bytesRead += header.Length; return(AddPadding(bytesRead)); }