protected void Page_Load(object sender, EventArgs e) { PaymentResponse paymentResponse = new PaymentResponse(); paymentResponse.SetValues(merchantSecretKey, Request.Params); //if response valid (ok data) if (paymentResponse.IsValid()) { this.paymentResponseMessage.Text = PaymentUtils.GetPaymentResponseStatusMessage(paymentResponse.Status); } else //invalid response (corrupt data) { Response.Redirect("~/PaymentErrorWebForm.aspx?error=response invalid"); } //save values ready for payment status query //Session used just for testign Session["Stamp"] = paymentResponse.Stamp; Session["Reference"] = paymentResponse.Reference; }
protected void Page_Load(object sender, EventArgs e) { //testing query functionality Query query = new Query(); query.InitializeValues((string)Session["Stamp"], (string)Session["Reference"], this.merchantId, (string)Session["Amount"], this.merchantSecretKey); //send Query to Checkout Finland string queryResponse = ""; try { queryResponse = CheckoutClient.postQueryData(query.FormData()); } catch (WebException ex) { //exception handling for testing string errorMessage = ex.ToString(); errorMessage = (errorMessage.Length > 1000) ? errorMessage.Substring(0, 1000) : errorMessage; Response.Redirect("~/PaymentErrorWebForm.aspx?error=" + HttpUtility.UrlEncode(errorMessage)); } XDocument xmlDoc = XDocument.Parse(queryResponse); XElement statusNode = (XElement)xmlDoc.FirstNode; string statusValue = statusNode.Value; this.queryResponseMessage.Text = PaymentUtils.GetPaymentResponseStatusMessage(statusValue); XElement tradeElem = (XElement)xmlDoc.FirstNode; XElement statusElem = (XElement)tradeElem.FirstNode; this.tradeBegin.Text = tradeElem.Name.ToString(); this.tradeEnd.Text = tradeElem.Name.ToString(); this.statusBegin.Text = statusElem.Name.ToString(); this.statusEnd.Text = statusElem.Name.ToString(); this.statusValue.Text = statusElem.Value; }