Created
May 3, 2012 20:59
-
-
Save t2-support-gists/2589460 to your computer and use it in GitHub Desktop.
Notary Csharp app1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| AT&T API Samples - Notary app 1 | |
| ------------------------------ | |
| This file describes how to set up, configure and run the C# Applications of the AT&T RESTFul sample applications. | |
| It covers all steps required to register the application on DevConnect and, based on the generated API keys and secrets, | |
| create and run one's own full-fledged sample applications. | |
| 1. Configuration | |
| 2. Installation | |
| 3. Parameters | |
| 4. Running the application | |
| 1. Configuration | |
| Configuration consists of a few steps necessary to get an application registered on DevConnect with the proper services and | |
| endpoints, depending on the type of client-side application (autonomous/non-autonomous). | |
| To register an application, go to https://devconnect-api.att.com/ and login with your valid username and password. | |
| Next, choose "My Apps" from the bar at the top of the page and click the "Setup a New Application" button. | |
| Fill in the form, in particular all fields marked as "required". | |
| Be careful while filling in the "OAuth Redirect URL" field. It should contain the URL that the oAuth provider will redirect | |
| users to when he/she successfully authenticates and authorizes your application. | |
| NOTE: You MUST select PAYMENT in the list of services under field 'Services' in order to use this sample application code. | |
| Having your application registered, you will get back an important pair of data: an API key and Secret key. They are | |
| necessary to get your applications working with the AT&T HTML5 APIs. See 'Adjusting parameters' below to learn how to use | |
| these keys. | |
| Initially your newly registered application is restricted to the "Sandbox" environment only. To move it to production, | |
| you may promote it by clicking the "Promote to production" button. Notice that you will get a different API key and secret, | |
| so these values in your application should be adjusted accordingly. | |
| Depending on the kind of authentication used, an application may be based on either the Autonomous Client or the Web-Server | |
| Client OAuth flow (see https://devconnect-api.att.com/docs/oauth-v1/client-credentials-grant-type or | |
| https://devconnect-api.att.com/docs/oauth-v1/authorization-code-grant-type respectively). | |
| 2. Installation | |
| ** Requirements | |
| 1. To run the this sample application you need an IIS Server. | |
| 2. Change the value of "href" at the following line in Default.aspx to point to the location of the "common.css" of "style" folder: | |
| <link rel="stylesheet" type="text/css" href="../../style/common.css"/> | |
| 3. Change the value of the "url" at the following line in common.css to point to the location of the "att.gif" of "images" folder. | |
| div#header { background:url(../images/att.gif) left center no-repeat; margin: 10px 5px} | |
| 3. Parameters | |
| Each sample application contains a config.web file. It holds configurable parameters described in an easy to read format. | |
| Please populate the following parameters in config.web as specified below: | |
| 1) api_key : {set the value as per your registered application 'API key' field value} | |
| 2) secret_key : {set the value as per your registered application 'Secret key' field value} | |
| 3) FQDN : https://api.att.com | |
| 4) scope : PAYMENT | |
| 5) paymentType : {set the value to "subscription" or "transaction"} | |
| 6) Amount : {set the value to decimal value} | |
| 7) Category : {set the value to 1,3,4 or 5} | |
| 8) Channel : {set the value to MOBILE_WEB} | |
| 9) MerchantPaymentRedirectUrl : {set the value to the notary applicatoin link} | |
| 10) IsPurchaseOnNoActiveSubscription : {set the value to false} | |
| 11) SubscriptionRecurringNumber" : {set the value to 9999} | |
| 12) SubscriptionRecurringPeriod : {set the value to MONTHLY} | |
| 13) SubscriptionRecurringPeriodAmount : {set the value to 1} | |
| 4. Running the application | |
| Suppose you copied the sample app files in your IIS server webroot/notary/app1/ folder, In order to run the sample application, type in'http://IIS_HOSTNAME/notary/app1/Default.aspx' | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> | |
| <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> | |
| <html xml:lang="en" xmlns="http://www.w3.org/1999/xhtml" lang="en"><head> | |
| <title>AT&T Sample Notary Application - Sign Payload Application</title> | |
| <meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type"> | |
| <link rel="stylesheet" type="text/css" href="../../style/common.css"/ > | |
| </script> | |
| <body> | |
| <div id="container"> | |
| <!-- open HEADER --><div id="header"> | |
| <div> | |
| <div id="hcRight"> | |
| <asp:Label runat="server" Text="Label" ID="serverTimeLabel"></asp:Label> | |
| </div> | |
| <div id="hcLeft">Server Time:</div> | |
| </div> | |
| <div> | |
| <div id="hcRight"><script language="JavaScript" type="text/javascript"> | |
| var myDate = new Date(); | |
| document.write(myDate); | |
| </script></div> | |
| <div id="hcLeft">Client Time:</div> | |
| </div> | |
| <div> | |
| <div id="hcRight"><script language="JavaScript" type="text/javascript"> | |
| document.write("" + navigator.userAgent); | |
| </script></div> | |
| <div id="hcLeft">User Agent:</div> | |
| </div> | |
| <br clear="all" /> | |
| </div><!-- close HEADER --> | |
| <div id="wrapper"> | |
| <div id="content"> | |
| <h1>A&T Sample Notary Application - Sign Payload Application</h1> | |
| </div> | |
| </div> | |
| <div id="wrapper"> | |
| <div id="content"> | |
| <h2><br /> | |
| Feature 1: Sign Payload</h2> | |
| <br/> | |
| </div> | |
| </div> | |
| <form id="form1" runat="server"> | |
| <div id="navigation"> | |
| <table border="0" width="950px"> | |
| <tbody> | |
| <tr> | |
| <td valign="top" class="label">Request:</td> | |
| <td class="cell" > | |
| <asp:TextBox runat="server" ID="requestText" Height="223px" | |
| Width="400px" TextMode="MultiLine"></asp:TextBox> | |
| <td width="50px"></td> | |
| <td valign="top" class="label">Signed Payload:</td> | |
| <td class="cell" width="400px"> | |
| <asp:TextBox runat="server" Height="223px" | |
| Width="400px" TextMode="MultiLine" | |
| ID="SignedPayLoadTextBox"></asp:TextBox> | |
| </td> | |
| </tr> | |
| <tr> | |
| <td></td> | |
| <td></td> | |
| <td width="50px"></td> | |
| <td valign="top" class="label">Signature:</td> | |
| <td class="cell"> | |
| <asp:TextBox ID="SignatureTextBox" runat="server" Height="73px" Width="400px" | |
| TextMode="MultiLine"></asp:TextBox> | |
| </td> | |
| </tr> | |
| <tr> | |
| <td></td> | |
| <td class="cell" align="right"> | |
| <asp:Button runat="server" Text="Sign Payload" ID="signPayLoadButton" | |
| onclick="signPayLoadButton_Click" /></td> | |
| </tr> | |
| </tbody></table> | |
| </div> | |
| <br clear="all" /> | |
| <div align="center"> | |
| <asp:Panel runat="server" ID="notaryPanel"> | |
| </asp:Panel></div> | |
| </form> | |
| <div id="footer"> | |
| <div style="float: right; width: 20%; font-size: 9px; text-align: right">Powered by AT&T Virtual Mobile</div> | |
| <p>© 2011 AT&T Intellectual Property. All rights reserved. <a href="http://developer.att.com/" target="_blank">http://developer.att.com</a> | |
| <br> | |
| The Application hosted on this site are working examples intended to be used for reference in creating products to consume AT&T Services and not meant to be used as part of your product. The data in these pages is for test purposes only and intended only for use as a reference in how the services perform. | |
| <br> | |
| For download of tools and documentation, please go to <a href="https://devconnect-api.att.com/" target="_blank">https://devconnect-api.att.com</a> | |
| <br> | |
| For more information contact <a href="mailto:[email protected]">[email protected]</a> | |
| </div> | |
| </div> | |
| </body></html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Collections.Generic; | |
| using System.Linq; | |
| using System.Web; | |
| using System.Web.UI; | |
| using System.Web.UI.WebControls; | |
| using System.Net; | |
| using System.IO; | |
| using System.Web.Services; | |
| using System.Text; | |
| using System.Configuration; | |
| using System.Web.Script.Serialization; | |
| using System.Drawing; | |
| using System.Net; | |
| using System.Net.Security; | |
| using System.Security.Cryptography.X509Certificates; | |
| public partial class _Default : System.Web.UI.Page | |
| { | |
| string shortCode, FQDN, oauthFlow; | |
| string api_key, secret_key, auth_code, access_token, authorize_redirect_uri, scope, expiryMilliSeconds, refresh_token, lastTokenTakenTime, refreshTokenExpiryTime; | |
| Table successTable, failureTable; | |
| string amount; | |
| Int32 category; | |
| string channel, description, merchantTransactionId, merchantProductId, merchantApplicationId; | |
| Uri merchantRedirectURI; | |
| string paymentType; | |
| string signedPayLoad, signature, goBackURL; | |
| string MerchantSubscriptionIdList, SubscriptionRecurringPeriod; | |
| Int32 SubscriptionRecurringNumber, SubscriptionRecurringPeriodAmount; | |
| string IsPurchaseOnNoActiveSubscription; | |
| DateTime transactionTime; | |
| string transactionTimeString; | |
| string payLoadStringFromRequest; | |
| public static void BypassCertificateError() | |
| { | |
| ServicePointManager.ServerCertificateValidationCallback += | |
| delegate(Object sender1, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) | |
| { | |
| return true; | |
| }; | |
| } | |
| private void readTransactionParametersFromConfigurationFile() | |
| { | |
| transactionTime = DateTime.UtcNow; | |
| transactionTimeString = String.Format("{0:ddd-MMM-dd-yyyy-HH-mm-ss}", transactionTime); | |
| if (ConfigurationManager.AppSettings["Amount"] == null) | |
| { | |
| drawPanelForFailure(notaryPanel, "Amount is not defined in configuration file"); | |
| return; | |
| } | |
| amount = ConfigurationManager.AppSettings["Amount"]; | |
| //requestText.Text = "Amount: " + amount + "\r\n"; | |
| if (ConfigurationManager.AppSettings["Category"] == null) | |
| { | |
| drawPanelForFailure(notaryPanel, "Category is not defined in configuration file"); | |
| return; | |
| } | |
| category = Convert.ToInt32(ConfigurationManager.AppSettings["Category"]); | |
| //requestText.Text = requestText.Text + "Category: " + category + "\r\n"; | |
| if (ConfigurationManager.AppSettings["Channel"] == null) | |
| { | |
| channel = "MOBILE_WEB"; | |
| } | |
| else | |
| { | |
| channel = ConfigurationManager.AppSettings["Channel"]; | |
| } | |
| //requestText.Text = requestText.Text + "Channel: " + channel + "\r\n"; | |
| description = "TrDesc" + transactionTimeString; | |
| //requestText.Text = requestText.Text + "Description: " + description + "\r\n"; | |
| merchantTransactionId = "TrId" + transactionTimeString; | |
| //requestText.Text = requestText.Text + "MerchantTransactionId: " + merchantTransactionId + "\r\n"; | |
| merchantProductId = "ProdId" + transactionTimeString; | |
| //requestText.Text = requestText.Text + "MerchantProductId: " + merchantProductId + "\r\n"; | |
| merchantApplicationId = "MerAppId" + transactionTimeString; | |
| //requestText.Text = requestText.Text + "MerchantApplicationId: " + merchantApplicationId + "\r\n"; | |
| if (ConfigurationManager.AppSettings["MerchantPaymentRedirectUrl"] == null) | |
| { | |
| drawPanelForFailure(notaryPanel, "MerchantPaymentRedirectUrl is not defined in configuration file"); | |
| return; | |
| } | |
| merchantRedirectURI = new Uri(ConfigurationManager.AppSettings["MerchantPaymentRedirectUrl"]); | |
| //requestText.Text = requestText.Text + "MerchantPaymentRedirectUrl: " + merchantRedirectURI; | |
| } | |
| private void readSubscriptionParametersFromConfigurationFile() | |
| { | |
| if (ConfigurationManager.AppSettings["MerchantSubscriptionIdList"] == null) | |
| { | |
| MerchantSubscriptionIdList = "merSubIdList" + transactionTimeString; | |
| } | |
| else | |
| { | |
| MerchantSubscriptionIdList = ConfigurationManager.AppSettings["MerchantSubscriptionIdList"]; | |
| } | |
| //requestText.Text = requestText.Text + "\r\n" + "MerchantSubscriptionIdList: " + MerchantSubscriptionIdList + "\r\n"; | |
| if (ConfigurationManager.AppSettings["SubscriptionRecurringPeriod"] == null) | |
| { | |
| SubscriptionRecurringPeriod = "MONTHLY"; | |
| } | |
| else | |
| { | |
| SubscriptionRecurringPeriod = ConfigurationManager.AppSettings["SubscriptionRecurringPeriod"]; | |
| } | |
| //requestText.Text = requestText.Text + "SubscriptionRecurringPeriod: " + SubscriptionRecurringPeriod + "\r\n"; | |
| if (ConfigurationManager.AppSettings["SubscriptionRecurringNumber"] == null) | |
| { | |
| SubscriptionRecurringNumber = Convert.ToInt32("9999"); | |
| } | |
| else | |
| { | |
| SubscriptionRecurringNumber = Convert.ToInt32(ConfigurationManager.AppSettings["SubscriptionRecurringNumber"]); | |
| } | |
| //requestText.Text = requestText.Text + "SubscriptionRecurringNumber: " + SubscriptionRecurringNumber + "\r\n"; | |
| if (ConfigurationManager.AppSettings["SubscriptionRecurringPeriodAmount"] == null) | |
| { | |
| SubscriptionRecurringPeriodAmount = Convert.ToInt32("1"); | |
| } | |
| else | |
| { | |
| SubscriptionRecurringPeriodAmount = Convert.ToInt32(ConfigurationManager.AppSettings["SubscriptionRecurringPeriodAmount"]); | |
| } | |
| // requestText.Text = requestText.Text + "SubscriptionRecurringPeriodAmount: " + SubscriptionRecurringPeriodAmount + "\r\n"; | |
| if (ConfigurationManager.AppSettings["IsPurchaseOnNoActiveSubscription"] == null) | |
| { | |
| IsPurchaseOnNoActiveSubscription = "false"; | |
| } | |
| else | |
| { | |
| IsPurchaseOnNoActiveSubscription = ConfigurationManager.AppSettings["IsPurchaseOnNoActiveSubscription"]; | |
| } | |
| //requestText.Text = requestText.Text + "IsPurchaseOnNoActiveSubscription: " + IsPurchaseOnNoActiveSubscription; | |
| } | |
| protected void Page_Load(object sender, EventArgs e) | |
| { | |
| BypassCertificateError(); | |
| DateTime currentServerTime = DateTime.UtcNow; | |
| serverTimeLabel.Text = String.Format("{0:ddd, MMM dd, yyyy HH:mm:ss}", currentServerTime) + " UTC"; | |
| FQDN = ConfigurationManager.AppSettings["FQDN"].ToString(); | |
| if (ConfigurationManager.AppSettings["FQDN"] == null) | |
| { | |
| drawPanelForFailure(notaryPanel, "FQDN is not defined in configuration file"); | |
| return; | |
| } | |
| FQDN = ConfigurationManager.AppSettings["FQDN"].ToString(); | |
| if (ConfigurationManager.AppSettings["api_key"] == null) | |
| { | |
| drawPanelForFailure(notaryPanel, "api_key is not defined in configuration file"); | |
| return; | |
| } | |
| api_key = ConfigurationManager.AppSettings["api_key"].ToString(); | |
| if (ConfigurationManager.AppSettings["secret_key"] == null) | |
| { | |
| drawPanelForFailure(notaryPanel, "secret_key is not defined in configuration file"); | |
| return; | |
| } | |
| secret_key = ConfigurationManager.AppSettings["secret_key"].ToString(); | |
| if (ConfigurationManager.AppSettings["scope"] == null) | |
| { | |
| scope = "PAYMENT"; | |
| } | |
| else | |
| { | |
| scope = ConfigurationManager.AppSettings["scope"].ToString(); | |
| } | |
| if ((Request["signed_payload"] != null) && (Request["signed_signature"] != null) | |
| && (Request["goBackURL"] != null) && (Request["signed_request"] != null)) | |
| { | |
| signPayLoadButton.Text = "Back"; | |
| requestText.Text = Request["signed_request"].ToString(); | |
| SignedPayLoadTextBox.Text = Request["signed_payload"].ToString(); | |
| SignatureTextBox.Text = Request["signed_signature"].ToString(); | |
| goBackURL = Request["goBackURL"].ToString(); | |
| } | |
| else | |
| { | |
| if ((Request["request_to_sign"] != null) && (Request["goBackURL"] != null) | |
| && (Request["api_key"] != null) && (Request["secret_key"] != null)) | |
| { | |
| payLoadStringFromRequest = Request["request_to_sign"].ToString(); | |
| goBackURL = Request["goBackURL"].ToString(); | |
| SignedPayLoadTextBox.Text = payLoadStringFromRequest.ToString(); | |
| api_key = Request["api_key"].ToString(); | |
| secret_key = Request["secret_key"].ToString(); | |
| executeSignedPayloadFromRequest(); | |
| } | |
| else | |
| { | |
| if (!Page.IsPostBack) | |
| { | |
| if (ConfigurationManager.AppSettings["paymentType"] == null) | |
| { | |
| drawPanelForFailure(notaryPanel, "paymentType is not defined in configuration file"); | |
| return; | |
| } | |
| paymentType = ConfigurationManager.AppSettings["paymentType"]; | |
| if (paymentType.Equals("Transaction", StringComparison.OrdinalIgnoreCase)) | |
| { | |
| readTransactionParametersFromConfigurationFile(); | |
| string payLoadString = "{'Amount':'" + amount.ToString() + "','Category':'" + category.ToString() + "','Channel':'" + channel.ToString() + "','Description':'" + description.ToString() + "','MerchantTransactionId':'" | |
| + merchantTransactionId.ToString() + "','MerchantProductId':'" + merchantProductId.ToString() | |
| + "','MerchantApplicaitonId':'" + merchantApplicationId.ToString() + "','MerchantPaymentRedirectUrl':'" | |
| + merchantRedirectURI.ToString() + "'}"; | |
| requestText.Text = payLoadString.ToString(); | |
| } | |
| else if (paymentType.Equals("Subscription", StringComparison.OrdinalIgnoreCase)) | |
| { | |
| readTransactionParametersFromConfigurationFile(); | |
| readSubscriptionParametersFromConfigurationFile(); | |
| string payLoadString = "{'Amount':'" + amount.ToString() + "','Category':'" + category.ToString() + "','Channel':'" + channel.ToString() + "','Description':'" + description.ToString() + "','MerchantTransactionId':'" + merchantTransactionId.ToString() + "','MerchantProductId':'" + merchantProductId.ToString() + "','MerchantApplicaitonId':'" + merchantApplicationId.ToString() + "','MerchantPaymentRedirectUrl':'" + merchantRedirectURI.ToString() + "','MerchantSubscriptionIdList':'" + MerchantSubscriptionIdList.ToString() + "','IsPurchaseOnNoActiveSubscription':'" + IsPurchaseOnNoActiveSubscription.ToString() + "','SubscriptionRecurringNumber':'" + SubscriptionRecurringNumber.ToString() + "','SubscriptionRecurringPeriod':'" + SubscriptionRecurringPeriod.ToString() + "','SubscriptionRecurringPeriodAmount':'" + SubscriptionRecurringPeriodAmount.ToString() + "'}"; | |
| requestText.Text = payLoadString.ToString(); | |
| } | |
| else | |
| { | |
| drawPanelForFailure(notaryPanel, "paymentType is defined with invalid value in configuration file. Valid values are Transaction or Subscription."); | |
| return; | |
| } | |
| } | |
| } | |
| } | |
| } | |
| public void executeSignedPayloadFromRequest() | |
| { | |
| try | |
| { | |
| string sendingData = payLoadStringFromRequest.ToString(); | |
| String newTransactionResponseData; | |
| string notaryAddress; | |
| notaryAddress = "" + FQDN + "/Security/Notary/Rest/1/SignedPayload"; | |
| //WebRequest newTransactionRequestObject = (WebRequest)System.Net.WebRequest.Create("" + FQDN + "/Security/Notary/Rest/1/SignedPayload?client_id=" + api_key.ToString() + "&client_secret=" + secret_key.ToString()); | |
| WebRequest newTransactionRequestObject = (WebRequest)System.Net.WebRequest.Create(notaryAddress); | |
| newTransactionRequestObject.Headers.Add("client_id", api_key.ToString()); | |
| newTransactionRequestObject.Headers.Add("client_secret", secret_key.ToString()); | |
| newTransactionRequestObject.Method = "POST"; | |
| newTransactionRequestObject.ContentType = "application/json"; | |
| UTF8Encoding encoding = new UTF8Encoding(); | |
| byte[] postBytes = encoding.GetBytes(sendingData); | |
| newTransactionRequestObject.ContentLength = postBytes.Length; | |
| Stream postStream = newTransactionRequestObject.GetRequestStream(); | |
| postStream.Write(postBytes, 0, postBytes.Length); | |
| postStream.Close(); | |
| WebResponse newTransactionResponseObject = (HttpWebResponse)newTransactionRequestObject.GetResponse(); | |
| using (StreamReader newTransactionResponseStream = new StreamReader(newTransactionResponseObject.GetResponseStream())) | |
| { | |
| newTransactionResponseData = newTransactionResponseStream.ReadToEnd(); | |
| JavaScriptSerializer deserializeJsonObject = new JavaScriptSerializer(); | |
| TransactionResponse deserializedJsonObj = (TransactionResponse)deserializeJsonObject.Deserialize(newTransactionResponseData, typeof(TransactionResponse)); | |
| newTransactionResponseStream.Close(); | |
| //SignedPayLoadTextBox.Text = deserializedJsonObj.SignedDocument.ToString(); | |
| //SignatureTextBox.Text = deserializedJsonObj.Signature.ToString(); | |
| Response.Redirect(goBackURL.ToString() + "?ret_signed_payload=" + deserializedJsonObj.SignedDocument.ToString() + "&ret_signature=" + deserializedJsonObj.Signature.ToString()); | |
| } | |
| } | |
| catch (Exception ex) | |
| { | |
| //SignatureTextBox.Text = ex.ToString(); | |
| //Response.Redirect(goBackURL.ToString() + "?ret_signed_payload_failed=true"); | |
| } | |
| } | |
| public bool executeSignedPayload() | |
| { | |
| try | |
| { | |
| String newTransactionResponseData; | |
| string notaryAddress; | |
| notaryAddress = "" + FQDN + "/Security/Notary/Rest/1/SignedPayload"; | |
| WebRequest newTransactionRequestObject = (WebRequest)System.Net.WebRequest.Create(notaryAddress); | |
| newTransactionRequestObject.Headers.Add("client_id", api_key.ToString()); | |
| newTransactionRequestObject.Headers.Add("client_secret", secret_key.ToString()); | |
| newTransactionRequestObject.Method = "POST"; | |
| newTransactionRequestObject.ContentType = "application/json"; | |
| UTF8Encoding encoding = new UTF8Encoding(); | |
| string payLoadString = requestText.Text.ToString(); | |
| byte[] postBytes = encoding.GetBytes(payLoadString); | |
| newTransactionRequestObject.ContentLength = postBytes.Length; | |
| Stream postStream = newTransactionRequestObject.GetRequestStream(); | |
| postStream.Write(postBytes, 0, postBytes.Length); | |
| postStream.Close(); | |
| WebResponse newTransactionResponseObject = (HttpWebResponse)newTransactionRequestObject.GetResponse(); | |
| using (StreamReader newTransactionResponseStream = new StreamReader(newTransactionResponseObject.GetResponseStream())) | |
| { | |
| newTransactionResponseData = newTransactionResponseStream.ReadToEnd(); | |
| JavaScriptSerializer deserializeJsonObject = new JavaScriptSerializer(); | |
| TransactionResponse deserializedJsonObj = (TransactionResponse)deserializeJsonObject.Deserialize(newTransactionResponseData, typeof(TransactionResponse)); | |
| SignedPayLoadTextBox.Text = deserializedJsonObj.SignedDocument.ToString(); | |
| SignatureTextBox.Text = deserializedJsonObj.Signature.ToString(); | |
| //Response.Redirect(redirectUrl.ToString()); | |
| newTransactionResponseStream.Close(); | |
| return true; | |
| } | |
| } | |
| catch (Exception ex) | |
| { | |
| return false; | |
| } | |
| } | |
| protected void signPayLoadButton_Click(object sender, EventArgs e) | |
| { | |
| if (signPayLoadButton.Text.Equals("Back", StringComparison.CurrentCultureIgnoreCase)) | |
| { | |
| try | |
| { | |
| Response.Redirect(goBackURL.ToString() + "?shown_notary=true"); | |
| } | |
| catch (Exception ex) | |
| { | |
| drawPanelForFailure(notaryPanel, ex.ToString()); | |
| } | |
| } | |
| else | |
| { | |
| bool result = executeSignedPayload(); | |
| } | |
| } | |
| private void drawPanelForFailure(Panel panelParam, string message) | |
| { | |
| failureTable = new Table(); | |
| failureTable.Font.Name = "Sans-serif"; | |
| failureTable.Font.Size = 9; | |
| failureTable.BorderStyle = BorderStyle.Outset; | |
| failureTable.Width = Unit.Pixel(650); | |
| TableRow rowOne = new TableRow(); | |
| TableCell rowOneCellOne = new TableCell(); | |
| rowOneCellOne.Font.Bold = true; | |
| rowOneCellOne.Text = "ERROR:"; | |
| rowOne.Controls.Add(rowOneCellOne); | |
| //rowOneCellOne.BorderWidth = 1; | |
| failureTable.Controls.Add(rowOne); | |
| TableRow rowTwo = new TableRow(); | |
| TableCell rowTwoCellOne = new TableCell(); | |
| //rowTwoCellOne.BorderWidth = 1; | |
| rowTwoCellOne.Text = message.ToString(); | |
| rowTwo.Controls.Add(rowTwoCellOne); | |
| failureTable.Controls.Add(rowTwo); | |
| failureTable.BorderWidth = 2; | |
| failureTable.BorderColor = Color.Red; | |
| failureTable.BackColor = System.Drawing.ColorTranslator.FromHtml("#fcc"); | |
| panelParam.Controls.Add(failureTable); | |
| } | |
| } | |
| public class AccessTokenResponse | |
| { | |
| public string access_token; | |
| public string refresh_token; | |
| public string expires_in; | |
| } | |
| public class TransactionResponse | |
| { | |
| public string SignedDocument | |
| { | |
| get; | |
| set; | |
| } | |
| public string Signature | |
| { | |
| get; | |
| set; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0"?> | |
| <!-- | |
| For more information on how to configure your ASP.NET application, please visit | |
| http://go.microsoft.com/fwlink/?LinkId=169433 | |
| --> | |
| <configuration> | |
| <system.web> | |
| <compilation debug="true" targetFramework="4.0"/> | |
| <httpRuntime maxQueryStringLength = "12288" maxRequestLength="12288"/> | |
| <customErrors mode="Off"></customErrors> | |
| </system.web> | |
| <appSettings> | |
| <!-- This is mandatory key and value should be equal | |
| to PAYMENT Service registered application 'API key' | |
| example: value="2726942c798aaaaa4bd3625d95cc7355"--> | |
| <add key="api_key" value=""/> | |
| <!-- This is mandatory key and value should be equal | |
| to PAYMENT Service registered application 'Secret key' | |
| example: value="5fb012657aaa6c7d"--> | |
| <add key="secret_key" value=""/> | |
| <!-- This is mandatory key and value should be equal | |
| to https://api.att.com for production environment | |
| example: value="https://api.att.com"--> | |
| <add key="FQDN" value=""></add> | |
| <!-- This is optional key and value should be equal | |
| to "PAYMENT" | |
| example: value="PAYMENT"--> | |
| <add key="scope" value=""/> | |
| <!-- This is mandatory key and valid values are "subscription" or "transaction" | |
| example: value="transaction"--> | |
| <add key="paymentType" value=""/> | |
| <!-- This is mandatory key and has to be decimal format | |
| example: value="2.1"--> | |
| <add key="Amount" value=""/> | |
| <!-- any decimal number --> | |
| <!-- This is mandatory key and has to be one of the value 1,3,4,5 | |
| example: value="3"--> | |
| <add key="Category" value=""/> | |
| <!--2 is not a valid value --> | |
| <!-- This is optional key and if you want to define, define only as MOBILE_WEB | |
| example: value="MOBILE_WEB"--> | |
| <add key ="Channel" value=""/> | |
| <!-- This is mandatory parameter and this will be your application url | |
| example: value="http://IIS_Server/csharpapps/notary/app1/Default.aspx"--> | |
| <add key ="MerchantPaymentRedirectUrl" value =""/> | |
| <!-- This is optional key and if you want to define, define only as false | |
| example: value="false"--> | |
| <add key ="IsPurchaseOnNoActiveSubscription" value =""/> | |
| <!-- always false --> | |
| <!-- This is optional key and if you want to define, define only as 9999 | |
| example: value="9999"--> | |
| <add key ="SubscriptionRecurringNumber" value =""/> | |
| <!-- This is optional key and if you want to define, define only as MONTHLY | |
| example: value="MONTHLY"--> | |
| <add key ="SubscriptionRecurringPeriod" value =""/> | |
| <!-- This is optional key and if you want to define, define only as 1 | |
| example: value="1"--> | |
| <add key ="SubscriptionRecurringPeriodAmount" value =""/> | |
| </appSettings> | |
| </configuration> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment