using System; using System.Collections; using System.Configuration; using System.Data; using System.Globalization; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using PirateWeb.Basic.Types; using PirateWeb.Logic.Financial; public partial class Pages_Public_PayInvoice : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { if (!String.IsNullOrEmpty(Request.QueryString["InvoiceRef"])) { this.TextInvoiceReference.Text = Request.QueryString["InvoiceRef"]; LookupReference(Request.QueryString["InvoiceRef"]); } if (!String.IsNullOrEmpty(Request.QueryString["merchant_return_link"])) { this.PanelPaypalReturn.Visible = true; } } } protected void ButtonLookup_Click(object sender, EventArgs e) { LookupReference(this.TextInvoiceReference.Text); } private void LookupReference (string reference) { OutboundInvoice invoice = null; try { invoice = OutboundInvoice.FromReference(reference); } catch (Exception) { this.PanelInvoice.Visible = false; this.LabelReferenceNotFound.Text = "Invoice not found or already paid."; return; } if (!invoice.Open) { this.PanelInvoice.Visible = false; this.LabelReferenceNotFound.Text = "Invoice not found or already paid."; return; } this.LabelReferenceNotFound.Text = string.Empty; this.PanelInvoice.Visible = true; this.LabelInvoiceReference.Text = invoice.Reference; this.LabelAmount.Text = invoice.Amount.ToString("N2", new CultureInfo("sv-SE")) + " " + invoice.Currency.Code + " (+5% Credit Card / Paypal surcharge)"; this.LabelIssuer.Text = invoice.Organization.Name; this.LabelRecipient.Text = invoice.CustomerName; this.LinkInvoiceImage.NavigateUrl = "http://data.piratpartiet.se/Forms/DisplayOutboundInvoice.aspx?Reference=" + invoice.Reference + "&Culture=" + (invoice.Domestic ? invoice.Organization.DefaultCountry.Culture.Replace("-", "").ToLower() : "enus"); OutboundInvoiceItems items = invoice.Items; items.Add(OutboundInvoiceItem.FromBasic(new BasicOutboundInvoiceItem(0, 0, "PayPal/Credit Card surcharge", (Int64) (invoice.AmountCents * 0.05)))); items.Add(OutboundInvoiceItem.FromBasic(new BasicOutboundInvoiceItem(0, 0, "INVOICE TOTAL", (Int64) (invoice.AmountCents * 1.05)))); this.RepeaterItems.DataSource = items; this.RepeaterItems.DataBind(); this.LiteralPaypalButton.Text = String.Format( "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + // Asp.Net hack for PayPal "\"\"", invoice.Reference, (invoice.Amount * 1.05m).ToString("N2", CultureInfo.InvariantCulture), (invoice.Domestic?invoice.Organization.DefaultCountry.Code:"US")); } }